* 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 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.
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
+++ /dev/null
-/* 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;
-}
/* 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
#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)
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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
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
tests/macros.h
Depends-on:
-hash-pjw
+hashcode-string
inttostr
bool
lib/hash-triple.h
Depends-on:
-hash-pjw
+hashcode-string
same-inode
bool
--- /dev/null
+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
#include <config.h>
#include "hash.h"
-#include "hash-pjw.h"
+#include "hashcode-string.h"
#include "inttostr.h"
#include <stdio.h>
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)