summaryrefslogtreecommitdiffstats
path: root/gomoku
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2010-03-29 02:46:05 +0000
committerdholland <dholland@NetBSD.org>2010-03-29 02:46:05 +0000
commit6cf28fc0462b053c201660f30c0c3af594915b6b (patch)
tree1206c1eecff38fd3d95b845f0062df7e440b5fbe /gomoku
parent1f1f3feb63311322ca0e1478a5f0413961eba837 (diff)
downloadbsdgames-darwin-6cf28fc0462b053c201660f30c0c3af594915b6b.tar.gz
bsdgames-darwin-6cf28fc0462b053c201660f30c0c3af594915b6b.tar.zst
bsdgames-darwin-6cf28fc0462b053c201660f30c0c3af594915b6b.zip
Allow saved game filenames up to PATH_MAX. From OpenBSD.
Diffstat (limited to 'gomoku')
-rw-r--r--gomoku/main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gomoku/main.c b/gomoku/main.c
index 74fd9d76..0f9b18f9 100644
--- a/gomoku/main.c
+++ b/gomoku/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.20 2009/08/12 06:19:17 dholland Exp $ */
+/* $NetBSD: main.c,v 1.21 2010/03/29 02:46:05 dholland Exp $ */
/*
* Copyright (c) 1994
@@ -42,12 +42,13 @@ __COPYRIGHT("@(#) Copyright (c) 1994\
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: main.c,v 1.20 2009/08/12 06:19:17 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.21 2010/03/29 02:46:05 dholland Exp $");
#endif
#endif /* not lint */
#include <curses.h>
#include <err.h>
+#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
@@ -88,6 +89,7 @@ int
main(int argc, char **argv)
{
char buf[128];
+ char fname[PATH_MAX];
int color, curmove, i, ch;
int input[2];
static const char *const fmt[2] = {
@@ -255,8 +257,8 @@ again:
FILE *fp;
ask("save file name? ");
- (void)get_line(buf, sizeof(buf));
- if ((fp = fopen(buf, "w")) == NULL) {
+ (void)get_line(fname, sizeof(fname));
+ if ((fp = fopen(fname, "w")) == NULL) {
misclog("cannot create save file");
goto getinput;
}
@@ -314,8 +316,8 @@ again:
FILE *fp;
ask("save file name? ");
- (void)get_line(buf, sizeof(buf));
- if ((fp = fopen(buf, "w")) == NULL) {
+ (void)get_line(fname, sizeof(fname));
+ if ((fp = fopen(fname, "w")) == NULL) {
misclog("cannot create save file");
goto replay;
}