include config.h for FLEXNAMES; bug report 4.3BSD/usr.bin/83
[unix-history] / usr / src / old / pcc / lint / lpass1 / hash.c
CommitLineData
49531380 1#ifndef lint
e3e0664b 2static char sccsid[] = "@(#)hash.c 1.2 (Berkeley) %G%";
49531380
EW
3#endif lint
4
e3e0664b
KB
5#include "config.h"
6
49531380
EW
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
17hashstr(s)
18#else
19hashstr(s, n)
20register n;
21#endif
22register 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}