/* hash - hashing table processing.
- Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+ Foundation, Inc.
+
Written by Jim Meyering, 1992.
This program is free software; you can redistribute it and/or modify
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
-#if HAVE_STDBOOL_H
-# include <stdbool.h>
-#else
-typedef enum {false = 0, true = 1} bool;
-#endif
+
+#include <limits.h>
+#include <stdbool.h>
#include <stdio.h>
#ifndef HAVE_DECL_FREE
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
if (bucket->data == NULL)
return NULL;
for (bucket = table->bucket; ; bucket++)
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
else if (bucket->data)
return bucket->data;
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
/* Find next entry in the same bucket. */
unsigned
hash_string (const char *string, unsigned n_buckets)
{
-# ifndef CHAR_BIT
-# define CHAR_BIT 8
-# endif
# define ROTATE_LEFT(Value, Shift) \
((Value) << (Shift) | (Value) >> ((sizeof (unsigned) * CHAR_BIT) - (Shift)))
# define HASH_ONE_CHAR(Value, Byte) \
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
*bucket_head = bucket;
= (new_table->bucket
+ new_table->hasher (data, new_table->n_buckets));
- if (new_table->bucket_limit <= new_bucket)
+ if (! (new_bucket < new_table->bucket_limit))
abort ();
next = cursor->next;