Diversify UCI string options into -string, -path and -file
[uci2wb.git] / UCI2WB.c
index 4d3a4df..2db1424 100644 (file)
--- a/UCI2WB.c
+++ b/UCI2WB.c
@@ -55,7 +55,7 @@ FILE *toE, *fromE, *fromF;
 int pid;\r
 \r
 #ifdef WIN32\r
-char *strcasestr (char *p, char *q) { char *r = p; while(*r) *r = tolower(*r), r++; return strstr(p, q); }\r
+char *strcasestr (char *p, char *q) { while(*p) { char *r=p++, *s=q; while(tolower(*r++) == tolower(*s) && *s) s++; if(!*s) return p-1; } return NULL; }\r
 \r
 WinPipe(HANDLE *hRd, HANDLE *hWr)\r
 {\r
@@ -358,6 +358,10 @@ Engine2GUI()
            sprintf(buf, ",%s,", name); if(strcasestr(EGT, buf)) { buf[strlen(buf)-5] = 0; strcat(egts, buf); continue; } // collect EGT formats\r
            // pass on engine-defined option as WB option feature\r
            if(!strcmp(type, "filename")) type[4] = 0;\r
+           else if(sc == 'c' && !strcmp(type, "string")) { // in UCI try to guess which strings are file or directory names\r
+               if(strcasestr(name, "file")) strcpy(type, "file"); else\r
+               if(strcasestr(name, "path") || strcasestr(name, "directory") || strcasestr(name, "folder")) strcpy(type, "path");\r
+           }\r
            sprintf(buf, "feature option=\"%s -%s", name, type); q = buf + strlen(buf);\r
            if(     !strcmp(type, "file")\r
                 || !strcmp(type, "string")) sprintf(q, " %s\"\n", val);\r