diff src/symbols.c @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 859a2309aef8
children 131b0175ea99
line wrap: on
line diff
--- a/src/symbols.c	Mon Aug 13 08:50:31 2007 +0200
+++ b/src/symbols.c	Mon Aug 13 08:51:03 2007 +0200
@@ -328,6 +328,7 @@
   return (make_int (hash));
 }
 
+#if 0 /* Emacs 19.34 */
 int
 hash_string (CONST Bufbyte *ptr, Bytecount len)
 {
@@ -344,6 +345,26 @@
     }
   return hash & 07777777777;
 }
+#endif
+
+/* derived from hashpjw, Dragon Book P436. */
+int
+hash_string (CONST Bufbyte *ptr, Bytecount len)
+{
+  CONST Bufbyte *p = ptr;
+  int hash = 0, g;
+  Bytecount count = len;
+
+  while (count-- > 0)
+    {
+      hash = (hash << 4) + *p++;
+      if (g = (hash & 0xf0000000)) {
+	hash = hash ^ (g >> 24);
+	hash = hash ^ g;
+      }
+    }
+  return hash & 07777777777;
+}
 
 void
 map_obarray (Lisp_Object obarray,