Merge commit 'origin/stable'
[pspp-builds.git] / src / data / file-name.c
index 272e555bf89965c3ebd282531781d0c50f4f244a..91229595924c7bfe7fe11d1486970ae598950f5c 100644 (file)
@@ -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
@@ -448,9 +448,9 @@ fn_compare_file_identities (const struct file_identity *a,
 unsigned int
 fn_hash_identity (const struct file_identity *identity)
 {
-  unsigned int hash = identity->device ^ identity->inode;
+  unsigned int hash = hash_int (identity->device, identity->inode);
   if (identity->name != NULL)
-    hash ^= hsh_hash_string (identity->name);
+    hash = hash_string (identity->name, hash);
   return hash;
 }
 
@@ -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] = '/';