X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=uci.c;h=55aaff5defe90e554cf52d31e298847b6be133a0;hb=ca6061cbffe88ff5eb2332e733e0a534b89cc5e7;hp=0885ee01f2692e34f12abe968bf7935e036c63c8;hpb=8f1501373295f172dd1118391c6ee914ecbc4e67;p=xboard.git diff --git a/uci.c b/uci.c index 0885ee0..55aaff5 100644 --- a/uci.c +++ b/uci.c @@ -23,15 +23,13 @@ * ------------------------------------------------------------------------ */ #include +#include #include - -#if HAVE_MALLOC_H - #include -#endif +#include #include "common.h" #include "backend.h" - +Boolean GetArgValue(char *a); void InitEngineUCI( const char * iniDir, ChessProgramState * cps ) { // replace engine command line by adapter command with expanded meta-symbols @@ -39,18 +37,24 @@ void InitEngineUCI( const char * iniDir, ChessProgramState * cps ) char *p, *q; char polyglotCommand[MSG_SIZ]; + if(cps->isUCI == 2) p = appData.ucciAdapter; else p = appData.adapterCommand; q = polyglotCommand; while(*p) { if(*p == '\\') p++; else if(*p == '%') { // substitute marker - char argName[MSG_SIZ], *s = argName; + char argName[MSG_SIZ], buf[MSG_SIZ], *s = buf; if(*++p == '%') { // second %, expand as f or s in option name (e.g. %%cp -> fcp) *s++ = cps == &first ? 'f' : 's'; p++; } - while(*p != ' ' && *p) *s++ = *p++; // copy option name + while(isdigit(*p) || isalpha(*p)) *s++ = *p++; // copy option name *s = NULLCHAR; + if(cps == &second) { // change options for first into those for second engine + if(strstr(buf, "first") == buf) sprintf(argName, "second%s", buf+5); else + if(buf[0] == 'f') sprintf(argName, "s%s", buf+1); else + safeStrCpy(argName, buf, sizeof(argName)/sizeof(argName[0])); + } else safeStrCpy(argName, buf, sizeof(argName)/sizeof(argName[0])); if(GetArgValue(argName)) { // look up value of option with this name s = argName; while(*s) *q++ = *s++;