-#ifdef MAIN_PROGRAM
-#include <ctype.h>
-#undef DEBUG
-#define DEBUG(level, params) /*nothing */
-#endif
-
-MODULE_ID("$Id: comp_hash.c,v 1.45 2009/07/18 20:30:21 tom Exp $")
-
-static int hash_function(const char *);
-
-/*
- * _nc_make_hash_table()
- *
- * Takes the entries in table[] and hashes them into hash_table[]
- * by name. There are CAPTABSIZE entries in table[] and HASHTABSIZE
- * slots in hash_table[].
- *
- */
-
-#ifdef MAIN_PROGRAM
-
-#undef MODULE_ID
-#define MODULE_ID(id) /*nothing */
-#include <tinfo/doalloc.c>
-
-static void
-_nc_make_hash_table(struct name_table_entry *table,
- short *hash_table)
-{
- short i;
- int hashvalue;
- int collisions = 0;
-
- for (i = 0; i < HASHTABSIZE; i++) {
- hash_table[i] = -1;
- }
- for (i = 0; i < CAPTABSIZE; i++) {
- hashvalue = hash_function(table[i].nte_name);
-
- if (hash_table[hashvalue] >= 0)
- collisions++;
-
- if (hash_table[hashvalue] != 0)
- table[i].nte_link = hash_table[hashvalue];
- hash_table[hashvalue] = i;
- }
-
- printf("/* %d collisions out of %d entries */\n", collisions, CAPTABSIZE);
-}
-#endif
-
-/*
- * int hash_function(string)
- *
- * Computes the hashing function on the given string.
- *
- * The current hash function is the sum of each consectutive pair
- * of characters, taken as two-byte integers, mod HASHTABSIZE.
- *
- */
-
-static int
-hash_function(const char *string)
-{
- long sum = 0;
-
- DEBUG(9, ("hashing %s", string));
- while (*string) {
- sum += (long) (*string + (*(string + 1) << 8));
- string++;
- }
-
- DEBUG(9, ("sum is %ld", sum));
- return (int) (sum % HASHTABSIZE);
-}
-
-#ifndef MAIN_PROGRAM
-
-#define SameName(a,b,termcap) (termcap ? !strncmp(a,b,2) : !strcmp(a,b))
-#if 0
-static bool
-same_name(const char *a, const char *b, bool termcap)
-{
- fprintf(stderr, "compare(%s,%s)\n", a, b);
- return SameName(a, b, termcap);
-}
-#else
-#define same_name(a,b,termcap) SameName(a,b,termcap)
-#endif