1114402Sru/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
2114402Sru     Written by James Clark (jjc@jclark.com)
3114402Sru
4114402SruThis file is part of groff.
5114402Sru
6114402Srugroff is free software; you can redistribute it and/or modify it under
7114402Sruthe terms of the GNU General Public License as published by the Free
8114402SruSoftware Foundation; either version 2, or (at your option) any later
9114402Sruversion.
10114402Sru
11114402Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
12114402SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
13114402SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14114402Srufor more details.
15114402Sru
16114402SruYou should have received a copy of the GNU General Public License along
17114402Sruwith groff; see the file COPYING.  If not, write to the Free Software
18151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
19114402Sru
20114402Sruunsigned hash(const char *s, int len)
21114402Sru{
22114402Sru#if 0
23114402Sru  unsigned h = 0, g;
24114402Sru  while (*s != '\0') {
25114402Sru    h <<= 4;
26114402Sru    h += *s++;
27114402Sru    if ((g = h & 0xf0000000) != 0) {
28114402Sru      h ^= g >> 24;
29114402Sru      h ^= g;
30114402Sru    }
31114402Sru  }
32114402Sru#endif
33114402Sru  unsigned h = 0;
34114402Sru  while (--len >= 0)
35114402Sru    h = *s++ + 65587*h;
36114402Sru  return h;
37114402Sru}
38114402Sru
39