]> Savannah Git Hosting - gnulib.git/commitdiff
Rename module hash-pjw-bare to hashcode-mem.
authorBruno Haible <bruno@clisp.org>
Tue, 29 Apr 2025 22:03:14 +0000 (00:03 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 29 Apr 2025 22:51:21 +0000 (00:51 +0200)
* 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
MODULES.html.sh
lib/hash-pjw-bare.c [deleted file]
lib/hash-pjw-bare.h
lib/hashcode-mem.c [new file with mode: 0644]
lib/hashcode-mem.h [new file with mode: 0644]
modules/hash-pjw-bare
modules/hashcode-mem [new file with mode: 0644]

index 55c570f68bacf7477199fa674cd7155ee65b739e..85c9d767bd7cdc7f1ca6d42ba6d9fdaef3c25421 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-04-29  Bruno Haible  <bruno@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  <bruno@clisp.org>
 
        hash: Remove deprecated function 'hash_delete'.
index 1deb6e55a52417571513c83b47df9cf4d4e77a6f..9aab40c27f4b56c5ed22f4284fbe03710d0434a3 100755 (executable)
@@ -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.c b/lib/hash-pjw-bare.c
deleted file mode 100644 (file)
index a6a66cb..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* hash-pjw-bare.c -- compute a hash value from a provided buffer.
-
-   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/>.  */
-
-#include <config.h>
-
-#include "hash-pjw-bare.h"
-
-#include <limits.h>
-
-#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
-
-/* Return a hash of the N bytes of X using the method described by
-   Bruno Haible in https://www.haible.de/bruno/hashfunc.html.
-   Note that while many hash functions reduce their result via modulo
-   to a 0..table_size-1 range, this function does not do that.  */
-
-size_t
-hash_pjw_bare (const void *x, size_t n)
-{
-  const unsigned char *s = x;
-  size_t h = 0;
-  unsigned i;
-
-  for (i = 0; i < n; i++)
-    h = s[i] + ((h << 9) | (h >> (SIZE_BITS - 9)));
-
-  return h;
-}
index 7ea1a8886aaa723d22aa8f3c23735148db9ebba6..70d36db1cea859865792b518afaddcd09bfdd2c7 100644 (file)
@@ -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
    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/hashcode-mem.c b/lib/hashcode-mem.c
new file mode 100644 (file)
index 0000000..cf086b0
--- /dev/null
@@ -0,0 +1,43 @@
+/* hashcode-mem.c -- compute a hash value from a provided buffer.
+
+   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/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "hashcode-mem.h"
+
+#include <limits.h>
+
+#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
+
+/* Return a hash of the N bytes of X using the method described by
+   Bruno Haible in https://www.haible.de/bruno/hashfunc.html.
+   Note that while many hash functions reduce their result via modulo
+   to a 0..table_size-1 range, this function does not do that.  */
+
+size_t
+hash_pjw_bare (const void *x, size_t n)
+{
+  const unsigned char *s = x;
+  size_t h = 0;
+  unsigned i;
+
+  for (i = 0; i < n; i++)
+    h = s[i] + ((h << 9) | (h >> (SIZE_BITS - 9)));
+
+  return h;
+}
diff --git a/lib/hashcode-mem.h b/lib/hashcode-mem.h
new file mode 100644 (file)
index 0000000..4f5adef
--- /dev/null
@@ -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
index 4dc94e3a3224329e28ffbf4ffe32a5fa2199f51d..05786a3763d2af877fdc465df111057314af0c7f 100644 (file)
@@ -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 (file)
index 0000000..1c6431a
--- /dev/null
@@ -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