The naming of *hash* modules is suboptimal: On one hand, we have the hash tables and containers: hash, hash-map, hash-set, linkedhash-map, linkedhash-set, avltreehash-list, linkedhash-list, rbtreehash-list, on the other hand the auxiliary modules that only provide hash code functions: hash-pjw, hash-pjw-bare, hash-triple, hash-triple-simple
I want to add a new module that defines a hash code for strings, for hash-map and hash-set. The naming is becoming a problem. I think it's best to rename the modules that provide hash code functions: hash-pjw -> hashcode-string hash-pjw-bare -> hashcode-mem hash-triple -> hashcode-file-inode hash-triple-simple -> hashcode-named-file And the new module will be called -> hashkey-string (similar to hashcode-string). With this, I'm also renaming the .h files accordingly. I'm NOT renaming the functions. For modules that are used outside Gnulib, to ease migration, I'm adding temporary module aliases and .h file aliases that trigger a deprecation message. 2025-04-29 Bruno Haible <br...@clisp.org> Rename include file hash-triple.h to hashcode-file.h. * lib/hashcode-file.h: Renamed from lib/hash-triple.h. * lib/hash-triple.h: New file. * lib/hashcode-named-file.c: Update. * lib/hashcode-file-inode.c: Update. * lib/canonicalize.c: Update. * lib/file-set.c: Update. * modules/hashcode-named-file (Files, Include): Update. * modules/hashcode-file-inode (Include): Update. * modules/hash-triple (Include): Update. Rename module hash-triple to hashcode-file-inode. * lib/hashcode-file-inode.c: Renamed from lib/hash-triple.c. * modules/hashcode-file-inode: Renamed from modules/hash-triple. * modules/hash-triple: New file. * lib/hash-triple.h: Update. * MODULES.html.sh: Update. Rename module hash-triple-simple to hashcode-named-file. * lib/hashcode-named-file.c: Renamed from lib/hash-triple-simple.c. * modules/hashcode-named-file: Renamed from modules/hash-triple-simple. * lib/hash-triple.h: Update. * modules/canonicalize (Depends-on): Update. * modules/file-set (Depends-on): Update. * modules/hash-triple (Depends-on): Update. * NEWS: Mention the change. 2025-04-29 Bruno Haible <br...@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 <br...@clisp.org> Rename module hash-pjw-bare to hashcode-mem. * lib/hashcode-mem.h: Renamed from lib/hash-pjw-bare.h. * lib/hashcode-mem.c: Renamed from lib/hash-pjw-bare.c. * lib/hash-pjw-bare.h: New file. * modules/hashcode-mem: Renamed from modules/hash-pjw-bare. * modules/hash-pjw-bare: New file. * MODULES.html.sh: Update.
>From cdb41cdfe4aff298197210df907c829b8048b51a Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 30 Apr 2025 00:03:14 +0200 Subject: [PATCH 1/5] Rename module hash-pjw-bare to hashcode-mem. * lib/hashcode-mem.h: Renamed from lib/hash-pjw-bare.h. * lib/hashcode-mem.c: Renamed from lib/hash-pjw-bare.c. * lib/hash-pjw-bare.h: New file. * modules/hashcode-mem: Renamed from modules/hash-pjw-bare. * modules/hash-pjw-bare: New file. * MODULES.html.sh: Update. --- ChangeLog | 10 +++++++ MODULES.html.sh | 2 +- lib/hash-pjw-bare.h | 26 +++-------------- lib/{hash-pjw-bare.c => hashcode-mem.c} | 5 ++-- lib/hashcode-mem.h | 39 +++++++++++++++++++++++++ modules/hash-pjw-bare | 13 +++++---- modules/hashcode-mem | 23 +++++++++++++++ 7 files changed, 88 insertions(+), 30 deletions(-) rename lib/{hash-pjw-bare.c => hashcode-mem.c} (91%) create mode 100644 lib/hashcode-mem.h create mode 100644 modules/hashcode-mem diff --git a/ChangeLog b/ChangeLog index 55c570f68b..85c9d767bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2025-04-29 Bruno Haible <br...@clisp.org> + + Rename module hash-pjw-bare to hashcode-mem. + * lib/hashcode-mem.h: Renamed from lib/hash-pjw-bare.h. + * lib/hashcode-mem.c: Renamed from lib/hash-pjw-bare.c. + * lib/hash-pjw-bare.h: New file. + * modules/hashcode-mem: Renamed from modules/hash-pjw-bare. + * modules/hash-pjw-bare: New file. + * MODULES.html.sh: Update. + 2025-04-29 Bruno Haible <br...@clisp.org> hash: Remove deprecated function 'hash_delete'. diff --git a/MODULES.html.sh b/MODULES.html.sh index 1deb6e55a5..9aab40c27f 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -2096,7 +2096,7 @@ func_all_modules () func_module obstack-printf func_module obstack-printf-posix func_module hash-pjw - func_module hash-pjw-bare + func_module hashcode-mem func_module hash func_module hamt func_module readline diff --git a/lib/hash-pjw-bare.h b/lib/hash-pjw-bare.h index 7ea1a8886a..70d36db1ce 100644 --- a/lib/hash-pjw-bare.h +++ b/lib/hash-pjw-bare.h @@ -1,5 +1,5 @@ /* hash-pjw-bare.h -- declaration for a simple hash function - Copyright (C) 2012-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,26 +14,8 @@ 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 buffer starting at X and of size N, - and return the hash code. Note that unlike hash_pjw(), it does not - return it modulo a table size. - The result is platform dependent: it depends on the size of the 'size_t' - type. */ -extern size_t hash_pjw_bare (const void *x, size_t n) _GL_ATTRIBUTE_PURE; - +#include "hashcode-mem.h" -#ifdef __cplusplus -} +#if __GNUC__ || (__clang_major__ >= 4) +# warning "The include file hash-pjw-bare.h is deprecated. Use hashcode-mem.h instead." #endif diff --git a/lib/hash-pjw-bare.c b/lib/hashcode-mem.c similarity index 91% rename from lib/hash-pjw-bare.c rename to lib/hashcode-mem.c index a6a66cb93b..cf086b0b16 100644 --- a/lib/hash-pjw-bare.c +++ b/lib/hashcode-mem.c @@ -1,4 +1,4 @@ -/* hash-pjw-bare.c -- compute a hash value from a provided buffer. +/* hashcode-mem.c -- compute a hash value from a provided buffer. Copyright (C) 2012-2025 Free Software Foundation, Inc. @@ -17,7 +17,8 @@ #include <config.h> -#include "hash-pjw-bare.h" +/* Specification. */ +#include "hashcode-mem.h" #include <limits.h> diff --git a/lib/hashcode-mem.h b/lib/hashcode-mem.h new file mode 100644 index 0000000000..4f5adefb52 --- /dev/null +++ b/lib/hashcode-mem.h @@ -0,0 +1,39 @@ +/* hashcode-mem.h -- declaration for a simple hash function + Copyright (C) 2012-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 buffer starting at X and of size N, + and return the hash code. Note that unlike hash_pjw(), it does not + return it modulo a table size. + The result is platform dependent: it depends on the size of the 'size_t' + type. */ +extern size_t hash_pjw_bare (const void *x, size_t n) _GL_ATTRIBUTE_PURE; + + +#ifdef __cplusplus +} +#endif diff --git a/modules/hash-pjw-bare b/modules/hash-pjw-bare index 4dc94e3a32..05786a3763 100644 --- a/modules/hash-pjw-bare +++ b/modules/hash-pjw-bare @@ -1,22 +1,25 @@ Description: Compute a hash value for a buffer of known size. +Status: +deprecated + +Notice: +This module is deprecated. Use the module 'hashcode-mem' instead. + Files: -lib/hash-pjw-bare.h -lib/hash-pjw-bare.c Depends-on: +hashcode-mem configure.ac: Makefile.am: -lib_SOURCES += hash-pjw-bare.h hash-pjw-bare.c Include: -"hash-pjw-bare.h" +"hashcode-mem.h" License: LGPLv2+ Maintainer: -Jim Meyering diff --git a/modules/hashcode-mem b/modules/hashcode-mem new file mode 100644 index 0000000000..1c6431a531 --- /dev/null +++ b/modules/hashcode-mem @@ -0,0 +1,23 @@ +Description: +Compute a hash value for a buffer of known size. + +Files: +lib/hashcode-mem.h +lib/hashcode-mem.c +lib/hash-pjw-bare.h + +Depends-on: + +configure.ac: + +Makefile.am: +lib_SOURCES += hashcode-mem.h hashcode-mem.c + +Include: +"hashcode-mem.h" + +License: +LGPLv2+ + +Maintainer: +Jim Meyering -- 2.43.0
>From 261415b09686bc5da188d446f8f16f92dd9372bb Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 30 Apr 2025 00:15:40 +0200 Subject: [PATCH 2/5] 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 <br...@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 <br...@clisp.org> 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 <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 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 <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/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 <config.h> -#include "hash-pjw.h" +/* Specification. */ +#include "hashcode-string.h" #include <limits.h> 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 <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 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 <config.h> #include "hash.h" -#include "hash-pjw.h" +#include "hashcode-string.h" #include "inttostr.h" #include <stdio.h> 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='\<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) -- 2.43.0
>From e412f9ace44fa4167c015c40aec3d3b9c59a6b65 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 30 Apr 2025 00:24:55 +0200 Subject: [PATCH 3/5] Rename module hash-triple-simple to hashcode-named-file. * lib/hashcode-named-file.c: Renamed from lib/hash-triple-simple.c. * modules/hashcode-named-file: Renamed from modules/hash-triple-simple. * lib/hash-triple.h: Update. * modules/canonicalize (Depends-on): Update. * modules/file-set (Depends-on): Update. * modules/hash-triple (Depends-on): Update. * NEWS: Mention the change. --- ChangeLog | 11 +++++++++++ NEWS | 2 ++ lib/hash-triple.h | 2 +- lib/{hash-triple-simple.c => hashcode-named-file.c} | 0 modules/canonicalize | 2 +- modules/file-set | 2 +- modules/hash-triple | 2 +- modules/{hash-triple-simple => hashcode-named-file} | 4 ++-- 8 files changed, 19 insertions(+), 6 deletions(-) rename lib/{hash-triple-simple.c => hashcode-named-file.c} (100%) rename modules/{hash-triple-simple => hashcode-named-file} (79%) diff --git a/ChangeLog b/ChangeLog index 6fee9a0a5c..a8112663f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2025-04-29 Bruno Haible <br...@clisp.org> + + Rename module hash-triple-simple to hashcode-named-file. + * lib/hashcode-named-file.c: Renamed from lib/hash-triple-simple.c. + * modules/hashcode-named-file: Renamed from modules/hash-triple-simple. + * lib/hash-triple.h: Update. + * modules/canonicalize (Depends-on): Update. + * modules/file-set (Depends-on): Update. + * modules/hash-triple (Depends-on): Update. + * NEWS: Mention the change. + 2025-04-29 Bruno Haible <br...@clisp.org> Rename module hash-pjw to hashcode-string. diff --git a/NEWS b/NEWS index d009455429..57249ffc02 100644 --- a/NEWS +++ b/NEWS @@ -74,6 +74,8 @@ User visible incompatible changes Date Modules Changes +2025-04-29 hash-triple-simple This module is renamed to hashcode-named-file. + 2025-01-02 string-desc The function prefix is changed from string_desc_ xstring-desc to sd_, and from xstring_desc_ to xsd_. string-desc-quotearg diff --git a/lib/hash-triple.h b/lib/hash-triple.h index 63819ae3e9..1e59be64ba 100644 --- a/lib/hash-triple.h +++ b/lib/hash-triple.h @@ -40,7 +40,7 @@ struct F_triple dev_t st_dev; }; -/* Defined in module 'hash-triple-simple'. */ +/* Defined in module 'hashcode-named-file'. */ extern size_t triple_hash (void const *x, size_t table_size) _GL_ATTRIBUTE_PURE; extern bool triple_compare_ino_str (void const *x, void const *y) diff --git a/lib/hash-triple-simple.c b/lib/hashcode-named-file.c similarity index 100% rename from lib/hash-triple-simple.c rename to lib/hashcode-named-file.c diff --git a/modules/canonicalize b/modules/canonicalize index 300705c130..70861a6164 100644 --- a/modules/canonicalize +++ b/modules/canonicalize @@ -16,7 +16,7 @@ fcntl-h file-set filename getcwd -hash-triple-simple +hashcode-named-file idx intprops memmove diff --git a/modules/file-set b/modules/file-set index 23efdfbb9d..d3b3a107f4 100644 --- a/modules/file-set +++ b/modules/file-set @@ -7,7 +7,7 @@ lib/file-set.h Depends-on: hash -hash-triple-simple +hashcode-named-file bool xalloc xalloc-die diff --git a/modules/hash-triple b/modules/hash-triple index b726192a8d..f908f10949 100644 --- a/modules/hash-triple +++ b/modules/hash-triple @@ -5,7 +5,7 @@ Files: lib/hash-triple.c Depends-on: -hash-triple-simple +hashcode-named-file same same-inode diff --git a/modules/hash-triple-simple b/modules/hashcode-named-file similarity index 79% rename from modules/hash-triple-simple rename to modules/hashcode-named-file index a78c019b17..621560430d 100644 --- a/modules/hash-triple-simple +++ b/modules/hashcode-named-file @@ -2,7 +2,7 @@ Description: Hash functions for file-related triples: name, device, inode. Files: -lib/hash-triple-simple.c +lib/hashcode-named-file.c lib/hash-triple.h Depends-on: @@ -13,7 +13,7 @@ bool configure.ac: Makefile.am: -lib_SOURCES += hash-triple-simple.c +lib_SOURCES += hashcode-named-file.c Include: "hash-triple.h" -- 2.43.0
>From 53cea75d3d378c7a71fa16ff01def1edfdf9cb55 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 30 Apr 2025 00:37:08 +0200 Subject: [PATCH 4/5] Rename module hash-triple to hashcode-file-inode. * lib/hashcode-file-inode.c: Renamed from lib/hash-triple.c. * modules/hashcode-file-inode: Renamed from modules/hash-triple. * modules/hash-triple: New file. * lib/hash-triple.h: Update. * MODULES.html.sh: Update. --- ChangeLog | 7 ++++++ MODULES.html.sh | 2 +- lib/hash-triple.h | 2 +- lib/{hash-triple.c => hashcode-file-inode.c} | 0 modules/hash-triple | 13 ++++++----- modules/hashcode-file-inode | 24 ++++++++++++++++++++ 6 files changed, 40 insertions(+), 8 deletions(-) rename lib/{hash-triple.c => hashcode-file-inode.c} (100%) create mode 100644 modules/hashcode-file-inode diff --git a/ChangeLog b/ChangeLog index a8112663f0..44e143f459 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2025-04-29 Bruno Haible <br...@clisp.org> + Rename module hash-triple to hashcode-file-inode. + * lib/hashcode-file-inode.c: Renamed from lib/hash-triple.c. + * modules/hashcode-file-inode: Renamed from modules/hash-triple. + * modules/hash-triple: New file. + * lib/hash-triple.h: Update. + * MODULES.html.sh: Update. + Rename module hash-triple-simple to hashcode-named-file. * lib/hashcode-named-file.c: Renamed from lib/hash-triple-simple.c. * modules/hashcode-named-file: Renamed from modules/hash-triple-simple. diff --git a/MODULES.html.sh b/MODULES.html.sh index c80ea9d7a2..baee4f95fd 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -2870,7 +2870,7 @@ func_all_modules () func_module cycle-check func_module dev-ino func_module file-set - func_module hash-triple + func_module hashcode-file-inode func_module i-ring func_module same-inode func_end_table diff --git a/lib/hash-triple.h b/lib/hash-triple.h index 1e59be64ba..26ef7a1f05 100644 --- a/lib/hash-triple.h +++ b/lib/hash-triple.h @@ -47,7 +47,7 @@ extern bool triple_compare_ino_str (void const *x, void const *y) _GL_ATTRIBUTE_PURE; extern void triple_free (void *x); -/* Defined in module 'hash-triple'. */ +/* Defined in module 'hashcode-file-inode'. */ extern size_t triple_hash_no_name (void const *x, size_t table_size) _GL_ATTRIBUTE_PURE; extern bool triple_compare (void const *x, void const *y); diff --git a/lib/hash-triple.c b/lib/hashcode-file-inode.c similarity index 100% rename from lib/hash-triple.c rename to lib/hashcode-file-inode.c diff --git a/modules/hash-triple b/modules/hash-triple index f908f10949..5c446cbe34 100644 --- a/modules/hash-triple +++ b/modules/hash-triple @@ -1,18 +1,20 @@ Description: Hash functions for file-related triples: name, device, inode. +Status: +deprecated + +Notice: +This module is deprecated. Use the module 'hashcode-file-inode' instead. + Files: -lib/hash-triple.c Depends-on: -hashcode-named-file -same -same-inode +hashcode-file-inode configure.ac: Makefile.am: -lib_SOURCES += hash-triple.c Include: "hash-triple.h" @@ -21,4 +23,3 @@ License: GPL Maintainer: -Jim Meyering diff --git a/modules/hashcode-file-inode b/modules/hashcode-file-inode new file mode 100644 index 0000000000..87d2d41486 --- /dev/null +++ b/modules/hashcode-file-inode @@ -0,0 +1,24 @@ +Description: +Hash functions for file-related triples: name, device, inode. + +Files: +lib/hashcode-file-inode.c + +Depends-on: +hashcode-named-file +same +same-inode + +configure.ac: + +Makefile.am: +lib_SOURCES += hashcode-file-inode.c + +Include: +"hash-triple.h" + +License: +GPL + +Maintainer: +Jim Meyering -- 2.43.0
>From 3748256978cd900c0404c09ab22c3b5a2f35e031 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 30 Apr 2025 00:46:21 +0200 Subject: [PATCH 5/5] Rename include file hash-triple.h to hashcode-file.h. * lib/hashcode-file.h: Renamed from lib/hash-triple.h. * lib/hash-triple.h: New file. * lib/hashcode-named-file.c: Update. * lib/hashcode-file-inode.c: Update. * lib/canonicalize.c: Update. * lib/file-set.c: Update. * modules/hashcode-named-file (Files, Include): Update. * modules/hashcode-file-inode (Include): Update. * modules/hash-triple (Include): Update. --- ChangeLog | 11 +++++++ lib/canonicalize.c | 2 +- lib/file-set.c | 2 +- lib/hash-triple.h | 63 +++++++------------------------------ lib/hashcode-file-inode.c | 2 +- lib/hashcode-file.h | 60 +++++++++++++++++++++++++++++++++++ lib/hashcode-named-file.c | 2 +- modules/hash-triple | 2 +- modules/hashcode-file-inode | 2 +- modules/hashcode-named-file | 3 +- 10 files changed, 91 insertions(+), 58 deletions(-) create mode 100644 lib/hashcode-file.h diff --git a/ChangeLog b/ChangeLog index 44e143f459..6a39c93bda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2025-04-29 Bruno Haible <br...@clisp.org> + Rename include file hash-triple.h to hashcode-file.h. + * lib/hashcode-file.h: Renamed from lib/hash-triple.h. + * lib/hash-triple.h: New file. + * lib/hashcode-named-file.c: Update. + * lib/hashcode-file-inode.c: Update. + * lib/canonicalize.c: Update. + * lib/file-set.c: Update. + * modules/hashcode-named-file (Files, Include): Update. + * modules/hashcode-file-inode (Include): Update. + * modules/hash-triple (Include): Update. + Rename module hash-triple to hashcode-file-inode. * lib/hashcode-file-inode.c: Renamed from lib/hash-triple.c. * modules/hashcode-file-inode: Renamed from modules/hash-triple. diff --git a/lib/canonicalize.c b/lib/canonicalize.c index 88472cc927..10d85efb1a 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -31,7 +31,7 @@ #include "attribute.h" #include "file-set.h" -#include "hash-triple.h" +#include "hashcode-file.h" #include "xalloc.h" /* Suppress bogus GCC -Wmaybe-uninitialized warnings. */ diff --git a/lib/file-set.c b/lib/file-set.c index 0d9e9206f7..6d4f02554a 100644 --- a/lib/file-set.c +++ b/lib/file-set.c @@ -19,7 +19,7 @@ #include <config.h> #include "file-set.h" -#include "hash-triple.h" +#include "hashcode-file.h" #include "xalloc.h" /* Record file, FILE, and dev/ino from *STATS, in the hash table, HT. diff --git a/lib/hash-triple.h b/lib/hash-triple.h index 26ef7a1f05..708835f22f 100644 --- a/lib/hash-triple.h +++ b/lib/hash-triple.h @@ -1,60 +1,21 @@ -/* Hash functions for file-related (name, device, inode) triples. - Copyright (C) 2007-2025 Free Software Foundation, Inc. +/* hash-triple.h -- declaration for a simple hash function + Copyright (C) 2025 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 - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + 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 program is distributed in the hope that it will be useful, + 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 General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + 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/>. */ -/* Written by Jim Meyering, 2007. */ - -#ifndef HASH_TRIPLE_H -#define HASH_TRIPLE_H - -/* This file uses _GL_ATTRIBUTE_PURE. */ -#if !_GL_CONFIG_H_INCLUDED - #error "Please include config.h first." -#endif - -#include <sys/types.h> -#include <sys/stat.h> - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Describe a just-created or just-renamed destination file. */ -struct F_triple -{ - char *name; - ino_t st_ino; - dev_t st_dev; -}; - -/* Defined in module 'hashcode-named-file'. */ - -extern size_t triple_hash (void const *x, size_t table_size) _GL_ATTRIBUTE_PURE; -extern bool triple_compare_ino_str (void const *x, void const *y) - _GL_ATTRIBUTE_PURE; -extern void triple_free (void *x); - -/* Defined in module 'hashcode-file-inode'. */ -extern size_t triple_hash_no_name (void const *x, size_t table_size) - _GL_ATTRIBUTE_PURE; -extern bool triple_compare (void const *x, void const *y); - - -#ifdef __cplusplus -} -#endif +#include "hashcode-string.h" +#if __GNUC__ || (__clang_major__ >= 4) +# warning "The include file hash-triple.h is deprecated. Use hashcode-file.h instead." #endif diff --git a/lib/hashcode-file-inode.c b/lib/hashcode-file-inode.c index 5d47e58fb4..f635804190 100644 --- a/lib/hashcode-file-inode.c +++ b/lib/hashcode-file-inode.c @@ -19,7 +19,7 @@ #include <config.h> /* Specification. */ -#include "hash-triple.h" +#include "hashcode-file.h" #include "same.h" #include "same-inode.h" diff --git a/lib/hashcode-file.h b/lib/hashcode-file.h new file mode 100644 index 0000000000..004359bce6 --- /dev/null +++ b/lib/hashcode-file.h @@ -0,0 +1,60 @@ +/* Hash functions for file-related (name, device, inode) triples. + Copyright (C) 2007-2025 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Jim Meyering, 2007. */ + +#ifndef HASHCODE_FILE_H +#define HASHCODE_FILE_H + +/* This file uses _GL_ATTRIBUTE_PURE. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + +#include <sys/types.h> +#include <sys/stat.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Describe a just-created or just-renamed destination file. */ +struct F_triple +{ + char *name; + ino_t st_ino; + dev_t st_dev; +}; + +/* Defined in module 'hashcode-named-file'. */ + +extern size_t triple_hash (void const *x, size_t table_size) _GL_ATTRIBUTE_PURE; +extern bool triple_compare_ino_str (void const *x, void const *y) + _GL_ATTRIBUTE_PURE; +extern void triple_free (void *x); + +/* Defined in module 'hashcode-file-inode'. */ +extern size_t triple_hash_no_name (void const *x, size_t table_size) + _GL_ATTRIBUTE_PURE; +extern bool triple_compare (void const *x, void const *y); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/hashcode-named-file.c b/lib/hashcode-named-file.c index 4bb71375f4..a488147edd 100644 --- a/lib/hashcode-named-file.c +++ b/lib/hashcode-named-file.c @@ -19,7 +19,7 @@ #include <config.h> /* Specification. */ -#include "hash-triple.h" +#include "hashcode-file.h" #include <stdlib.h> #include <string.h> diff --git a/modules/hash-triple b/modules/hash-triple index 5c446cbe34..1f1cfc37a6 100644 --- a/modules/hash-triple +++ b/modules/hash-triple @@ -17,7 +17,7 @@ configure.ac: Makefile.am: Include: -"hash-triple.h" +"hashcode-file.h" License: GPL diff --git a/modules/hashcode-file-inode b/modules/hashcode-file-inode index 87d2d41486..2e2b0ad51a 100644 --- a/modules/hashcode-file-inode +++ b/modules/hashcode-file-inode @@ -15,7 +15,7 @@ Makefile.am: lib_SOURCES += hashcode-file-inode.c Include: -"hash-triple.h" +"hashcode-file.h" License: GPL diff --git a/modules/hashcode-named-file b/modules/hashcode-named-file index 621560430d..bdc68502f8 100644 --- a/modules/hashcode-named-file +++ b/modules/hashcode-named-file @@ -3,6 +3,7 @@ Hash functions for file-related triples: name, device, inode. Files: lib/hashcode-named-file.c +lib/hashcode-file.h lib/hash-triple.h Depends-on: @@ -16,7 +17,7 @@ Makefile.am: lib_SOURCES += hashcode-named-file.c Include: -"hash-triple.h" +"hashcode-file.h" License: GPL -- 2.43.0