From 3f02c0b84e29979405064a927952a21bd2427045 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Wed, 27 Apr 2016 21:41:45 +0200 Subject: [PATCH] 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. --- hachu.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) 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); -- 1.7.0.4