From: H.G. Muller Date: Sun, 28 Mar 2010 10:32:07 +0000 (+0200) Subject: Allow any %ENVIRONMENTVAR% in WB settings file name rather than ~ X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=23a3ba7289d92cfaf9346cef5cc3cf51c0000015;p=xboard.git Allow any %ENVIRONMENTVAR% in WB settings file name rather than ~ Only a single variable at the beginning of the file name is recognized, and the matching is not fool proof (it matches across backslashes). --- diff --git a/winboard/winboard.c b/winboard/winboard.c index 509ba76..87eb9eb 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -1222,13 +1222,12 @@ PrintCommPortSettings(FILE *f, char *name) int MySearchPath(char *installDir, char *name, char *fullname) { - char *dummy; - if(name[0] == '~' && name[1] == '\\') { // [HGM] recognize ~ as HOMEPATH environment variable - installDir = getenv("HOMEPATH"); - name += 2; - strcpy(fullname, installDir); - strcat(fullname, "\\"); - strcat(fullname, name); + char *dummy, buf[MSG_SIZ]; + if(name[0] == '%' && strchr(name+1, '%')) { // [HGM] recognize %*% as environment variable + strcpy(buf, name+1); + *strchr(buf, '%') = 0; + installDir = getenv(buf); + sprintf(fullname, "%s\\%s", installDir, strchr(name+1, '%')+1); return strlen(fullname); } return (int) SearchPath(installDir, name, NULL, MSG_SIZ, fullname, &dummy);