Fix string options with empty default
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 24 Dec 2016 18:41:11 +0000 (19:41 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 24 Dec 2016 18:44:58 +0000 (19:44 +0100)
When sscanf finds nothing after 'default', it does not touch the target
array at all, rather than putting an empty string in it. So the target
is now initialized to an empty string before the sscanf.

UCI2WB.c

index cbc11f7..6b4d19d 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -332,7 +332,7 @@ Engine2GUI()
        }\r
        else if(!strcmp(command, "option")) { // USI option: extract data fields\r
            char name[80], type[80], buf[1024], val[256], *q;\r
-           int min=0, max=1e9;\r
+           int min=0, max=1e9; *val = 0;\r
            if(p = strstr(line+6, " type ")) sscanf(p+1, "type %s", type), *p = '\n';\r
            if(p = strstr(line+6, " min "))  sscanf(p+1, "min %d", &min), *p = '\n';\r
            if(p = strstr(line+6, " max "))  sscanf(p+1, "max %d", &max), *p = '\n';\r