X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Ffile-name.c;h=601afd5579e04a2ffff00193166989aedcd8e3b5;hb=9fe6585fa66655a4e5a366488fb0ba613e784b3f;hp=f861028682f8c3391b440d475579c45e1c9e6f1e;hpb=2402013898889076c67683f1582f90448f4fa6ef;p=pspp-builds.git diff --git a/src/data/file-name.c b/src/data/file-name.c index f8610286..601afd55 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -454,31 +454,45 @@ fn_hash_identity (const struct file_identity *identity) return hash; } - - -#ifdef WINDOWS32 +#ifdef WIN32 /* Apparently windoze users like to see output dumped into their home directory, not the current directory (!) */ const char * default_output_path (void) { - static const char *home_dir = NULL; + static char *path = NULL; - /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference - to HOME, because the user can change HOME. */ - if (home_dir == NULL) + if ( path == NULL) { - const char *home_drive = getenv ("HOMEDRIVE"); - const char *home_path = getenv ("HOMEPATH"); + /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference + to HOME, because the user can change HOME. */ - if (home_drive != NULL && home_path != NULL) - home_dir = xasprintf ("%s%s%c", - home_drive, home_path, DIRECTORY_SEPARATOR); - else - home_dir = "c:/users/default/"; /* poor default */ + const char *home_dir = getenv ("HOME"); + int i; + + if (home_dir == NULL) + { + 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); + } + + if (home_dir == NULL) + home_dir = "c:/users/default"; /* poor default */ + + path = xasprintf ("%s%c", home_dir, '/'); + + + for(i = 0; i < strlen (path); i++) + if (path[i] == '\\') path[i] = '/'; } - return home_dir; + + return path; } #else