home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d191 / ispell.lha / ISpell / src.zoo / hash.c < prev    next >
Text File  |  1989-02-22  |  350b  |  28 lines

  1. /* -*- Mode:Text -*- */
  2. /*
  3.  * hash.c - a simple hash function for ispell
  4.  *
  5.  * Pace Willisson, 1983
  6.  */
  7.  
  8. hash (s, n, hashsize)
  9. register char *s;
  10. register n;
  11. register hashsize;
  12. {
  13.     register short h = 0;
  14.  
  15.     while (n--) {
  16.         h ^= *s++;
  17.         if (h < 0) {
  18.             h <<= 1;
  19.             h++;
  20.         } else {
  21.             h <<= 1;
  22.         }
  23.     }
  24.  
  25.     h &= 077777;
  26.     return (unsigned long) h % hashsize;
  27. }
  28.