From 5db8386400bc43a01bc82473e6d30bd3b1b11591 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 6 Jan 2010 23:54:49 +0100 Subject: [PATCH] Change format of -adapterCommand. first or f at the start of an option name are now automatically changed into second or s, rather than needing %% to be recognized. The values of -ec and -ed in the default -adapterCommand are now quoted (now XBoard understands quoting in the engine command line). --- args.h | 2 +- uci.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) mode change 100644 => 100755 uci.c diff --git a/args.h b/args.h index e23b506..079851e 100644 --- a/args.h +++ b/args.h @@ -529,7 +529,7 @@ ArgDescriptor argDescriptors[] = { { "secondHasOwnBookUCI", ArgBoolean, (void *) &appData.secondHasOwnBookUCI, FALSE, (ArgIniType) TRUE }, { "sNoOwnBookUCI", ArgFalse, (void *) &appData.secondHasOwnBookUCI, FALSE, INVALID }, { "secondXBook", ArgFalse, (void *) &appData.secondHasOwnBookUCI, FALSE, INVALID }, - { "adapterCommand", ArgFilename, (void *) &appData.adapterCommand, TRUE, (ArgIniType) "polyglot -noini -ec %%cp -ed %%d" }, + { "adapterCommand", ArgFilename, (void *) &appData.adapterCommand, TRUE, (ArgIniType) "polyglot -noini -ec \"%fcp\" -ed \"%fd\"" }, { "polyglotDir", ArgFilename, (void *) &appData.polyglotDir, TRUE, (ArgIniType) "" }, { "usePolyglotBook", ArgBoolean, (void *) &appData.usePolyglotBook, TRUE, (ArgIniType) FALSE }, { "polyglotBook", ArgFilename, (void *) &appData.polyglotBook, TRUE, (ArgIniType) "" }, diff --git a/uci.c b/uci.c old mode 100644 new mode 100755 index 0885ee0..5eeda2b --- a/uci.c +++ b/uci.c @@ -24,6 +24,7 @@ */ #include #include +#include #if HAVE_MALLOC_H #include @@ -31,7 +32,7 @@ #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 @@ -44,13 +45,18 @@ void InitEngineUCI( const char * iniDir, ChessProgramState * cps ) 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(*p >= '0' && *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); if(GetArgValue(argName)) { // look up value of option with this name s = argName; while(*s) *q++ = *s++; -- 1.7.0.4