From: H.G.Muller Date: Wed, 27 Apr 2016 19:41:45 +0000 (+0200) Subject: Make resistant to empty lines X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=3f02c0b84e29979405064a927952a21bd2427045;p=hachu.git Make resistant to empty lines An empty line (emitted by XBoard due to a bug) made HaChu repeat the previous command. Now the GetLine routine keeps reading until it gets a non-empty line. --- diff --git a/hachu.c b/hachu.c index 7c672d4..bb26721 100644 --- a/hachu.c +++ b/hachu.c @@ -2792,8 +2792,10 @@ printf("# setup done");fflush(stdout); int i, c; while(1) { // wait for input, and read it until we have collected a complete line - for(i = 0; (inBuf[i] = c = getchar()) != '\n'; i++) if(c == EOF || i>7997) exit(0); - inBuf[i+1] = 0; + do { + for(i = 0; (inBuf[i] = c = getchar()) != '\n'; i++) if(c == EOF || i>7997) exit(0); + inBuf[i+1] = 0; + } while(!i); // ignore empty lines // extract the first word sscanf(inBuf, "%s", command);