/* Hash tables.
- Copyright (C) 2000-2005 Free Software Foundation, Inc.
+ Copyright (C) 2000-2006 Free Software Foundation, Inc.
This file is part of GNU Wget.
GNU Wget is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or (at
+the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.
GNU Wget is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with Wget; if not, write to the Free Software Foundation, Inc.,
-51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+along with Wget. If not, see <http://www.gnu.org/licenses/>.
In addition, as a special exception, the Free Software Foundation
gives permission to link the code of its release of Wget with the
# define xnew_array(type, x) xmalloc (sizeof (type) * (x))
# define xmalloc malloc
# define xfree free
-# define countof(x) (sizeof (x) / sizeof ((x)[0]))
-# define TOLOWER(x) ('A' <= (x) && (x) <= 'Z' ? (x) - 32 : (x))
+# ifndef countof
+# define countof(x) (sizeof (x) / sizeof ((x)[0]))
+# endif
+# include <ctype.h>
+# define TOLOWER(x) tolower ((unsigned char) (x))
+# if __STDC_VERSION__ >= 199901L
+# include <stdint.h> /* for uintptr_t */
+# else
+ typedef unsigned long uintptr_t;
+# endif
#endif
#include "hash.h"
-1. This is acceptable because it still allows the use of
nonnegative integer keys. */
-#define INVALID_PTR ((void *) ~0UL)
+#define INVALID_PTR ((void *) ~(uintptr_t) 0)
#ifndef UCHAR_MAX
# define UCHAR_MAX 0xff
#endif
unsigned long
hash_pointer (const void *ptr)
{
- unsigned long key = (unsigned long) ptr;
+ uintptr_t key = (uintptr_t) ptr;
key += (key << 12);
key ^= (key >> 22);
key += (key << 4);
key ^= (key >> 2);
key += (key << 7);
key ^= (key >> 12);
-#if SIZEOF_LONG > 4
+#if SIZEOF_VOID_P > 4
key += (key << 44);
key ^= (key >> 54);
key += (key << 36);
key += (key << 39);
key ^= (key >> 44);
#endif
- return key;
+ return (unsigned long) key;
}
static int