int\r
MySearchPath(char *installDir, char *name, char *fullname)\r
{\r
- char *dummy, buf[MSG_SIZ];\r
- if(name[0] == '%' && strchr(name+1, '%')) { // [HGM] recognize %*% as environment variable\r
- strcpy(buf, name+1);\r
- *strchr(buf, '%') = 0;\r
- installDir = getenv(buf);\r
- sprintf(fullname, "%s\\%s", installDir, strchr(name+1, '%')+1);\r
- return strlen(fullname);\r
+ char *dummy, buf[MSG_SIZ], *p = name, *q;\r
+ if(name[0]== '%') {\r
+ fullname[0] = 0; // [HGM] first expand any environment variables in the given name\r
+ while(*p == '%' && (q = strchr(p+1, '%'))) { // [HGM] recognize %*% as environment variable\r
+ strcpy(buf, p+1);\r
+ *strchr(buf, '%') = 0;\r
+ strcat(fullname, getenv(buf));\r
+ p = q+1; while(*p == '\\') { strcat(fullname, "\\"); p++; }\r
+ }\r
+ strcat(fullname, p); // after environment variables (if any), take the remainder of the given name\r
+ if(appData.debugMode) fprintf(debugFP, "name = '%s', expanded name = '%s'\n", name, fullname);\r
+ return (int) strlen(fullname);\r
}\r
return (int) SearchPath(installDir, name, NULL, MSG_SIZ, fullname, &dummy);\r
}\r