From 261415b09686bc5da188d446f8f16f92dd9372bb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 30 Apr 2025 00:15:40 +0200 Subject: [PATCH] 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. --- ChangeLog | 15 +++++++++++ MODULES.html.sh | 2 +- lib/hash-pjw.h | 25 +++--------------- lib/hash-triple-simple.c | 2 +- lib/{hash-pjw.c => hashcode-string.c} | 5 ++-- lib/hashcode-string.h | 38 +++++++++++++++++++++++++++ modules/hash-pjw | 13 +++++---- modules/hash-tests | 2 +- modules/hash-triple-simple | 2 +- modules/hashcode-string | 23 ++++++++++++++++ tests/test-hash.c | 2 +- top/maint.mk | 4 +-- 12 files changed, 98 insertions(+), 35 deletions(-) rename lib/{hash-pjw.c => hashcode-string.c} (90%) create mode 100644 lib/hashcode-string.h create mode 100644 modules/hashcode-string diff --git a/ChangeLog b/ChangeLog index 85c9d767bd..6fee9a0a5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2025-04-29 Bruno Haible + + 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 Rename module hash-pjw-bare to hashcode-mem. diff --git a/MODULES.html.sh b/MODULES.html.sh index 9aab40c27f..c80ea9d7a2 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -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.h b/lib/hash-pjw.h index 1d9ffeaaa0..14af42a891 100644 --- a/lib/hash-pjw.h +++ b/lib/hash-pjw.h @@ -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 @@ -14,25 +14,8 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -/* This file uses _GL_ATTRIBUTE_PURE. */ -#if !_GL_CONFIG_H_INCLUDED - #error "Please include config.h first." -#endif - -#include - -#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 diff --git a/lib/hash-triple-simple.c b/lib/hash-triple-simple.c index 51d1332833..4bb71375f4 100644 --- a/lib/hash-triple-simple.c +++ b/lib/hash-triple-simple.c @@ -24,7 +24,7 @@ #include #include -#include "hash-pjw.h" +#include "hashcode-string.h" #include "same-inode.h" #define STREQ(a, b) (strcmp (a, b) == 0) diff --git a/lib/hash-pjw.c b/lib/hashcode-string.c similarity index 90% rename from lib/hash-pjw.c rename to lib/hashcode-string.c index fbe8ef6f0c..6943d7b17b 100644 --- a/lib/hash-pjw.c +++ b/lib/hashcode-string.c @@ -1,4 +1,4 @@ -/* hash-pjw.c -- compute a hash value from a NUL-terminated string. +/* hashcode-string.c -- compute a hash value from a NUL-terminated string. Copyright (C) 2001, 2003, 2006, 2009-2025 Free Software Foundation, Inc. @@ -17,7 +17,8 @@ #include -#include "hash-pjw.h" +/* Specification. */ +#include "hashcode-string.h" #include diff --git a/lib/hashcode-string.h b/lib/hashcode-string.h new file mode 100644 index 0000000000..af99f4e74c --- /dev/null +++ b/lib/hashcode-string.h @@ -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 . */ + +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include + +#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 diff --git a/modules/hash-pjw b/modules/hash-pjw index 3bd6ad5c5f..56193fa2d1 100644 --- a/modules/hash-pjw +++ b/modules/hash-pjw @@ -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 diff --git a/modules/hash-tests b/modules/hash-tests index e598573e12..c9593f347d 100644 --- a/modules/hash-tests +++ b/modules/hash-tests @@ -3,7 +3,7 @@ tests/test-hash.c tests/macros.h Depends-on: -hash-pjw +hashcode-string inttostr bool diff --git a/modules/hash-triple-simple b/modules/hash-triple-simple index 53a472f870..a78c019b17 100644 --- a/modules/hash-triple-simple +++ b/modules/hash-triple-simple @@ -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 index 0000000000..a9484514db --- /dev/null +++ b/modules/hashcode-string @@ -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 diff --git a/tests/test-hash.c b/tests/test-hash.c index a2a34506c1..e7735684be 100644 --- a/tests/test-hash.c +++ b/tests/test-hash.c @@ -18,7 +18,7 @@ #include #include "hash.h" -#include "hash-pjw.h" +#include "hashcode-string.h" #include "inttostr.h" #include diff --git a/top/maint.mk b/top/maint.mk index 54c5e82753..a5392fc938 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -728,8 +728,8 @@ sc_prohibit_posixver_without_use: sc_prohibit_same_without_use: @h='same.h' re='\