- const char * iniFileName = GetIniFilename( cps );
- char polyglotIniFile[ MAX_PATH ];
- FILE * f;
-
- /* Build name of initialization file */
- if( strchr( iniDir, ' ' ) != NULL ) {
- char iniDirShort[ MAX_PATH ];
-#ifdef WIN32
- GetShortPathName( iniDir, iniDirShort, sizeof(iniDirShort) );
-
- strcpy( polyglotIniFile, iniDirShort );
-#else
- // [HGM] UCI: not sure if this works, but GetShortPathName seems Windows pecific
- // and names with spaces in it do not work in xboard in many places, so ignore
- strcpy( polyglotIniFile, iniDir );
-#endif
- }
- else {
- strcpy( polyglotIniFile, iniDir );
- }
-
- strcat( polyglotIniFile, SLASH_CHAR );
- strcat( polyglotIniFile, iniFileName );
-
- /* Create initialization file */
- f = fopen( polyglotIniFile, "w" );
-
- if( f != NULL ) {
- fprintf( f, "[Polyglot]\n" );
-
- if( cps->dir != 0 && strlen(cps->dir) > 0 ) {
- fprintf( f, "EngineDir = %s\n", cps->dir );
- }
-
- if( cps->program != 0 && strlen(cps->program) > 0 ) {
- fprintf( f, "EngineCommand = %s\n", cps->program );
+ 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], 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++;