Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/larn - rename getchar to lgetchar to avoid conflicts w...
details: https://anonhg.NetBSD.org/src/rev/fe5f9a2bca7e
branches: trunk
changeset: 503361:fe5f9a2bca7e
user: christos <christos%NetBSD.org@localhost>
date: Mon Feb 05 00:57:32 2001 +0000
description:
- rename getchar to lgetchar to avoid conflicts with the stdio getchar
- fix redundant decls and nested externs
- use snprintf instead of sprintf
diffstat:
games/larn/bill.c | 19 +++++++++++--------
games/larn/extern.h | 4 ++--
games/larn/global.c | 31 ++++++++++++++-----------------
games/larn/header.h | 4 ++--
games/larn/help.c | 8 ++++----
games/larn/io.c | 10 +++++-----
games/larn/main.c | 13 +++++++------
games/larn/monster.c | 14 +++++++-------
games/larn/moreobj.c | 17 ++++++++---------
games/larn/object.c | 42 +++++++++++++++++++++---------------------
games/larn/scores.c | 12 +++++++-----
games/larn/signal.c | 10 ++++++----
games/larn/store.c | 20 ++++++++++----------
13 files changed, 104 insertions(+), 100 deletions(-)
diffs (truncated from 790 to 300 lines):
diff -r 77a500cd0f5c -r fe5f9a2bca7e games/larn/bill.c
--- a/games/larn/bill.c Mon Feb 05 00:42:14 2001 +0000
+++ b/games/larn/bill.c Mon Feb 05 00:57:32 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bill.c,v 1.5 1997/10/18 20:03:06 christos Exp $ */
+/* $NetBSD: bill.c,v 1.6 2001/02/05 00:57:32 christos Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -38,15 +38,15 @@
#if 0
static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91";
#else
-__RCSID("$NetBSD: bill.c,v 1.5 1997/10/18 20:03:06 christos Exp $");
+__RCSID("$NetBSD: bill.c,v 1.6 2001/02/05 00:57:32 christos Exp $");
#endif
#endif /* not lint */
#include <sys/file.h>
#include <sys/wait.h>
+#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <stdio.h>
#include <unistd.h>
#include "header.h"
#include "extern.h"
@@ -134,18 +134,21 @@
if (fork() == 0) {
resetscroll();
cp = mail;
- sprintf(fname, "/tmp/#%dlarnmail", getpid());
+ snprintf(fname, sizeof(fname), "/tmp/#%dlarnmail", getpid());
for (i = 0; i < 6; i++) {
if ((fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT,
0666)) == -1)
exit(0);
while (*cp != NULL) {
if (*cp[0] == '1') {
- sprintf(buf, "\n%ld gold pieces back with you from your journey. As the",
+ snprintf(buf, sizeof(buf),
+ "\n%ld gold pieces back with you from your journey. As the",
(long) c[GOLD]);
write(fd, buf, strlen(buf));
} else if (*cp[0] == '2') {
- sprintf(buf, "\nin preparing your tax bill. You owe %ld gold pieces as", (long) c[GOLD] * TAXRATE);
+ snprintf(buf, sizeof(buf),
+ "\nin preparing your tax bill. You owe %ld gold pieces as",
+ (long) c[GOLD] * TAXRATE);
write(fd, buf, strlen(buf));
} else
write(fd, *cp, strlen(*cp));
@@ -154,8 +157,8 @@
cp++;
close(fd);
- sprintf(buf, "mail -I %s < %s > /dev/null",
- loginname, fname);
+ snprintf(buf, sizeof(buf),
+ "mail -I %s < %s > /dev/null", loginname, fname);
system(buf);
unlink(fname);
}
diff -r 77a500cd0f5c -r fe5f9a2bca7e games/larn/extern.h
--- a/games/larn/extern.h Mon Feb 05 00:42:14 2001 +0000
+++ b/games/larn/extern.h Mon Feb 05 00:57:32 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.2 1999/10/04 23:27:02 lukem Exp $ */
+/* $NetBSD: extern.h,v 1.3 2001/02/05 00:57:33 christos Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -127,7 +127,7 @@
/* io.c */
void setupvt100 __P((void));
void clearvt100 __P((void));
-int getchar __P((void));
+int lgetchar __P((void));
void scbr __P((void));
void sncbr __P((void));
void newgame __P((void));
diff -r 77a500cd0f5c -r fe5f9a2bca7e games/larn/global.c
--- a/games/larn/global.c Mon Feb 05 00:42:14 2001 +0000
+++ b/games/larn/global.c Mon Feb 05 00:57:32 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: global.c,v 1.6 1997/10/18 20:03:20 christos Exp $ */
+/* $NetBSD: global.c,v 1.7 2001/02/05 00:57:33 christos Exp $ */
/*
* global.c Larn is copyrighted 1986 by Noah Morgan.
@@ -23,22 +23,20 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: global.c,v 1.6 1997/10/18 20:03:20 christos Exp $");
+__RCSID("$NetBSD: global.c,v 1.7 2001/02/05 00:57:33 christos Exp $");
#endif /* not lint */
#include <string.h>
#include <unistd.h>
#include "header.h"
#include "extern.h"
-extern int score[], srcount, dropflag;
-extern int random; /* the random number seed */
-extern short playerx, playery, lastnum, level;
-extern u_char cheat;
-extern char monstnamelist[], logname[];
-extern char lastmonst[], *what[], *who[];
+extern int score[], dropflag;
+extern int random; /* the random number seed */
+extern char *what[], *who[];
extern char winner[];
-extern u_char monstlevel[];
-extern char sciv[SCORESIZE + 1][26][2], *potionname[], *scrollname[];
+extern char sciv[SCORESIZE + 1][26][2];
+extern char *password;
+
/*
***********
RAISE LEVEL
@@ -435,7 +433,7 @@
strcpy(lastmonst, "");
lprcat("\n\nDo you really want to quit?");
while (1) {
- i = getchar();
+ i = lgetchar();
if (i == 'y') {
died(300);
return;
@@ -466,7 +464,7 @@
lprcat("\n --- press ");
standout("space");
lprcat(" to continue --- ");
- while (getchar() != ' ');
+ while (lgetchar() != ' ');
}
/*
@@ -808,10 +806,10 @@
{
int i, j;
i = 50;
- while ((getchar() != '"') && (--i > 0));
+ while ((lgetchar() != '"') && (--i > 0));
i = 36;
while (--i > 0) {
- if ((j = getchar()) != '"')
+ if ((j = lgetchar()) != '"')
*str++ = j;
else
i = 0;
@@ -820,7 +818,7 @@
i = 50;
if (j != '"')
/* if end due to too long, then find closing quote */
- while ((getchar() != '"') && (--i > 0));
+ while ((lgetchar() != '"') && (--i > 0));
}
/*
@@ -833,7 +831,6 @@
{
int i, j;
char *gpwp;
- extern char *password;
scbr(); /* system("stty -echo cbreak"); */
gpwp = gpwbuf;
lprcat("\nEnter Password: ");
@@ -861,7 +858,7 @@
int i;
i = 0;
while (i != 'y' && i != 'n' && i != '\33')
- i = getchar();
+ i = lgetchar();
return (i);
}
diff -r 77a500cd0f5c -r fe5f9a2bca7e games/larn/header.h
--- a/games/larn/header.h Mon Feb 05 00:42:14 2001 +0000
+++ b/games/larn/header.h Mon Feb 05 00:57:32 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: header.h,v 1.12 1997/10/25 01:40:48 thorpej Exp $ */
+/* $NetBSD: header.h,v 1.13 2001/02/05 00:57:33 christos Exp $ */
/* header.h Larn is copyrighted 1986 by Noah Morgan. */
@@ -332,7 +332,7 @@
extern u_char alpha[], beenhere[], boldon, cheat, ckpflag;
extern u_char *class[], course[];
extern char diagfile[], helpfile[], ckpfile[], larnlevels[],
- playerids[], optsfile[], psname[], savefilename[],
+ playerids[], optsfile[1024], psname[], savefilename[],
scorefile[];
extern u_char *inbuffer, is_alpha[], is_digit[];
extern u_char item[MAXX][MAXY], iven[], know[MAXX][MAXY];
diff -r 77a500cd0f5c -r fe5f9a2bca7e games/larn/help.c
--- a/games/larn/help.c Mon Feb 05 00:42:14 2001 +0000
+++ b/games/larn/help.c Mon Feb 05 00:57:32 2001 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: help.c,v 1.4 1997/10/18 20:03:24 christos Exp $ */
+/* $NetBSD: help.c,v 1.5 2001/02/05 00:57:33 christos Exp $ */
/* help.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: help.c,v 1.4 1997/10/18 20:03:24 christos Exp $");
+__RCSID("$NetBSD: help.c,v 1.5 2001/02/05 00:57:33 christos Exp $");
#endif /* not lint */
#include <unistd.h>
@@ -51,7 +51,7 @@
lprcat(" for more help ---- ");
i = 0;
while ((i != ' ') && (i != '\n') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if ((i == '\n') || (i == '\33')) {
lrclose();
setscroll();
@@ -102,7 +102,7 @@
lprcat("Press ");
standout("return");
lprcat(" to continue: ");
- while (getchar() != '\n');
+ while (lgetchar() != '\n');
setscroll();
}
diff -r 77a500cd0f5c -r fe5f9a2bca7e games/larn/io.c
--- a/games/larn/io.c Mon Feb 05 00:42:14 2001 +0000
+++ b/games/larn/io.c Mon Feb 05 00:57:32 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.10 2000/05/24 14:20:29 blymn Exp $ */
+/* $NetBSD: io.c,v 1.11 2001/02/05 00:57:33 christos Exp $ */
/*
* io.c Larn is copyrighted 1986 by Noah Morgan.
@@ -7,7 +7,7 @@
*
* setupvt100() Subroutine to set up terminal in correct mode for game
* clearvt100() Subroutine to clean up terminal when the game is over
- * getchar() Routine to read in one character from the terminal
+ * lgetchar() Routine to read in one character from the terminal
* scbr() Function to set cbreak -echo for the terminal
* sncbr() Function to set -cbreak echo for the terminal
* newgame() Subroutine to save the initial time and seed rnd()
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: io.c,v 1.10 2000/05/24 14:20:29 blymn Exp $");
+__RCSID("$NetBSD: io.c,v 1.11 2001/02/05 00:57:33 christos Exp $");
#endif /* not lint */
#include "header.h"
@@ -164,10 +164,10 @@
}
/*
- * getchar() Routine to read in one character from the terminal
+ * lgetchar() Routine to read in one character from the terminal
*/
int
-getchar()
+lgetchar()
{
char byt;
#ifdef EXTRA
diff -r 77a500cd0f5c -r fe5f9a2bca7e games/larn/main.c
--- a/games/larn/main.c Mon Feb 05 00:42:14 2001 +0000
+++ b/games/larn/main.c Mon Feb 05 00:57:32 2001 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: main.c,v 1.15 2000/05/22 12:42:46 blymn Exp $ */
+/* $NetBSD: main.c,v 1.16 2001/02/05 00:57:33 christos Exp $ */
/* main.c */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.15 2000/05/22 12:42:46 blymn Exp $");
+__RCSID("$NetBSD: main.c,v 1.16 2001/02/05 00:57:33 christos Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -100,7 +100,8 @@
strcpy(savefilename, ptr);
strcat(savefilename, "/Larn.sav"); /* save file name in home
* directory */
- sprintf(optsfile, "%s/.larnopts", ptr); /* the .larnopts filename */
+ snprintf(optsfile, sizeof(optsfile), "%s/.larnopts", ptr);
+ /* the .larnopts filename */
/*
* now malloc the memory for the dungeon
@@ -1272,7 +1273,7 @@
lprintf("\nWhat do you want to %s [* for all] ? ", str);
i = 0;
while (i > 'z' || (i < 'a' && i != '*' && i != '\33' && i != '.'))
- i = getchar();
+ i = lgetchar();
if (i == '\33')
Home |
Main Index |
Thread Index |
Old Index