[BACK]Return to look.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / m4

Diff for /src/usr.bin/m4/look.c between version 1.5 and 1.6

version 1.5, 1999/11/17 15:34:13 version 1.6, 1999/11/20 17:48:59
Line 57 
Line 57 
   
 static void freent __P((ndptr));  static void freent __P((ndptr));
   
 int  unsigned
 hash(name)  hash(name)
         const char *name;          const char *name;
 {  {
         unsigned long h = 0;          unsigned h = 0;
         while (*name)          while (*name)
                 h = (h << 5) + h + *name++;                  h = (h << 5) + h + *name++;
         return (h % HASHSIZE);          return (h);
 }  }
   
 /*  /*
Line 75 
Line 75 
         const char *name;          const char *name;
 {  {
         ndptr p;          ndptr p;
           unsigned h;
   
         for (p = hashtab[hash(name)]; p != nil; p = p->nxtptr)          h = hash(name);
                 if (STREQ(name, p->name))          for (p = hashtab[h % HASHSIZE]; p != nil; p = p->nxtptr)
                   if (h == p->hv && STREQ(name, p->name))
                         break;                          break;
         return (p);          return (p);
 }  }
Line 90 
Line 92 
 addent(name)  addent(name)
         const char *name;          const char *name;
 {  {
         int h;          unsigned h;
         ndptr p;          ndptr p;
   
         h = hash(name);          h = hash(name);
         p = (ndptr) xalloc(sizeof(struct ndblock));          p = (ndptr) xalloc(sizeof(struct ndblock));
         p->nxtptr = hashtab[h];          p->nxtptr = hashtab[h % HASHSIZE];
         hashtab[h] = p;          hashtab[h % HASHSIZE] = p;
         p->name = xstrdup(name);          p->name = xstrdup(name);
           p->hv = h;
         return p;          return p;
 }  }
   
Line 125 
Line 128 
         ndptr xp, tp, mp;          ndptr xp, tp, mp;
   
         h = hash(name);          h = hash(name);
         mp = hashtab[h];          mp = hashtab[h % HASHSIZE];
         tp = nil;          tp = nil;
         while (mp != nil) {          while (mp != nil) {
                 if (STREQ(mp->name, name)) {                  if (mp->hv == h && STREQ(mp->name, name)) {
                         mp = mp->nxtptr;                          mp = mp->nxtptr;
                         if (tp == nil) {                          if (tp == nil) {
                                 freent(hashtab[h]);                                  freent(hashtab[h % HASHSIZE]);
                                 hashtab[h] = mp;                                  hashtab[h % HASHSIZE] = mp;
                         }                          }
                         else {                          else {
                                 xp = tp->nxtptr;                                  xp = tp->nxtptr;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6