From 175e677c82a13e7251eedbae865ab8af4ddb8fd1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 5 Oct 2001 11:46:57 +0000 Subject: [PATCH] Include hash-pjw.h and remove definition of hash_pjw. --- src/copy.c | 22 +--------------------- src/remove.c | 21 +-------------------- 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/src/copy.c b/src/copy.c index 77ad6b8a7d..5915c0e8be 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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) diff --git a/src/remove.c b/src/remove.c index 9b887021d9..c36928fdbb 100644 --- a/src/remove.c +++ b/src/remove.c @@ -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) { -- 2.47.3