From 168ca19e0f412a537388cea5c4d8fa0a39f082a5 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Sat, 9 Nov 2013 22:54:37 +0100 Subject: [PATCH] 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. --- gnushogi/rawdsp.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) 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); -- 1.7.0.4