374 |
xfree (stale); |
xfree (stale); |
375 |
} |
} |
376 |
} |
} |
377 |
|
|
378 |
|
|
379 |
|
|
380 |
struct m4_hash_iterator |
struct m4_hash_iterator |
467 |
|
|
468 |
return M4_HASH_NODE_VAL (M4_ITERATOR_PLACE (place)); |
return M4_HASH_NODE_VAL (M4_ITERATOR_PLACE (place)); |
469 |
} |
} |
470 |
|
|
471 |
|
|
472 |
|
/* Using a string as the hash key is common enough that we provide |
473 |
|
implementations here for use in client hash table routines. */ |
474 |
|
|
475 |
|
/* Return a hash value for a string, from GNU Emacs. */ |
476 |
|
size_t |
477 |
|
m4_hash_string_hash (const void *key) |
478 |
|
{ |
479 |
|
int val = 0; |
480 |
|
const char *ptr = (const char *) key; |
481 |
|
char ch; |
482 |
|
|
483 |
|
while ((ch = *ptr++) != '\0') |
484 |
|
{ |
485 |
|
if (ch >= 0140) |
486 |
|
ch -= 40; |
487 |
|
val = ((val << 3) + (val >> 28) + ch); |
488 |
|
}; |
489 |
|
val = (val < 0) ? -val : val; |
490 |
|
return val; |
491 |
|
} |
492 |
|
|
493 |
|
/* Comparison function for hash keys -- used by the underlying |
494 |
|
hash table ADT when searching for a key match during name lookup. */ |
495 |
|
int |
496 |
|
m4_hash_string_cmp (const void *key, const void *try) |
497 |
|
{ |
498 |
|
return (strcmp ((const char *) key, (const char *) try)); |
499 |
|
} |