]> Savannah Git Hosting - gnulib.git/commitdiff
Rename module hash-pjw to hashcode-string.
authorBruno Haible <bruno@clisp.org>
Tue, 29 Apr 2025 22:15:40 +0000 (00:15 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 29 Apr 2025 22:51:27 +0000 (00:51 +0200)
* lib/hashcode-string.h: Renamed from lib/hash-pjw.h.
* lib/hashcode-string.c: Renamed from lib/hash-pjw.c.
* lib/hash-pjw.h: New file.
* modules/hashcode-string: Renamed from modules/hash-pjw.
* modules/hash-pjw: New file.
* MODULES.html.sh: Update.
* top/maint.mk: Update.
* lib/hash-triple-simple.c: Update.
* modules/hash-triple-simple (Depends-on): Update.
* tests/test-hash.c: Update.
* modules/hash-tests (Depends-on): Update.

13 files changed:
ChangeLog
MODULES.html.sh
lib/hash-pjw.c [deleted file]
lib/hash-pjw.h
lib/hash-triple-simple.c
lib/hashcode-string.c [new file with mode: 0644]
lib/hashcode-string.h [new file with mode: 0644]
modules/hash-pjw
modules/hash-tests
modules/hash-triple-simple
modules/hashcode-string [new file with mode: 0644]
tests/test-hash.c
top/maint.mk

index 85c9d767bd7cdc7f1ca6d42ba6d9fdaef3c25421..6fee9a0a5c0d4085dde9471963ca7206efc88b5d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-04-29  Bruno Haible  <bruno@clisp.org>
+
+       Rename module hash-pjw to hashcode-string.
+       * lib/hashcode-string.h: Renamed from lib/hash-pjw.h.
+       * lib/hashcode-string.c: Renamed from lib/hash-pjw.c.
+       * lib/hash-pjw.h: New file.
+       * modules/hashcode-string: Renamed from modules/hash-pjw.
+       * modules/hash-pjw: New file.
+       * MODULES.html.sh: Update.
+       * top/maint.mk: Update.
+       * lib/hash-triple-simple.c: Update.
+       * modules/hash-triple-simple (Depends-on): Update.
+       * tests/test-hash.c: Update.
+       * modules/hash-tests (Depends-on): Update.
+
 2025-04-29  Bruno Haible  <bruno@clisp.org>
 
        Rename module hash-pjw-bare to hashcode-mem.
index 9aab40c27f4b56c5ed22f4284fbe03710d0434a3..c80ea9d7a228c0ad011ca2031868f28c30121368 100755 (executable)
@@ -2095,7 +2095,7 @@ func_all_modules ()
   func_module obstack
   func_module obstack-printf
   func_module obstack-printf-posix
-  func_module hash-pjw
+  func_module hashcode-string
   func_module hashcode-mem
   func_module hash
   func_module hamt
diff --git a/lib/hash-pjw.c b/lib/hash-pjw.c
deleted file mode 100644 (file)
index fbe8ef6..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* hash-pjw.c -- compute a hash value from a NUL-terminated string.
-
-   Copyright (C) 2001, 2003, 2006, 2009-2025 Free Software Foundation, Inc.
-
-   This file is free software: you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   This file is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-#include "hash-pjw.h"
-
-#include <limits.h>
-
-#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
-
-/* A hash function for NUL-terminated char* strings using
-   the method described by Bruno Haible.
-   See https://www.haible.de/bruno/hashfunc.html.  */
-
-size_t
-hash_pjw (const void *x, size_t tablesize)
-{
-  const char *s;
-  size_t h = 0;
-
-  for (s = x; *s; s++)
-    h = *s + ((h << 9) | (h >> (SIZE_BITS - 9)));
-
-  return h % tablesize;
-}
index 1d9ffeaaa0a2833be870ee33f9bd23cffaf8a731..14af42a8919d95c1096c8aa637c86bf7492a93a0 100644 (file)
@@ -1,5 +1,5 @@
 /* hash-pjw.h -- declaration for a simple hash function
-   Copyright (C) 2001, 2003, 2009-2025 Free Software Foundation, Inc.
+   Copyright (C) 2025 Free Software Foundation, Inc.
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
-/* This file uses _GL_ATTRIBUTE_PURE.  */
-#if !_GL_CONFIG_H_INCLUDED
- #error "Please include config.h first."
-#endif
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Compute a hash code for a NUL-terminated string starting at X,
-   and return the hash code modulo TABLESIZE.
-   The result is platform dependent: it depends on the size of the 'size_t'
-   type and on the signedness of the 'char' type.  */
-extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE;
-
+#include "hashcode-string.h"
 
-#ifdef __cplusplus
-}
+#if __GNUC__ || (__clang_major__ >= 4)
+# warning "The include file hash-pjw.h is deprecated. Use hashcode-string.h instead."
 #endif
index 51d1332833aec36fd3d3ba57a36d61d26ec391a3..4bb71375f4e56a1b3e1778bc77bab60a450111a3 100644 (file)
@@ -24,7 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "hash-pjw.h"
+#include "hashcode-string.h"
 #include "same-inode.h"
 
 #define STREQ(a, b) (strcmp (a, b) == 0)
diff --git a/lib/hashcode-string.c b/lib/hashcode-string.c
new file mode 100644 (file)
index 0000000..6943d7b
--- /dev/null
@@ -0,0 +1,41 @@
+/* hashcode-string.c -- compute a hash value from a NUL-terminated string.
+
+   Copyright (C) 2001, 2003, 2006, 2009-2025 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "hashcode-string.h"
+
+#include <limits.h>
+
+#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
+
+/* A hash function for NUL-terminated char* strings using
+   the method described by Bruno Haible.
+   See https://www.haible.de/bruno/hashfunc.html.  */
+
+size_t
+hash_pjw (const void *x, size_t tablesize)
+{
+  const char *s;
+  size_t h = 0;
+
+  for (s = x; *s; s++)
+    h = *s + ((h << 9) | (h >> (SIZE_BITS - 9)));
+
+  return h % tablesize;
+}
diff --git a/lib/hashcode-string.h b/lib/hashcode-string.h
new file mode 100644 (file)
index 0000000..af99f4e
--- /dev/null
@@ -0,0 +1,38 @@
+/* hashcode-string.h -- declaration for a simple hash function
+   Copyright (C) 2001, 2003, 2009-2025 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* This file uses _GL_ATTRIBUTE_PURE.  */
+#if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+#endif
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Compute a hash code for a NUL-terminated string starting at X,
+   and return the hash code modulo TABLESIZE.
+   The result is platform dependent: it depends on the size of the 'size_t'
+   type and on the signedness of the 'char' type.  */
+extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE;
+
+
+#ifdef __cplusplus
+}
+#endif
index 3bd6ad5c5f309df7cd6c2e85ed74e5942d0c4a22..56193fa2d19294f6f0c13fa31a49cca3d15ba285 100644 (file)
@@ -1,22 +1,25 @@
 Description:
 Compute a hash value for a NUL-terminated string.
 
+Status:
+deprecated
+
+Notice:
+This module is deprecated. Use the module 'hashcode-string' instead.
+
 Files:
-lib/hash-pjw.h
-lib/hash-pjw.c
 
 Depends-on:
+hashcode-string
 
 configure.ac:
 
 Makefile.am:
-lib_SOURCES += hash-pjw.h hash-pjw.c
 
 Include:
-"hash-pjw.h"
+"hashcode-string.h"
 
 License:
 LGPLv2+
 
 Maintainer:
-Jim Meyering
index e598573e12be1866d490e4d7514fd3804a18421b..c9593f347dc13d7c5f5f0eca7c7d4bed4f7c8cce 100644 (file)
@@ -3,7 +3,7 @@ tests/test-hash.c
 tests/macros.h
 
 Depends-on:
-hash-pjw
+hashcode-string
 inttostr
 bool
 
index 53a472f870cbb55443763b3d55fcf6ffb40c0425..a78c019b17041a20a11d67b775e165d8182aa04c 100644 (file)
@@ -6,7 +6,7 @@ lib/hash-triple-simple.c
 lib/hash-triple.h
 
 Depends-on:
-hash-pjw
+hashcode-string
 same-inode
 bool
 
diff --git a/modules/hashcode-string b/modules/hashcode-string
new file mode 100644 (file)
index 0000000..a948451
--- /dev/null
@@ -0,0 +1,23 @@
+Description:
+Compute a hash value for a NUL-terminated string.
+
+Files:
+lib/hashcode-string.h
+lib/hashcode-string.c
+lib/hash-pjw.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += hashcode-string.h hashcode-string.c
+
+Include:
+"hashcode-string.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+Jim Meyering
index a2a34506c1015f9c1c7c839778ba02f577d16323..e7735684be3e85ca861286a9d14b99b988e0dde9 100644 (file)
@@ -18,7 +18,7 @@
 #include <config.h>
 
 #include "hash.h"
-#include "hash-pjw.h"
+#include "hashcode-string.h"
 #include "inttostr.h"
 
 #include <stdio.h>
index 54c5e8275307f3d4b3d56d9060be5cf6c46e4109..a5392fc9388d825afe044f57568856fbab4a92e5 100644 (file)
@@ -728,8 +728,8 @@ sc_prohibit_posixver_without_use:
 sc_prohibit_same_without_use:
        @h='same.h' re='\<same_name(at)? *\(' $(_sc_header_without_use)
 
-sc_prohibit_hash_pjw_without_use:
-       @h='hash-pjw.h' \
+sc_prohibit_hashcode_string_without_use:
+       @h='hashcode-string.h' \
        re='\<hash_pjw\>' \
          $(_sc_header_without_use)