#include <limits.h>
#include <sys/types.h>
-#include <obstack.h>
+/* Since this simple implementation of hash tables allows only insertion, no
+ removal of entries, the right data structure for the memory holding all keys
+ is an obstack. */
+#include "obstack.h"
+/* Use checked memory allocation. */
#include "xalloc.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
+
typedef struct hash_entry
{
- unsigned long used;
- const void *key;
+ unsigned long used; /* Hash code of the key, or 0 for an unused entry. */
+ const void *key; /* Key. */
size_t keylen;
- void *data;
+ void *data; /* Value. */
struct hash_entry *next;
}
hash_entry;
-/* Forward declaration of local functions. */
-static void insert_entry_2 (hash_table *htab,
- const void *key, size_t keylen,
- unsigned long int hval, size_t idx, void *data);
-static void resize (hash_table *htab);
-static size_t lookup (hash_table *htab,
- const void *key, size_t keylen,
- unsigned long int hval);
-static unsigned long compute_hashval (const void *key, size_t keylen);
-static int is_prime (unsigned long int candidate);
+
+/* Given an odd CANDIDATE > 1, return true if it is a prime number. */
+static int
+is_prime (unsigned long int candidate)
+{
+ /* No even number and none less than 10 will be passed here. */
+ unsigned long int divn = 3;
+ unsigned long int sq = divn * divn;
+
+ while (sq < candidate && candidate % divn != 0)
+ {
+ ++divn;
+ sq += 4 * divn;
+ ++divn;
+ }
+
+ return candidate % divn != 0;
+}
+
+
+/* Given SEED > 1, return the smallest odd prime number >= SEED. */
+unsigned long
+next_prime (unsigned long int seed)
+{
+ /* Make it definitely odd. */
+ seed |= 1;
+
+ while (!is_prime (seed))
+ seed += 2;
+
+ return seed;
+}
+/* Initialize a hash table. INIT_SIZE > 1 is the initial number of available
+ entries.
+ Return 0 upon successful completion, -1 upon memory allocation error. */
int
-init_hash (hash_table *htab, unsigned long int init_size)
+hash_init (hash_table *htab, unsigned long int init_size)
{
/* We need the size to be a prime. */
init_size = next_prime (init_size);
}
+/* Delete a hash table's contents.
+ Return 0 always. */
int
-delete_hash (hash_table *htab)
+hash_destroy (hash_table *htab)
{
free (htab->table);
obstack_free (&htab->mem_pool, NULL);
}
-int
-insert_entry (hash_table *htab, const void *key, size_t keylen, void *data)
+/* Compute a hash code for a key consisting of KEYLEN bytes starting at KEY
+ in memory. */
+static unsigned long
+compute_hashval (const void *key, size_t keylen)
{
- unsigned long int hval = compute_hashval (key, keylen);
+ size_t cnt;
+ unsigned long int hval;
+
+ /* Compute the hash value for the given string. The algorithm
+ is taken from [Aho,Sethi,Ullman], fixed according to
+ http://www.haible.de/bruno/hashfunc.html. */
+ cnt = 0;
+ hval = keylen;
+ while (cnt < keylen)
+ {
+ hval = (hval << 9) | (hval >> (sizeof (unsigned long) * CHAR_BIT - 9));
+ hval += (unsigned long int) *(((const char *) key) + cnt++);
+ }
+ return hval != 0 ? hval : ~((unsigned long) 0);
+}
+
+
+/* References:
+ [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
+ [Knuth] The Art of Computer Programming, part3 (6.4) */
+
+/* Look up a given key in the hash table.
+ Return the index of the entry, if present, or otherwise the index a free
+ entry where it could be inserted. */
+static size_t
+lookup (hash_table *htab,
+ const void *key, size_t keylen,
+ unsigned long int hval)
+{
+ unsigned long int hash;
+ size_t idx;
hash_entry *table = (hash_entry *) htab->table;
- size_t idx = lookup (htab, key, keylen, hval);
+
+ /* First hash function: simply take the modul but prevent zero. */
+ hash = 1 + hval % htab->size;
+
+ idx = hash;
if (table[idx].used)
- /* We don't want to overwrite the old value. */
- return -1;
- else
{
- /* An empty bucket has been found. */
- insert_entry_2 (htab, obstack_copy (&htab->mem_pool, key, keylen),
- keylen, hval, idx, data);
- if (100 * htab->filled > 75 * htab->size)
- /* Table is filled more than 75%. Resize the table. */
- resize (htab);
- return 0;
+ if (table[idx].used == hval && table[idx].keylen == keylen
+ && memcmp (table[idx].key, key, keylen) == 0)
+ return idx;
+
+ /* Second hash function as suggested in [Knuth]. */
+ hash = 1 + hval % (htab->size - 2);
+
+ do
+ {
+ if (idx <= hash)
+ idx = htab->size + idx - hash;
+ else
+ idx -= hash;
+
+ /* If entry is found use it. */
+ if (table[idx].used == hval && table[idx].keylen == keylen
+ && memcmp (table[idx].key, key, keylen) == 0)
+ return idx;
+ }
+ while (table[idx].used);
}
+ return idx;
+}
+
+
+/* Look up the value of a key in the given table.
+ If found, return 0 and set *RESULT to it. Otherwise return -1. */
+int
+hash_find_entry (hash_table *htab, const void *key, size_t keylen,
+ void **result)
+{
+ hash_entry *table = (hash_entry *) htab->table;
+ size_t idx = lookup (htab, key, keylen, compute_hashval (key, keylen));
+
+ if (table[idx].used == 0)
+ return -1;
+
+ *result = table[idx].data;
+ return 0;
}
+
+/* Insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table at index IDX.
+ HVAL is the key's hash code. IDX depends on it. The table entry at index
+ IDX is known to be unused. */
static void
insert_entry_2 (hash_table *htab,
const void *key, size_t keylen,
}
+/* Grow the hash table. */
static void
resize (hash_table *htab)
{
}
+/* Try to insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
+ Return 0 if successful, or -1 if there is already an entry with the given
+ key. */
int
-find_entry (hash_table *htab, const void *key, size_t keylen, void **result)
+hash_insert_entry (hash_table *htab,
+ const void *key, size_t keylen,
+ void *data)
{
+ unsigned long int hval = compute_hashval (key, keylen);
hash_entry *table = (hash_entry *) htab->table;
- size_t idx = lookup (htab, key, keylen, compute_hashval (key, keylen));
+ size_t idx = lookup (htab, key, keylen, hval);
- if (table[idx].used == 0)
+ if (table[idx].used)
+ /* We don't want to overwrite the old value. */
return -1;
+ else
+ {
+ /* An empty bucket has been found. */
+ void *keycopy = obstack_copy (&htab->mem_pool, key, keylen);
+ insert_entry_2 (htab, keycopy, keylen, hval, idx, data);
+ if (100 * htab->filled > 75 * htab->size)
+ /* Table is filled more than 75%. Resize the table. */
+ resize (htab);
+ return 0;
+ }
+}
- *result = table[idx].data;
- return 0;
+
+/* Insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
+ Return 0. */
+int
+hash_set_value (hash_table *htab,
+ const void *key, size_t keylen,
+ void *data)
+{
+ unsigned long int hval = compute_hashval (key, keylen);
+ hash_entry *table = (hash_entry *) htab->table;
+ size_t idx = lookup (htab, key, keylen, hval);
+
+ if (table[idx].used)
+ {
+ /* Overwrite the old value. */
+ table[idx].data = data;
+ return 0;
+ }
+ else
+ {
+ /* An empty bucket has been found. */
+ void *keycopy = obstack_copy (&htab->mem_pool, key, keylen);
+ insert_entry_2 (htab, keycopy, keylen, hval, idx, data);
+ if (100 * htab->filled > 75 * htab->size)
+ /* Table is filled more than 75%. Resize the table. */
+ resize (htab);
+ return 0;
+ }
}
+/* Steps *PTR forward to the next used entry in the given hash table. *PTR
+ should be initially set to NULL. Store information about the next entry
+ in *KEY, *KEYLEN, *DATA.
+ Return 0. */
int
-iterate_table (hash_table *htab, void **ptr, const void **key, size_t *keylen,
- void **data)
+hash_iterate (hash_table *htab, void **ptr, const void **key, size_t *keylen,
+ void **data)
{
if (*ptr == NULL)
{
{
if (*ptr == htab->first)
return -1;
- *ptr = (void *) (((hash_entry *) *ptr)->next);
+ *ptr = (void *) ((hash_entry *) *ptr)->next;
}
*key = ((hash_entry *) *ptr)->key;
*data = ((hash_entry *) *ptr)->data;
return 0;
}
-
-
-/* References:
- [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
- [Knuth] The Art of Computer Programming, part3 (6.4) */
-
-static size_t
-lookup (hash_table *htab,
- const void *key, size_t keylen,
- unsigned long int hval)
-{
- unsigned long int hash;
- size_t idx;
- hash_entry *table = (hash_entry *) htab->table;
-
- /* First hash function: simply take the modul but prevent zero. */
- hash = 1 + hval % htab->size;
-
- idx = hash;
-
- if (table[idx].used)
- {
- if (table[idx].used == hval && table[idx].keylen == keylen
- && memcmp (table[idx].key, key, keylen) == 0)
- return idx;
-
- /* Second hash function as suggested in [Knuth]. */
- hash = 1 + hval % (htab->size - 2);
-
- do
- {
- if (idx <= hash)
- idx = htab->size + idx - hash;
- else
- idx -= hash;
-
- /* If entry is found use it. */
- if (table[idx].used == hval && table[idx].keylen == keylen
- && memcmp (table[idx].key, key, keylen) == 0)
- return idx;
- }
- while (table[idx].used);
- }
- return idx;
-}
-
-
-static unsigned long
-compute_hashval (const void *key, size_t keylen)
-{
- size_t cnt;
- unsigned long int hval;
-
- /* Compute the hash value for the given string. The algorithm
- is taken from [Aho,Sethi,Ullman]. */
- cnt = 0;
- hval = keylen;
- while (cnt < keylen)
- {
- hval = (hval << 9) | (hval >> (sizeof (unsigned long) * CHAR_BIT - 9));
- hval += (unsigned long int) *(((const char *) key) + cnt++);
- }
- return hval != 0 ? hval : ~((unsigned long) 0);
-}
-
-
-unsigned long
-next_prime (unsigned long int seed)
-{
- /* Make it definitely odd. */
- seed |= 1;
-
- while (!is_prime (seed))
- seed += 2;
-
- return seed;
-}
-
-
-static int
-is_prime (unsigned long int candidate)
-{
- /* No even number and none less than 10 will be passed here. */
- unsigned long int divn = 3;
- unsigned long int sq = divn * divn;
-
- while (sq < candidate && candidate % divn != 0)
- {
- ++divn;
- sq += 4 * divn;
- ++divn;
- }
-
- return candidate % divn != 0;
-}
-/* Copyright (C) 1995, 2000-2003 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 2000-2003, 2005 Free Software Foundation, Inc.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
#ifndef _HASH_H
#define _HASH_H
-#include <obstack.h>
+#include "obstack.h"
#ifdef __cplusplus
extern "C" {
typedef struct hash_table
{
- unsigned long int size;
- unsigned long int filled;
- void *first;
- void *table;
- struct obstack mem_pool;
+ unsigned long int size; /* Number of allocated entries. */
+ unsigned long int filled; /* Number of used entries. */
+ void *first; /* Pointer to head of list of entries. */
+ void *table; /* Pointer to array of entries. */
+ struct obstack mem_pool; /* Memory pool holding the keys. */
}
hash_table;
-extern int init_hash (hash_table *htab, unsigned long int init_size);
-extern int delete_hash (hash_table *htab);
-extern int insert_entry (hash_table *htab,
- const void *key, size_t keylen,
- void *data);
-extern int find_entry (hash_table *htab,
- const void *key, size_t keylen,
- void **result);
+/* Initialize a hash table. INIT_SIZE > 1 is the initial number of available
+ entries.
+ Return 0 upon successful completion, -1 upon memory allocation error. */
+extern int hash_init (hash_table *htab, unsigned long int init_size);
-extern int iterate_table (hash_table *htab, void **ptr,
- const void **key, size_t *keylen,
- void **data);
+/* Delete a hash table's contents.
+ Return 0 always. */
+extern int hash_destroy (hash_table *htab);
+/* Look up the value of a key in the given table.
+ If found, return 0 and set *RESULT to it. Otherwise return -1. */
+extern int hash_find_entry (hash_table *htab,
+ const void *key, size_t keylen,
+ void **result);
+
+/* Try to insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
+ Return 0 if successful, or -1 if there is already an entry with the given
+ key. */
+extern int hash_insert_entry (hash_table *htab,
+ const void *key, size_t keylen,
+ void *data);
+
+/* Insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
+ Return 0. */
+extern int hash_set_value (hash_table *htab,
+ const void *key, size_t keylen,
+ void *data);
+
+/* Steps *PTR forward to the next used entry in the given hash table. *PTR
+ should be initially set to NULL. Store information about the next entry
+ in *KEY, *KEYLEN, *DATA.
+ Return 0. */
+extern int hash_iterate (hash_table *htab, void **ptr,
+ const void **key, size_t *keylen,
+ void **data);
+
+/* Given SEED > 1, return the smallest odd prime number >= SEED. */
extern unsigned long int next_prime (unsigned long int seed);
#ifdef __cplusplus
mlp->nitems_max = 0;
mlp->item = NULL;
if ((mlp->use_hashtable = use_hashtable))
- init_hash (&mlp->htable, 10);
+ hash_init (&mlp->htable, 10);
return mlp;
}
if (mlp->item)
free (mlp->item);
if (mlp->use_hashtable)
- delete_hash (&mlp->htable);
+ hash_destroy (&mlp->htable);
free (mlp);
}
keylen = strlen (mp->msgid) + 1;
}
- found = insert_entry (htable, key, keylen, mp);
+ found = hash_insert_entry (htable, key, keylen, mp);
if (mp->msgctxt != NULL)
freesa (alloced_key);
if (mlp->use_hashtable)
{
/* Our simple-minded hash tables don't support removal. */
- delete_hash (&mlp->htable);
+ hash_destroy (&mlp->htable);
mlp->use_hashtable = false;
}
}
if (mlp->use_hashtable && i < mlp->nitems)
{
/* Our simple-minded hash tables don't support removal. */
- delete_hash (&mlp->htable);
+ hash_destroy (&mlp->htable);
mlp->use_hashtable = false;
}
mlp->nitems = i;
unsigned long int size = mlp->htable.size;
size_t j;
- delete_hash (&mlp->htable);
- init_hash (&mlp->htable, size);
+ hash_destroy (&mlp->htable);
+ hash_init (&mlp->htable, size);
for (j = 0; j < mlp->nitems; j++)
{
the assertion that it wouldn't have duplicates, and before the
msgids changed it indeed didn't have duplicates. */
{
- delete_hash (&mlp->htable);
+ hash_destroy (&mlp->htable);
mlp->use_hashtable = false;
return true;
}
{
void *htable_value;
- int found = !find_entry (&mlp->htable, key, keylen, &htable_value);
+ int found = !hash_find_entry (&mlp->htable, key, keylen, &htable_value);
if (msgctxt != NULL)
freesa (alloced_key);
unsigned long table_size;
/* Collect the contexts, removing duplicates. */
- init_hash (&all_contexts, 10);
+ hash_init (&all_contexts, 10);
for (j = 0; j < mlp->nitems; j++)
{
message_ty *mp = mlp->item[j];
if (!is_header (mp))
- insert_entry (&all_contexts,
- mp->msgctxt, strlen (mp->msgctxt) + 1,
- NULL);
+ hash_insert_entry (&all_contexts,
+ mp->msgctxt, strlen (mp->msgctxt) + 1,
+ NULL);
}
/* Compute the number of different contexts. */
void *null;
iter = NULL;
- while (iterate_table (&all_contexts, &iter, &key, &keylen, &null)
+ while (hash_iterate (&all_contexts, &iter, &key, &keylen, &null)
== 0)
{
const char *context = (const char *)key;
free (list_memory);
}
- delete_hash (&all_contexts);
+ hash_destroy (&all_contexts);
}
}
/* xgettext awk backend.
- Copyright (C) 2002-2003 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
{
void *keyword_value;
- if (find_entry (&keywords, token.string, strlen (token.string),
- &keyword_value)
+ if (hash_find_entry (&keywords, token.string, strlen (token.string),
+ &keyword_value)
== 0)
{
int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
/* xgettext C/C++/ObjectiveC backend.
- Copyright (C) 1995-1998, 2000-2004 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
This file was written by Peter Miller <millerp@canb.auug.org.au>
const char *colon;
if (keywords->table == NULL)
- init_hash (keywords, 100);
+ hash_init (keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
case token_type_name:
last_non_comment_line = newline_count;
- if (find_entry (objc_extensions ? &objc_keywords : &c_keywords,
- token.string, strlen (token.string), &keyword_value)
+ if (hash_find_entry (objc_extensions ? &objc_keywords : &c_keywords,
+ token.string, strlen (token.string),
+ &keyword_value)
== 0)
{
tp->type = xgettext_token_type_keyword;
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
{
void *keyword_value;
- if (find_entry (&keywords, dottedname, strlen (dottedname),
- &keyword_value)
+ if (hash_find_entry (&keywords, dottedname, strlen (dottedname),
+ &keyword_value)
== 0)
{
int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
/* xgettext Emacs Lisp backend.
- Copyright (C) 2001-2003 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001-2002.
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
char *symbol_name = string_of_object (&inner);
void *keyword_value;
- if (find_entry (&keywords,
- symbol_name, strlen (symbol_name),
- &keyword_value)
+ if (hash_find_entry (&keywords,
+ symbol_name, strlen (symbol_name),
+ &keyword_value)
== 0)
{
argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
/* xgettext glade backend.
- Copyright (C) 2002-2003 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2002.
else
{
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
- insert_entry (&keywords, name, strlen (name), NULL);
+ hash_insert_entry (&keywords, name, strlen (name), NULL);
}
}
/* In Glade 1, a few specific elements are translatable. */
if (!p->extract_string)
p->extract_string =
- (find_entry (&keywords, name, strlen (name), &hash_result) == 0);
+ (hash_find_entry (&keywords, name, strlen (name), &hash_result) == 0);
/* In Glade 2, all <property> and <atkproperty> elements are translatable
that have the attribute translatable="yes". */
if (!p->extract_string
/* xgettext Java backend.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
{
void *keyword_value;
- if (find_entry (&keywords, dottedname, strlen (dottedname),
- &keyword_value)
+ if (hash_find_entry (&keywords, dottedname, strlen (dottedname),
+ &keyword_value)
== 0)
{
int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
/* xgettext librep backend.
- Copyright (C) 2001-2003 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc.
This file was written by Bruno Haible <haible@clisp.cons.org>, 2001.
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
char *symbol_name = string_of_object (&inner);
void *keyword_value;
- if (find_entry (&keywords,
- symbol_name, strlen (symbol_name),
- &keyword_value)
+ if (hash_find_entry (&keywords,
+ symbol_name, strlen (symbol_name),
+ &keyword_value)
== 0)
{
argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
size_t i;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, symname, len,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, symname, len,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
i--;
prefix_len = i;
- if (find_entry (&keywords,
- symbol_name + prefix_len,
- strlen (symbol_name + prefix_len),
- &keyword_value)
+ if (hash_find_entry (&keywords,
+ symbol_name + prefix_len,
+ strlen (symbol_name + prefix_len),
+ &keyword_value)
== 0)
{
argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
/* xgettext Perl backend.
- Copyright (C) 2002-2004 Free Software Foundation, Inc.
+ Copyright (C) 2002-2005 Free Software Foundation, Inc.
This file was written by Guido Flohr <guido@imperia.net>, 2002-2003.
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
real_file_name, line_number);
#endif
- if (find_entry (&keywords, tp->string, strlen (tp->string),
- &keyword_value) == 0)
+ if (hash_find_entry (&keywords, tp->string, strlen (tp->string),
+ &keyword_value) == 0)
{
/* Extract a possible string from the key. Before proceeding
we check whether the open curly is followed by a symbol and
switch (c)
{
case '-':
- if (find_entry (&keywords, buffer, bufpos, &keyword_value) == 0)
+ if (hash_find_entry (&keywords, buffer, bufpos, &keyword_value)
+ == 0)
{
flag_context_list_iterator_ty context_iter =
flag_context_list_iterator (
case '{':
if (!maybe_hash_deref)
buffer[0] = '%';
- if (find_entry (&keywords, buffer, bufpos, &keyword_value) == 0)
+ if (hash_find_entry (&keywords, buffer, bufpos, &keyword_value)
+ == 0)
{
flag_context_list_iterator_ty context_iter =
flag_context_list_iterator (
{
void *keyword_value;
- if (find_entry (&keywords, tp->string, strlen (tp->string),
- &keyword_value) == 0)
+ if (hash_find_entry (&keywords, tp->string, strlen (tp->string),
+ &keyword_value) == 0)
{
last_token = token_type_keyword_symbol;
/* xgettext PHP backend.
- Copyright (C) 2001-2003 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005 Free Software Foundation, Inc.
This file was written by Bruno Haible <bruno@clisp.org>, 2002.
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
{
void *keyword_value;
- if (find_entry (&keywords, token.string, strlen (token.string),
- &keyword_value)
+ if (hash_find_entry (&keywords, token.string, strlen (token.string),
+ &keyword_value)
== 0)
{
int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
{
void *keyword_value;
- if (find_entry (&keywords, token.string, strlen (token.string),
- &keyword_value)
+ if (hash_find_entry (&keywords, token.string, strlen (token.string),
+ &keyword_value)
== 0)
{
int argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
char *symbol_name = string_of_object (&inner);
void *keyword_value;
- if (find_entry (&keywords,
- symbol_name, strlen (symbol_name),
- &keyword_value)
+ if (hash_find_entry (&keywords,
+ symbol_name, strlen (symbol_name),
+ &keyword_value)
== 0)
{
argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
const char *colon;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
{
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
}
char *function_name = string_of_word (&inner);
void *keyword_value;
- if (find_entry (&keywords,
- function_name, strlen (function_name),
- &keyword_value)
+ if (hash_find_entry (&keywords,
+ function_name, strlen (function_name),
+ &keyword_value)
== 0)
{
argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
int argnum2;
if (keywords.table == NULL)
- init_hash (&keywords, 100);
+ hash_init (&keywords, 100);
split_keywordspec (name, &end, &argnum1, &argnum2);
if (argnum1 == 0)
argnum1 = 1;
- insert_entry (&keywords, name, end - name,
- (void *) (long) (argnum1 + (argnum2 << 10)));
+ hash_insert_entry (&keywords, name, end - name,
+ (void *) (long) (argnum1 + (argnum2 << 10)));
}
}
if (function_name[0] == ':' && function_name[1] == ':')
stripped_name += 2;
- if (find_entry (&keywords,
- stripped_name, strlen (stripped_name),
- &keyword_value)
+ if (hash_find_entry (&keywords,
+ stripped_name, strlen (stripped_name),
+ &keyword_value)
== 0)
{
argnum1 = (int) (long) keyword_value & ((1 << 10) - 1);
void *entry;
if (flag_table->table != NULL
- && find_entry (flag_table, key, keylen, &entry) == 0)
+ && hash_find_entry (flag_table, key, keylen, &entry) == 0)
return (flag_context_list_ty *) entry;
else
return NULL;
/* Insert the pair (VALUE, PASS) at INDEX in the element numbered ARGNUM
of the list corresponding to NAME in the TABLE. */
if (table->table == NULL)
- init_hash (table, 100);
+ hash_init (table, 100);
{
void *entry;
- if (find_entry (table, name_start, name_end - name_start, &entry) != 0)
+ if (hash_find_entry (table, name_start, name_end - name_start, &entry) != 0)
{
/* Create new hash table entry. */
flag_context_list_ty *list =
abort ();
}
list->next = NULL;
- insert_entry (table, name_start, name_end - name_start, list);
+ hash_insert_entry (table, name_start, name_end - name_start, list);
}
else
{