[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes to m4/m4/hash.c,v
From: |
Eric Blake |
Subject: |
Changes to m4/m4/hash.c,v |
Date: |
Fri, 28 Jul 2006 00:22:10 +0000 |
CVSROOT: /sources/m4
Module name: m4
Changes by: Eric Blake <ericb> 06/07/28 00:22:09
Index: m4/hash.c
===================================================================
RCS file: /sources/m4/m4/m4/hash.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- m4/hash.c 1 May 2005 11:10:05 -0000 1.17
+++ m4/hash.c 28 Jul 2006 00:22:09 -0000 1.18
@@ -1,5 +1,5 @@
/* GNU m4 -- A simple macro processor
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2006 Free Software Foundation, Inc.
Written by Gary V. Vaughan <address@hidden>
This program is free software; you can redistribute it and/or modify
@@ -544,21 +544,17 @@
/* Using a string as the hash key is common enough that we provide
implementations here for use in client hash table routines. */
-/* Return a hash value for a string, from GNU Emacs. */
+/* Return a hash value for a string, consistent with gnulib's hash
+ module. */
size_t
m4_hash_string_hash (const void *key)
{
- int val = 0;
+ size_t val = 0;
const char *ptr = (const char *) key;
char ch;
while ((ch = *ptr++) != '\0')
- {
- if (ch >= 0140)
- ch -= 40;
- val = ((val << 3) + (val >> 28) + ch);
- };
- val = (val < 0) ? -val : val;
+ val = (val << 7) + (val >> (sizeof (val) * CHAR_BIT - 7)) + ch;
return val;
}
- Changes to m4/m4/hash.c,v,
Eric Blake <=