1: #if !defined(lint) && defined(DOSCCS)
   2: static char sccsid[] = "@(#)hash.c	1.1	(Berkeley)	3/29/83";
   3: #endif lint
   4: 
   5: #include "config.h"
   6: 
   7: /*
   8:  * Hash function.  Used for pass 2 symbol table and string table,
   9:  * and structure/union name passing between passes.
  10:  * The hash function is a modular hash of
  11:  * the sum of the characters with the sum
  12:  * rotated before each successive character
  13:  * is added.
  14:  * Only 15 bits are used.
  15:  */
  16: #ifdef FLEXNAMES
  17: hashstr(s)
  18: #else
  19: hashstr(s, n)
  20: register n;
  21: #endif
  22: register char *s;
  23: {
  24:     register i;
  25: 
  26:     i = 0;
  27: #ifdef FLEXNAMES
  28:     while (*s)
  29: #else
  30:     while (n-- > 0 && *s)
  31: #endif
  32:         i = (i << 3 | i >> 12 & 0x07) + *s++;
  33:     return i & 0x7fff;
  34: }

Defined functions

hashstr defined in line 17; used 4 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1991-08-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1772
Valid CSS Valid XHTML 1.0 Strict