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

Defined functions

hashstr defined in line 15; used 4 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1983-03-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 782
Valid CSS Valid XHTML 1.0 Strict