MSYS2-packages/coreutils/coreutils-8.32-lib-hash-pjw.c.patch
مهدي شينون (Mehdi Chinoune) ddf66eac75 coreutils: update to 9.4
patches were copied from CygWin.
2023-09-20 07:21:31 +01:00

28 lines
611 B
Diff

--- origsrc/lib/hash-pjw.c 2016-07-15 14:47:39.000000000 -0500
+++ src/lib/hash-pjw.c 2017-02-03 13:32:48.725613200 -0600
@@ -19,6 +19,7 @@
#include "hash-pjw.h"
+#include <ctype.h>
#include <limits.h>
#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
@@ -38,3 +39,16 @@ hash_pjw (const void *x, size_t tablesiz
return h % tablesize;
}
+
+/* Likewise, but case-insensitive. */
+size_t
+hash_pjw_case (const void *x, size_t tablesize)
+{
+ const unsigned char *s;
+ size_t h = 0;
+
+ for (s = x; *s; s++)
+ h = tolower (*s) + ((h << 9) | (h >> (SIZE_BITS - 9)));
+
+ return h % tablesize;
+}