From 069d9d85da438602b0afbc84748689a8b6ad5e72 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 9 Jun 2009 21:02:51 -0700 Subject: [PATCH] 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). --- backend.c | 5 +++-- winboard/winboard.c | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) 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); -- 1.7.0.4