summaryrefslogtreecommitdiffstats
path: root/larn
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2001-02-05 00:57:32 +0000
committerchristos <christos@NetBSD.org>2001-02-05 00:57:32 +0000
commitb1c8e14afd5a078ca925fe471733a693ca4a8076 (patch)
tree479753089c657c4900becbda1592945edbc418bb /larn
parent5813ff28d2110a139386e10f5e3977f3b88dbda8 (diff)
downloadbsdgames-darwin-b1c8e14afd5a078ca925fe471733a693ca4a8076.tar.gz
bsdgames-darwin-b1c8e14afd5a078ca925fe471733a693ca4a8076.tar.zst
bsdgames-darwin-b1c8e14afd5a078ca925fe471733a693ca4a8076.zip
- rename getchar to lgetchar to avoid conflicts with the stdio getchar
- fix redundant decls and nested externs - use snprintf instead of sprintf
Diffstat (limited to 'larn')
-rw-r--r--larn/bill.c19
-rw-r--r--larn/extern.h4
-rw-r--r--larn/global.c31
-rw-r--r--larn/header.h4
-rw-r--r--larn/help.c8
-rw-r--r--larn/io.c10
-rw-r--r--larn/main.c13
-rw-r--r--larn/monster.c14
-rw-r--r--larn/moreobj.c17
-rw-r--r--larn/object.c42
-rw-r--r--larn/scores.c12
-rw-r--r--larn/signal.c10
-rw-r--r--larn/store.c20
13 files changed, 104 insertions, 100 deletions
diff --git a/larn/bill.c b/larn/bill.c
index dbc71495..22e271e0 100644
--- a/larn/bill.c
+++ b/larn/bill.c
@@ -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 @@ mailbill()
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 @@ mailbill()
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 --git a/larn/extern.h b/larn/extern.h
index bb1b26f9..6f496777 100644
--- a/larn/extern.h
+++ b/larn/extern.h
@@ -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 @@ int openhelp __P((void));
/* 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 --git a/larn/global.c b/larn/global.c
index 90e41823..c4e75bfb 100644
--- a/larn/global.c
+++ b/larn/global.c
@@ -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 @@ quit()
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 @@ more()
lprcat("\n --- press ");
standout("space");
lprcat(" to continue --- ");
- while (getchar() != ' ');
+ while (lgetchar() != ' ');
}
/*
@@ -808,10 +806,10 @@ gettokstr(str)
{
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 @@ gettokstr(str)
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 @@ getpassword()
{
int i, j;
char *gpwp;
- extern char *password;
scbr(); /* system("stty -echo cbreak"); */
gpwp = gpwbuf;
lprcat("\nEnter Password: ");
@@ -861,7 +858,7 @@ getyn()
int i;
i = 0;
while (i != 'y' && i != 'n' && i != '\33')
- i = getchar();
+ i = lgetchar();
return (i);
}
diff --git a/larn/header.h b/larn/header.h
index 6812680c..66823741 100644
--- a/larn/header.h
+++ b/larn/header.h
@@ -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 char VERSION, SUBVERSION;
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 --git a/larn/help.c b/larn/help.c
index d0c1af04..42c87e6d 100644
--- a/larn/help.c
+++ b/larn/help.c
@@ -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 @@ help()
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 @@ retcont()
lprcat("Press ");
standout("return");
lprcat(" to continue: ");
- while (getchar() != '\n');
+ while (lgetchar() != '\n');
setscroll();
}
diff --git a/larn/io.c b/larn/io.c
index 73952da8..b9f963fa 100644
--- a/larn/io.c
+++ b/larn/io.c
@@ -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 @@ clearvt100()
}
/*
- * 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 --git a/larn/main.c b/larn/main.c
index eba8146c..41a1498c 100644
--- a/larn/main.c
+++ b/larn/main.c
@@ -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 @@ main(argc, argv)
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 @@ whatitem(str)
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')
lprcat(" aborted");
return (i);
@@ -1289,7 +1290,7 @@ readnum(mx)
int i;
unsigned long amt = 0;
sncbr();
- if ((i = getchar()) == '*')
+ if ((i = lgetchar()) == '*')
amt = mx; /* allow him to say * for all gold */
else
while (i != '\n') {
@@ -1300,7 +1301,7 @@ readnum(mx)
}
if ((i <= '9') && (i >= '0') && (amt < 99999999))
amt = amt * 10 + i - '0';
- i = getchar();
+ i = lgetchar();
}
scbr();
return (amt);
diff --git a/larn/monster.c b/larn/monster.c
index 3761bb82..5d0562a9 100644
--- a/larn/monster.c
+++ b/larn/monster.c
@@ -1,4 +1,4 @@
-/* $NetBSD: monster.c,v 1.6 1998/08/30 09:19:38 veego Exp $ */
+/* $NetBSD: monster.c,v 1.7 2001/02/05 00:57:33 christos Exp $ */
/*
* monster.c Larn is copyrighted 1986 by Noah Morgan.
@@ -100,7 +100,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: monster.c,v 1.6 1998/08/30 09:19:38 veego Exp $");
+__RCSID("$NetBSD: monster.c,v 1.7 2001/02/05 00:57:33 christos Exp $");
#endif /* not lint */
#include <string.h>
@@ -233,16 +233,16 @@ cast()
}
lprcat(eys);
--c[SPELLS];
- while ((a = getchar()) == 'D') {
+ while ((a = lgetchar()) == 'D') {
seemagic(-1);
cursors();
lprcat(eys);
}
if (a == '\33')
goto over; /* to escape casting a spell */
- if ((b = getchar()) == '\33')
+ if ((b = lgetchar()) == '\33')
goto over; /* to escape casting a spell */
- if ((d = getchar()) == '\33') {
+ if ((d = lgetchar()) == '\33') {
over: lprcat(aborted);
c[SPELLS]++;
return;
@@ -996,7 +996,7 @@ dirsub(x, y)
int i;
lprcat("\nIn What Direction? ");
for (i = 0;;)
- switch (getchar()) {
+ switch (lgetchar()) {
case 'b':
i++;
case 'n':
@@ -1894,7 +1894,7 @@ genmonst()
int i, j;
cursors();
lprcat("\nGenocide what monster? ");
- for (i = 0; (!isalpha(i)) && (i != ' '); i = getchar());
+ for (i = 0; (!isalpha(i)) && (i != ' '); i = lgetchar());
lprc(i);
for (j = 0; j < MAXMONST; j++) /* search for the monster type */
if (monstnamelist[j] == i) { /* have we found it? */
diff --git a/larn/moreobj.c b/larn/moreobj.c
index 7c6766f7..f2fe8bcb 100644
--- a/larn/moreobj.c
+++ b/larn/moreobj.c
@@ -1,4 +1,4 @@
-/* $NetBSD: moreobj.c,v 1.4 1997/10/18 20:03:32 christos Exp $ */
+/* $NetBSD: moreobj.c,v 1.5 2001/02/05 00:57:34 christos Exp $ */
/*
* moreobj.c Larn is copyrighted 1986 by Noah Morgan.
@@ -9,9 +9,8 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: moreobj.c,v 1.4 1997/10/18 20:03:32 christos Exp $");
+__RCSID("$NetBSD: moreobj.c,v 1.5 2001/02/05 00:57:34 christos Exp $");
#endif /* not lint */
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "header.h"
@@ -36,11 +35,11 @@ oaltar()
iopts();
while (1) {
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case 'p':
lprcat(" pray\nDo you (m) give money or (j) just pray? ");
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case 'j':
if (rnd(100) < 75)
lprcat("\nnothing happens");
@@ -154,7 +153,7 @@ othrone(arg)
iopts();
while (1) {
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case 'p':
lprcat(" pry off");
k = rnd(101);
@@ -204,7 +203,7 @@ odeadthrone()
iopts();
while (1) {
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case 's':
lprcat(" sit down");
k = rnd(101);
@@ -239,7 +238,7 @@ ochest()
iopts();
while (1) {
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case 'o':
lprcat(" open it");
k = rnd(101);
@@ -308,7 +307,7 @@ ofountain()
lprcat("\nDo you (d) drink, (w) wash yourself");
iopts();
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case 'd':
lprcat("drink");
if (rnd(1501) < 2) {
diff --git a/larn/object.c b/larn/object.c
index bfda5a17..59df0215 100644
--- a/larn/object.c
+++ b/larn/object.c
@@ -1,10 +1,10 @@
-/* $NetBSD: object.c,v 1.9 1998/08/30 09:19:38 veego Exp $ */
+/* $NetBSD: object.c,v 1.10 2001/02/05 00:57:34 christos Exp $ */
/* object.c Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: object.c,v 1.9 1998/08/30 09:19:38 veego Exp $");
+__RCSID("$NetBSD: object.c,v 1.10 2001/02/05 00:57:34 christos Exp $");
#endif /* not lint */
#include "header.h"
#include "extern.h"
@@ -149,7 +149,7 @@ lookforobject()
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if (i == 'g') {
oschool(); /* the college of larn */
} else
@@ -174,7 +174,7 @@ lookforobject()
lprcat("\nDo you (g) go inside, or (i) stay here? ");
j = 0;
while ((j != 'g') && (j != 'i') && (j != '\33'))
- j = getchar();
+ j = lgetchar();
if (j == 'g') {
if (i == OBANK)
obank();
@@ -197,7 +197,7 @@ lookforobject()
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if (i == 'g')
dndstore(); /* the dnd adventurers store */
else
@@ -220,7 +220,7 @@ lookforobject()
iopts();
i = 0;
while ((i != 'c') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if ((i == '\33') || (i == 'i')) {
ignore();
break;
@@ -239,7 +239,7 @@ lookforobject()
iopts();
i = 0;
while ((i != 'o') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if ((i == '\33') || (i == 'i')) {
ignore();
playerx = lastpx;
@@ -290,7 +290,7 @@ lookforobject()
iopts();
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if (i == 'g') {
newcavelevel(1);
playerx = 33;
@@ -310,7 +310,7 @@ lookforobject()
iopts();
i = 0;
while ((i != 'c') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if ((i == '\33') || (i == 'i')) {
ignore();
break;
@@ -350,7 +350,7 @@ lookforobject()
iopts();
i = 0;
while ((i != 'c') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if ((i == '\33') || (i == 'i')) {
ignore();
break;
@@ -446,7 +446,7 @@ lookforobject()
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if (i == 'g')
otradepost();
else
@@ -460,7 +460,7 @@ lookforobject()
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if (i == 'g')
ohome();
else
@@ -481,7 +481,7 @@ lookforobject()
lprcat("\nDo you (g) go inside, or (i) stay here? ");
i = 0;
while ((i != 'g') && (i != 'i') && (i != '\33'))
- i = getchar();
+ i = lgetchar();
if (i == 'g')
olrs(); /* the larn revenue service */
else
@@ -525,7 +525,7 @@ finditem(itm)
iopts();
i = 0;
while (i != 't' && i != 'i' && i != '\33')
- i = getchar();
+ i = lgetchar();
if (i == 't') {
lprcat("take");
if (take(itm, tmp) == 0)
@@ -558,7 +558,7 @@ ostairs(dir)
lprcat("or (f) kick stairs? ");
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case '\33':
case 's':
case 'i':
@@ -663,7 +663,7 @@ opotion(pot)
lprcat("\nDo you (d) drink it, (t) take it");
iopts();
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case '\33':
case 'i':
ignore();
@@ -879,7 +879,7 @@ oscroll(typ)
lprcat("(t) take it");
iopts();
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case '\33':
case 'i':
ignore();
@@ -1173,7 +1173,7 @@ obook()
lprcat("(t) take it");
iopts();
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case '\33':
case 'i':
ignore();
@@ -1223,7 +1223,7 @@ ocookie()
lprcat("\nDo you (e) eat it, (t) take it");
iopts();
while (1)
- switch (getchar()) {
+ switch (lgetchar()) {
case '\33':
case 'i':
ignore();
@@ -1323,9 +1323,9 @@ ohome()
lprcat(" to continue, ");
standout("escape");
lprcat(" to leave ----- ");
- i = getchar();
+ i = lgetchar();
while (i != '\33' && i != '\n')
- i = getchar();
+ i = lgetchar();
if (i == '\33') {
drawscreen();
nosignal = 0; /* enable signals */
diff --git a/larn/scores.c b/larn/scores.c
index 2fbe635e..e9082a95 100644
--- a/larn/scores.c
+++ b/larn/scores.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.10 1997/10/18 20:03:48 christos Exp $ */
+/* $NetBSD: scores.c,v 1.11 2001/02/05 00:57:34 christos Exp $ */
/*
* scores.c Larn is copyrighted 1986 by Noah Morgan.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: scores.c,v 1.10 1997/10/18 20:03:48 christos Exp $");
+__RCSID("$NetBSD: scores.c,v 1.11 2001/02/05 00:57:34 christos Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/times.h>
@@ -668,9 +668,11 @@ invalid:
mod = "an";
else
mod = "a";
- sprintf(logg.what, "killed by %s %s", mod, monster[x].name);
+ snprintf(logg.what, sizeof(logg.what),
+ "killed by %s %s", mod, monster[x].name);
} else
- sprintf(logg.what, "%s", whydead[x - 256]);
+ snprintf(logg.what, sizeof(logg.what),
+ "%s", whydead[x - 256]);
logg.cavelev = level;
time(&zzz); /* get cpu time -- write out score info */
logg.diedtime = zzz;
@@ -797,7 +799,7 @@ getplid(nam)
if (havepid != -1)
return (havepid); /* already did it */
lflush(); /* flush any pending I/O */
- sprintf(name, "%s\n", nam); /* append a \n to name */
+ snprintf(name, sizeof(name), "%s\n", nam);/* append a \n to name */
if (lopen(playerids) < 0) { /* no file, make it */
if ((fd7 = creat(playerids, 0666)) < 0)
return (-1); /* can't make it */
diff --git a/larn/signal.c b/larn/signal.c
index e16ff8ee..2b08a052 100644
--- a/larn/signal.c
+++ b/larn/signal.c
@@ -1,14 +1,14 @@
-/* $NetBSD: signal.c,v 1.6 1997/10/18 20:03:50 christos Exp $ */
+/* $NetBSD: signal.c,v 1.7 2001/02/05 00:57:34 christos Exp $ */
/* "Larn is copyrighted 1986 by Noah Morgan.\n" */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: signal.c,v 1.6 1997/10/18 20:03:50 christos Exp $");
+__RCSID("$NetBSD: signal.c,v 1.7 2001/02/05 00:57:34 christos Exp $");
#endif /* not lint */
-#include <stdio.h>
#include <signal.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "header.h"
@@ -131,7 +131,9 @@ sigpanic(sig)
{
char buf[128];
signal(sig, SIG_DFL);
- sprintf(buf, "\nLarn - Panic! Signal %d received [SIG%s]", sig, sys_signame[sig]);
+ snprintf(buf, sizeof(buf),
+ "\nLarn - Panic! Signal %d received [SIG%s]", sig,
+ sys_signame[sig]);
write(2, buf, strlen(buf));
sleep(2);
sncbr();
diff --git a/larn/store.c b/larn/store.c
index fce6efc3..837edf71 100644
--- a/larn/store.c
+++ b/larn/store.c
@@ -1,4 +1,4 @@
-/* $NetBSD: store.c,v 1.7 1998/08/30 09:19:38 veego Exp $ */
+/* $NetBSD: store.c,v 1.8 2001/02/05 00:57:34 christos Exp $ */
/*-
* Copyright (c) 1988 The Regents of the University of California.
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)store.c 5.4 (Berkeley) 5/13/91";
#else
-__RCSID("$NetBSD: store.c,v 1.7 1998/08/30 09:19:38 veego Exp $");
+__RCSID("$NetBSD: store.c,v 1.8 2001/02/05 00:57:34 christos Exp $");
#endif
#endif /* not lint */
@@ -253,7 +253,7 @@ dndstore()
lflush();
i = 0;
while (i != '\33')
- i = getchar();
+ i = lgetchar();
drawscreen();
nosignal = 0; /* enable signals */
return;
@@ -271,7 +271,7 @@ dndstore()
lprcat(" to leave]? ");
i = 0;
while ((i < 'a' || i > 'z') && (i != ' ') && (i != '\33') && (i != 12))
- i = getchar();
+ i = lgetchar();
if (i == 12) {
clear();
dnd_2hed();
@@ -406,7 +406,7 @@ oschool()
yrepcount = 0;
i = 0;
while ((i < 'a' || i > 'h') && (i != '\33') && (i != 12))
- i = getchar();
+ i = lgetchar();
if (i == 12) {
sch_hed();
continue;
@@ -545,7 +545,7 @@ banktitle(str)
lflush();
i = 0;
while (i != '\33')
- i = getchar();
+ i = lgetchar();
drawscreen();
nosignal = 0; /* enable signals */
return;
@@ -626,7 +626,7 @@ obanksub()
yrepcount = 0;
i = 0;
while (i != 'd' && i != 'w' && i != 's' && i != '\33')
- i = getchar();
+ i = lgetchar();
switch (i) {
case 'd':
lprcat("deposit\nHow much? ");
@@ -664,7 +664,7 @@ obanksub()
lprcat("\nWhich stone would you like to sell? ");
i = 0;
while ((i < 'a' || i > 'z') && i != '*')
- i = getchar();
+ i = lgetchar();
if (i == '*')
for (i = 0; i < 26; i++) {
if (gemvalue[i]) {
@@ -770,7 +770,7 @@ otradepost()
lprcat("] ? ");
i = 0;
while (i > 'z' || (i < 'a' && i != '*' && i != '\33' && i != '.'))
- i = getchar();
+ i = lgetchar();
if (i == '\33') {
setscroll();
recalc();
@@ -874,7 +874,7 @@ olrs()
yrepcount = 0;
i = 0;
while (i != 'p' && i != '\33')
- i = getchar();
+ i = lgetchar();
switch (i) {
case 'p':
lprcat("pay taxes\nHow much? ");