mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-10 03:10:09 +00:00
Roland McGrath <roland@redhat.com>
* locale/hashval.h (compute_hashval): Use prototype defn. (hashval_t): New macro, defined to unsigned long int if not already defined. (compute_hashval): Return hashval_t instead of unsigned long int. * locale/loadarchive.c (hashval_t): New macro. * locale/programs/locarchive.c: Include hashval.h directly instead of simple-hash.h. (compute_hashval, hashval_t): Define these macros first. (insert_name): Use archive_hashval instead of compute_hashval. (add_locale, delete_locales_from_archive): Likewise. 2002-08-28 Jakub Jelinek <jakub@redhat.com>
This commit is contained in:
parent
75261665f1
commit
a3f9038c87
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
2002-08-28 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
Roland McGrath <roland@redhat.com>
|
||||||
|
|
||||||
|
* locale/hashval.h (compute_hashval): Use prototype defn.
|
||||||
|
(hashval_t): New macro, defined to unsigned long int
|
||||||
|
if not already defined.
|
||||||
|
(compute_hashval): Return hashval_t instead of unsigned long int.
|
||||||
|
* locale/loadarchive.c (hashval_t): New macro.
|
||||||
|
* locale/programs/locarchive.c: Include hashval.h directly instead
|
||||||
|
of simple-hash.h.
|
||||||
|
(compute_hashval, hashval_t): Define these macros first.
|
||||||
|
(insert_name): Use archive_hashval instead of compute_hashval.
|
||||||
|
(add_locale, delete_locales_from_archive): Likewise.
|
||||||
|
|
||||||
2002-08-28 Jakub Jelinek <jakub@redhat.com>
|
2002-08-28 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
* locale/programs/locarchive.c (insert_name): Suppress warnings about
|
* locale/programs/locarchive.c (insert_name): Suppress warnings about
|
||||||
|
@ -18,20 +18,16 @@
|
|||||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
02111-1307 USA. */
|
02111-1307 USA. */
|
||||||
|
|
||||||
#ifndef LONGBITS
|
#ifndef hashval_t
|
||||||
# include <limits.h>
|
# define hashval_t unsigned long int
|
||||||
# define LONGBITS (sizeof (long int) * CHAR_BIT)
|
|
||||||
#endif
|
#endif
|
||||||
|
#include <limits.h> /* For CHAR_BIT. */
|
||||||
|
|
||||||
unsigned long int compute_hashval (const void *key, size_t keylen);
|
hashval_t
|
||||||
|
compute_hashval (const void *key, size_t keylen)
|
||||||
unsigned long int
|
|
||||||
compute_hashval (key, keylen)
|
|
||||||
const void *key;
|
|
||||||
size_t keylen;
|
|
||||||
{
|
{
|
||||||
size_t cnt;
|
size_t cnt;
|
||||||
unsigned long int hval;
|
hashval_t hval;
|
||||||
|
|
||||||
/* Compute the hash value for the given string. The algorithm
|
/* Compute the hash value for the given string. The algorithm
|
||||||
is taken from [Aho,Sethi,Ullman], modified to reduce the number of
|
is taken from [Aho,Sethi,Ullman], modified to reduce the number of
|
||||||
@ -41,8 +37,8 @@ compute_hashval (key, keylen)
|
|||||||
hval = keylen;
|
hval = keylen;
|
||||||
while (cnt < keylen)
|
while (cnt < keylen)
|
||||||
{
|
{
|
||||||
hval = (hval << 9) | (hval >> (LONGBITS - 9));
|
hval = (hval << 9) | (hval >> (sizeof hval * CHAR_BIT - 9));
|
||||||
hval += (unsigned long int) *(((char *) key) + cnt++);
|
hval += (hashval_t) *(((char *) key) + cnt++);
|
||||||
}
|
}
|
||||||
return hval != 0 ? hval : ~((unsigned long int) 0);
|
return hval != 0 ? hval : ~((hashval_t) 0);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
/* Define the hash function. We define the function as static inline. */
|
/* Define the hash function. We define the function as static inline. */
|
||||||
#define compute_hashval static inline compute_hashval
|
#define compute_hashval static inline compute_hashval
|
||||||
|
#define hashval_t uint32_t
|
||||||
#include "hashval.h"
|
#include "hashval.h"
|
||||||
#undef compute_hashval
|
#undef compute_hashval
|
||||||
|
|
||||||
|
@ -43,9 +43,15 @@
|
|||||||
#include "../../crypt/md5.h"
|
#include "../../crypt/md5.h"
|
||||||
#include "../localeinfo.h"
|
#include "../localeinfo.h"
|
||||||
#include "../locarchive.h"
|
#include "../locarchive.h"
|
||||||
#include "simple-hash.h"
|
|
||||||
#include "localedef.h"
|
#include "localedef.h"
|
||||||
|
|
||||||
|
/* Define the hash function. We define the function as static inline.
|
||||||
|
We must change the name so as not to conflict with simple-hash.h. */
|
||||||
|
#define compute_hashval static inline archive_hashval
|
||||||
|
#define hashval_t uint32_t
|
||||||
|
#include "hashval.h"
|
||||||
|
#undef compute_hashval
|
||||||
|
|
||||||
extern const char *output_prefix;
|
extern const char *output_prefix;
|
||||||
|
|
||||||
#define ARCHIVE_NAME LOCALEDIR "/locale-archive"
|
#define ARCHIVE_NAME LOCALEDIR "/locale-archive"
|
||||||
@ -522,7 +528,7 @@ insert_name (struct locarhandle *ah,
|
|||||||
unsigned int insert_idx, idx, incr;
|
unsigned int insert_idx, idx, incr;
|
||||||
|
|
||||||
/* Hash value of the locale name. */
|
/* Hash value of the locale name. */
|
||||||
uint32_t hval = compute_hashval (name, name_len);
|
uint32_t hval = archive_hashval (name, name_len);
|
||||||
|
|
||||||
insert_idx = -1;
|
insert_idx = -1;
|
||||||
idx = hval % head->namehash_size;
|
idx = hval % head->namehash_size;
|
||||||
@ -720,7 +726,7 @@ add_locale (struct locarhandle *ah,
|
|||||||
/* Compute the hash value of the checksum to determine a
|
/* Compute the hash value of the checksum to determine a
|
||||||
starting point for the search in the MD5 hash value
|
starting point for the search in the MD5 hash value
|
||||||
table. */
|
table. */
|
||||||
hval = compute_hashval (data[cnt].sum, 16);
|
hval = archive_hashval (data[cnt].sum, 16);
|
||||||
|
|
||||||
idx = hval % head->sumhash_size;
|
idx = hval % head->sumhash_size;
|
||||||
incr = 1 + hval % (head->sumhash_size - 2);
|
incr = 1 + hval % (head->sumhash_size - 2);
|
||||||
@ -812,7 +818,7 @@ add_locale (struct locarhandle *ah,
|
|||||||
error (EXIT_FAILURE, errno, _("cannot add to locale archive"));
|
error (EXIT_FAILURE, errno, _("cannot add to locale archive"));
|
||||||
|
|
||||||
/* Add the hash value to the hash table. */
|
/* Add the hash value to the hash table. */
|
||||||
md5hval = compute_hashval (data[cnt].sum, 16);
|
md5hval = archive_hashval (data[cnt].sum, 16);
|
||||||
|
|
||||||
idx = md5hval % head->sumhash_size;
|
idx = md5hval % head->sumhash_size;
|
||||||
incr = 1 + md5hval % (head->sumhash_size - 2);
|
incr = 1 + md5hval % (head->sumhash_size - 2);
|
||||||
@ -1303,7 +1309,7 @@ delete_locales_from_archive (nlist, list)
|
|||||||
unsigned int incr;
|
unsigned int incr;
|
||||||
|
|
||||||
/* Search for this locale in the archive. */
|
/* Search for this locale in the archive. */
|
||||||
hval = compute_hashval (locname, strlen (locname));
|
hval = archive_hashval (locname, strlen (locname));
|
||||||
|
|
||||||
idx = hval % head->namehash_size;
|
idx = hval % head->namehash_size;
|
||||||
incr = 1 + hval % (head->namehash_size - 2);
|
incr = 1 + hval % (head->namehash_size - 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user