From: Ben Pfaff Date: Fri, 17 Jul 2009 03:48:18 +0000 (-0700) Subject: Fix failure to write output file in GUI on Windows when HOMEPATH is "\". X-Git-Tag: v0.6.2-pre5~2 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10ac8c99bd7a4155216e9bc3e48dd30e63b11642;p=pspp-builds.git Fix failure to write output file in GUI on Windows when HOMEPATH is "\". Thanks to Michel Boaventura for reporting this problem: http://lists.gnu.org/archive/html/pspp-dev/2009-07/msg00064.html --- diff --git a/src/data/file-name.c b/src/data/file-name.c index 272e555b..642947cb 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -485,7 +485,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++)