home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / wp_dtp / ispell.lha / hash.c < prev    next >
Text File  |  1990-08-05  |  311b  |  26 lines

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