Fix UCI_Variant command
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 12 Jun 2019 08:08:53 +0000 (10:08 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 12 Jun 2019 08:08:53 +0000 (10:08 +0200)
The variant list was not properly terminated after replacing the UCI
'var' keywords by commas for use in a CECP variants feature.

UCI2WB.c

index eb3ddc7..1cfa030 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -383,10 +383,11 @@ HandleEngineOutput()
        }\r
        else if(!strcmp(command, "readyok")) return; // resume processing of GUI commands\r
        else if(sc == 'x'&& !strcmp(command, "ucciok") || sscanf(command, "u%ciok", &c)==1 && c==sc) {\r
-           char *p = varList, *q = varList;\r
+           char *p = varList, *q = p;\r
            while(*q && *q != '\n')  if(!strncmp(q, " var ", 5)) *p++ = ',', q +=5; // replace var keywords by commas\r
                                else if(!strncmp(q-1, " chess ", 7)) strcpy(p, "normal"), p += 6, q += 5; // 'chess' is called 'normal' in CECP\r
                                else *p++ = *q++; // copy other variant names unmodified\r
+           *p = 0;\r
            if(frc) sprintf(p, ",normal,fischerandom"), printf("feature oocastle=%d\n", frc<0); // unannounced FRC uses O-O castling\r
            if(!*varList) strcpy(varList, sc=='s' ? ",shogi,5x5+5_shogi" : VARIANTS); // without clue guess liberally\r
            printf("feature variants=\"%s\"\n", varList+1); // from UCI_Variant combo and/or UCI_Chess960 check options\r