From: H.G. Muller Date: Wed, 10 Jun 2009 04:02:51 +0000 (-0700) Subject: automatically test ini file extension for files from commandline option @filename X-Git-Tag: v4.4.0.alpha6~18 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=069d9d85da438602b0afbc84748689a8b6ad5e72;p=xboard.git automatically test ini file extension for files from commandline option @filename The winboard.c is a patch that automatically tries indirection files on the command line (@filename type arguments) also with an extension .ini if the name itself did not match any existing file and contained no period. This saves the user typing the .ini all the time (which I started to find pretty annoying while working on the installer package). --- diff --git a/backend.c b/backend.c index 0e36ec2..b2dad3b 100644 --- a/backend.c +++ b/backend.c @@ -12401,8 +12401,9 @@ ParseOption(Option *opt, ChessProgramState *cps) } else return FALSE; *p = 0; // terminate option name // now look if the command-line options define a setting for this engine option. - p = strstr(cps->optionSettings, opt->name); - if(p == cps->optionSettings || p[-1] == ',') { + if(cps->optionSettings && cps->optionSettings[0]) + p = strstr(cps->optionSettings, opt->name); else p = NULL; + if(p && (p == cps->optionSettings || p[-1] == ',')) { sprintf(buf, "option %s", p); if(p = strstr(buf, ",")) *p = 0; strcat(buf, "\n"); diff --git a/winboard/winboard.c b/winboard/winboard.c index bdfc1f3..f4e6c0d 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -495,6 +495,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, if (!InitInstance(hInstance, nCmdShow, lpCmdLine)) { return (FALSE); } + // InitCommonControlsEx(&ex); InitCommonControls(); @@ -1428,8 +1429,14 @@ ParseSettingsFile(char *name, char fullname[MSG_SIZ]) { char *dummy; FILE *f; + int ok; char buf[MSG_SIZ]; - if (SearchPath(installDir, name, NULL, MSG_SIZ, fullname, &dummy)) { + ok = SearchPath(installDir, name, NULL, MSG_SIZ, fullname, &dummy); + if(!ok && strchr(name, '.') == NULL) { // [HGM] append default file-name extension '.ini' when needed + sprintf(buf, "%s.ini", name); + ok = SearchPath(installDir, buf, NULL, MSG_SIZ, fullname, &dummy); + } + if (ok) { f = fopen(fullname, "r"); if (f != NULL) { ParseArgs(FileGet, f);