]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include hash-pjw.h and remove definition of hash_pjw.
authorJim Meyering <jim@meyering.net>
Fri, 5 Oct 2001 11:46:57 +0000 (11:46 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 5 Oct 2001 11:46:57 +0000 (11:46 +0000)
src/copy.c
src/remove.c

index 77ad6b8a7dffa331854ff4bc4c162b1f615c3792..5915c0e8be4ab4feab9400e172cc44e3846622cc 100644 (file)
@@ -33,6 +33,7 @@
 #include "copy.h"
 #include "cp-hash.h"
 #include "hash.h"
+#include "hash-pjw.h"
 #include "same.h"
 #include "dirname.h"
 #include "full-write.h"
@@ -587,27 +588,6 @@ overwrite_prompt (char const *dst_path, struct stat const *dst_sb)
     }
 }
 
-/* A hash function for null-terminated char* strings using
-   the method described in Aho, Sethi, & Ullman, p 436. */
-/* FIXME: this is copied from remove.c */
-
-static unsigned int
-hash_pjw (const void *x, unsigned int tablesize)
-{
-  const char *s = x;
-  unsigned int h = 0;
-  unsigned int g;
-
-  while (*s != 0)
-    {
-      h = (h << 4) + *s++;
-      if ((g = h & (unsigned int) 0xf0000000) != 0)
-        h = (h ^ (g >> 24)) ^ g;
-    }
-
-  return (h % tablesize);
-}
-
 /* Hash a dest_info entry.  */
 static unsigned int
 dest_info_hash (void const *x, unsigned int table_size)
index 9b887021d99aa6ad820fb747fa7cb944cbfeda4e..c36928fdbb9fb0ae643f9accfe303cc5031919da 100644 (file)
@@ -32,6 +32,7 @@
 #include "error.h"
 #include "obstack.h"
 #include "hash.h"
+#include "hash-pjw.h"
 #include "quote.h"
 #include "remove.h"
 
@@ -174,26 +175,6 @@ hash_compare_active_dir_ents (void const *x, void const *y)
   return SAME_INODE (*a, *b) ? true : false;
 }
 
-/* A hash function for null-terminated char* strings using
-   the method described in Aho, Sethi, & Ullman, p 436. */
-
-static unsigned int
-hash_pjw (const void *x, unsigned int tablesize)
-{
-  const char *s = x;
-  unsigned int h = 0;
-  unsigned int g;
-
-  while (*s != 0)
-    {
-      h = (h << 4) + *s++;
-      if ((g = h & (unsigned int) 0xf0000000) != 0)
-        h = (h ^ (g >> 24)) ^ g;
-    }
-
-  return (h % tablesize);
-}
-
 static bool
 hash_compare_strings (void const *x, void const *y)
 {