chiark / gitweb /
cleanup: All the whitespace fixes, all at once.
[mLib] / unihash.c
index e2093b9a9c429fca98ecdb7f6cf94c90503898eb..9f9719bffbd0dbf7243f2627a75f302a4fedc97e 100644 (file)
--- a/unihash.c
+++ b/unihash.c
@@ -1,13 +1,13 @@
 /* -*-c-*-
  *
- * $Id: unihash.c,v 1.2 2003/12/14 14:45:30 mdw Exp $
+ * $Id: unihash.c,v 1.3 2004/04/08 01:36:13 mdw Exp $
  *
  * Simple and efficient universal hashing for hashtables
  *
  * (c) 2003 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of the mLib utilities library.
  *
  * it under the terms of the GNU Library General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
- * 
+ *
  * mLib 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 Library General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Library General Public
  * License along with mLib; if not, write to the Free
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: unihash.c,v $
- * Revision 1.2  2003/12/14 14:45:30  mdw
- * Test universal hashing and fix bugs.
- *
- * Revision 1.1  2003/10/12 14:43:24  mdw
- * Universal hashing.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include <assert.h>
@@ -97,7 +86,7 @@ void unihash_setkey(unihash_info *i, uint32 k)
  *
  * Returns:    Hash of data so far.
  *
- * Use:                Hashes data.  Call this as many times as needed.  
+ * Use:                Hashes data.  Call this as many times as needed.
  */
 
 uint32 unihash_hash(const unihash_info *i, uint32 a,
@@ -108,7 +97,7 @@ uint32 unihash_hash(const unihash_info *i, uint32 a,
   assert(UNIHASH_NBATCH == 4);
 
 #define FULLMULT(u, x)                                                 \
-  (i->s[u][0][U8((x) >>  0)] ^ i->s[u][1][U8((x) >>  8)] ^             \
+  (i->s[u][0][U8((x) >>         0)] ^ i->s[u][1][U8((x) >>  8)] ^              \
    i->s[u][2][U8((x) >> 16)] ^ i->s[u][3][U8((x) >> 24)]);
 
 #define BYTEMULT(u, x) i->s[u][0][x]
@@ -152,7 +141,7 @@ uint32 unihash_hash(const unihash_info *i, uint32 a,
  * Returns:    The hash value computed.
  *
  * Use:                All-in-one hashing function.  No faster than using the
- *             separate calls, but more convenient.
+ *             separate calls, but more convenient.
  */
 
 uint32 unihash(const unihash_info *i, const void *p, size_t sz)
@@ -204,11 +193,11 @@ static int verify(dstr *v)
     if (h != hh) {
       ok = 0;
       fprintf(stderr, "\nunihash failed\n");
-      fprintf(stderr, "  key = %08lx\n", (unsigned long)k);
-      fprintf(stderr, "  data = %s\n", v[1].buf);
-      fprintf(stderr, "  step = %d\n", step[i]);
-      fprintf(stderr, "  expected = %08lx\n", (unsigned long)h);
-      fprintf(stderr, "  computed = %08lx\n", (unsigned long)hh);
+      fprintf(stderr, "         key = %08lx\n", (unsigned long)k);
+      fprintf(stderr, "         data = %s\n", v[1].buf);
+      fprintf(stderr, "         step = %d\n", step[i]);
+      fprintf(stderr, "         expected = %08lx\n", (unsigned long)h);
+      fprintf(stderr, "         computed = %08lx\n", (unsigned long)hh);
     }
   }
   return (ok);