X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=uci.c;h=55aaff5defe90e554cf52d31e298847b6be133a0;hb=d9f4b584106f4d7477158476ff792f6fa0b2630a;hp=5eeda2b5ebc83639d60a0fa1cbbf052b45abaa76;hpb=952edaa8941552b9d0faef8d06161f44c2cc83fd;p=xboard.git diff --git a/uci.c b/uci.c index 5eeda2b..55aaff5 100644 --- a/uci.c +++ b/uci.c @@ -23,13 +23,10 @@ * ------------------------------------------------------------------------ */ #include +#include #include #include -#if HAVE_MALLOC_H - #include -#endif - #include "common.h" #include "backend.h" Boolean GetArgValue(char *a); @@ -40,6 +37,7 @@ 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) { @@ -50,13 +48,13 @@ void InitEngineUCI( const char * iniDir, ChessProgramState * cps ) *s++ = cps == &first ? 'f' : 's'; p++; } - while(*p >= '0' && *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 - strcpy(argName, buf); - } else strcpy(argName, buf); + 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++;