X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Ffile-name.c;h=91229595924c7bfe7fe11d1486970ae598950f5c;hb=cba0d9a3d5873beddd0d241cc672fbf0cdaf0e07;hp=601afd5579e04a2ffff00193166989aedcd8e3b5;hpb=b5c82cc9aabe7e641011130240ae1b2e84348e23;p=pspp-builds.git diff --git a/src/data/file-name.c b/src/data/file-name.c index 601afd55..91229595 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -476,7 +476,6 @@ default_output_path (void) const char *home_drive = getenv ("HOMEDRIVE"); const char *home_path = getenv ("HOMEPATH"); - if (home_drive != NULL && home_path != NULL) home_dir = xasprintf ("%s%s", home_drive, home_path); @@ -485,8 +484,14 @@ default_output_path (void) if (home_dir == NULL) home_dir = "c:/users/default"; /* poor default */ - path = xasprintf ("%s%c", home_dir, '/'); - + /* Copy home_dir into path. Add a slash at the end but + only if there isn't already one there, because Windows + treats // specially. */ + if (home_dir[0] == '\0' + || strchr ("/\\", home_dir[strlen (home_dir) - 1]) == NULL) + path = xasprintf ("%s%c", home_dir, '/'); + else + path = xstrdup (home_dir); for(i = 0; i < strlen (path); i++) if (path[i] == '\\') path[i] = '/';