Module Name: src
Committed By: dholland
Date: Thu Jun 4 06:47:36 UTC 2009
Modified Files:
src/games/gomoku: gomoku.h main.c
Log Message:
Remove global scratch string buffer. Don't zoom off the end while reading
user input, either.
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.16 -r1.17 src/games/gomoku/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/gomoku/gomoku.h
diff -u src/games/gomoku/gomoku.h:1.14 src/games/gomoku/gomoku.h:1.15
--- src/games/gomoku/gomoku.h:1.14 Thu Jun 4 06:41:50 2009
+++ src/games/gomoku/gomoku.h Thu Jun 4 06:47:36 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: gomoku.h,v 1.14 2009/06/04 06:41:50 dholland Exp $ */
+/* $NetBSD: gomoku.h,v 1.15 2009/06/04 06:47:36 dholland Exp $ */
/*
* Copyright (c) 1994
@@ -246,7 +246,6 @@
};
extern const char *letters;
-extern char fmtbuf[];
extern const char pdir[];
extern const int dd[4];
Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.16 src/games/gomoku/main.c:1.17
--- src/games/gomoku/main.c:1.16 Thu Jun 4 06:27:47 2009
+++ src/games/gomoku/main.c Thu Jun 4 06:47:36 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.16 2009/06/04 06:27:47 dholland Exp $ */
+/* $NetBSD: main.c,v 1.17 2009/06/04 06:47:36 dholland Exp $ */
/*
* Copyright (c) 1994
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: main.c,v 1.16 2009/06/04 06:27:47 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.17 2009/06/04 06:47:36 dholland Exp $");
#endif
#endif /* not lint */
@@ -69,7 +69,6 @@
FILE *inputfp; /* file for debug input */
const char pdir[4] = "-\\|/";
-char fmtbuf[128];
struct spotstr board[BAREA]; /* info for board */
struct combostr frames[FAREA]; /* storage for all frames */
@@ -333,14 +332,15 @@
int
readinput(FILE *fp)
{
- char *cp;
int c;
+ char buf[128];
+ size_t pos;
- cp = fmtbuf;
- while ((c = getc(fp)) != EOF && c != '\n')
- *cp++ = c;
- *cp = '\0';
- return (ctos(fmtbuf));
+ pos = 0;
+ while ((c = getc(fp)) != EOF && c != '\n' && pos < sizeof(buf) - 1)
+ buf[pos++] = c;
+ buf[pos] = '\0';
+ return ctos(buf);
}
#ifdef DEBUG