From: Yann Dirson Date: Sat, 9 Nov 2013 21:54:37 +0000 (+0100) Subject: Restore interactive "level" mode in xshogi proto, by dropping trailing newline in... X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=168ca19e0f412a537388cea5c4d8fa0a39f082a5;p=gnushogi.git Restore interactive "level" mode in xshogi proto, by dropping trailing newline in GetString. Not very interesting in itself, except that bug was causing some code to be dead in Raw_SelectLevel, and several similar functions should be made similar to that one to implement xboard protocol correctly. --- diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 8a6ec66..bf3f4c1 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -162,10 +162,17 @@ int Raw_GetString(char* sx) { int eof = 0; + char *nl; sx[0] = '\0'; while(!eof && !sx[0]) eof = (fgets(sx, 80, stdin) == NULL); + + /* remove any trailing newline */ + nl = strchr(sx, '\n'); + if (nl) + nl[0] = '\0'; + return eof; } @@ -698,6 +705,7 @@ Raw_GiveHint(void) void Raw_SelectLevel(char *sx) { + /* FIXME: NO_SQUARES is nonsense here */ char T[NO_SQUARES + 1], *p; strncpy(T, sx, NO_SQUARES);