28 lines
611 B
Diff
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;
|
|
+}
|