$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 #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 {