From 23a3ba7289d92cfaf9346cef5cc3cf51c0000015 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 28 Mar 2010 12:32:07 +0200 Subject: [PATCH] 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). --- winboard/winboard.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) 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); -- 1.7.0.4