summaryrefslogtreecommitdiff
path: root/games/velena/patches/patch-cmdline_c
diff options
context:
space:
mode:
Diffstat (limited to 'games/velena/patches/patch-cmdline_c')
-rw-r--r--games/velena/patches/patch-cmdline_c38
1 files changed, 38 insertions, 0 deletions
diff --git a/games/velena/patches/patch-cmdline_c b/games/velena/patches/patch-cmdline_c
new file mode 100644
index 00000000000..fe3f0c80068
--- /dev/null
+++ b/games/velena/patches/patch-cmdline_c
@@ -0,0 +1,38 @@
+$NetBSD: patch-cmdline_c,v 1.1 2011/05/28 22:41:43 dholland Exp $
+
+- declare external functions
+- improve input prompting
+- don't use gets
+
+--- cmdline.c.orig 1997-07-27 21:14:18.000000000 +0000
++++ cmdline.c
+@@ -16,6 +16,7 @@
+ #include <stdio.h>
+
+ #include "connect4.h"
++#include "proto.h"
+
+ // Here's the interface for sending positions to velena engine
+ // positions are passed in a C string in the form of: x+y+'0'
+@@ -42,16 +43,19 @@ void command_line_input(struct board *bo
+ int flag = 1,answer;
+ char st[80];
+
+- printf("Enter positions in the form x+y+'0', where:\n");
++ setvbuf(stdout, NULL, _IONBF, 0);
++ printf("Enter positions in the form xy0, where:\n");
+ printf("x is the level of play: 'a' = weak, 'b' = normal, 'c' = strong\n");
+ printf("y is a sequence of moves that brings to the position you want\n");
+ printf(" (columns are numbered from 1 to 7)\n");
+ printf("'0' is the 48 ASCII char which tells Velena where the string ends\n");
++ printf("Example: c4444350\n");
+ printf("\nEnter 'q' to quit\n\n");
+
+ do {
+ printf(">"); // Waiting for the user to enter the string
+- gets(st);
++ if (fgets(st, sizeof(st), stdin) == NULL)
++ break;
+
+ if(st[0]=='q') flag = 0; // if the string begins with 'q' we quit.
+ else {