Use Bob Jenkins lookup3 hash instead of FNV.
[pspp-builds.git] / src / data / file-name.c
index 86c8e17e467d45c3cf7edac34166b20357cba62f..f861028682f8c3391b440d475579c45e1c9e6f1e 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
@@ -138,6 +138,7 @@ fn_search_path (const char *base_name, const char *path_)
       if (!ds_is_empty (&file) && !ISSLASH (ds_last (&file)))
        ds_put_char (&file, '/');
       ds_put_cstr (&file, base_name);
+      ds_relocate (&file);
 
       /* Check whether file exists. */
       if (fn_exists (ds_cstr (&file)))
@@ -447,8 +448,50 @@ 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;
 }
+
+
+
+#ifdef WINDOWS32
+
+/* 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;
+
+  /* Windows NT defines HOMEDRIVE and HOMEPATH.  But give preference
+     to HOME, because the user can change HOME.  */
+  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%c",
+                             home_drive, home_path, DIRECTORY_SEPARATOR);
+      else
+       home_dir = "c:/users/default/"; /* poor default */
+    }
+  return home_dir;
+}
+
+#else
+
+/* ... whereas the rest of the world just likes it to be
+   put "here" for easy access. */
+const char *
+default_output_path (void)
+{
+  static char current_dir[]  = "";
+
+  return current_dir;
+}
+
+#endif
+