/[m4]/m4/m4/hash.c
ViewVC logotype

Diff of /m4/m4/hash.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by gary, Sun Sep 30 22:26:57 2001 UTC revision 1.6 by gary, Tue May 28 21:30:24 2002 UTC
# Line 374  m4_hash_exit (void) Line 374  m4_hash_exit (void)
374        xfree (stale);        xfree (stale);
375      }      }
376  }  }
377    
378    
379    
380  struct m4_hash_iterator  struct m4_hash_iterator
# Line 467  m4_hash_iterator_value (m4_hash_iterator Line 467  m4_hash_iterator_value (m4_hash_iterator
467    
468    return M4_HASH_NODE_VAL (M4_ITERATOR_PLACE (place));    return M4_HASH_NODE_VAL (M4_ITERATOR_PLACE (place));
469  }  }
470    
471    
472    /* Using a string as the hash key is common enough that we provide
473       implementations here for use in client hash table routines.  */
474    
475    /* Return a hash value for a string, from GNU Emacs.  */
476    size_t
477    m4_hash_string_hash (const void *key)
478    {
479      int val = 0;
480      const char *ptr = (const char *) key;
481      char ch;
482    
483      while ((ch = *ptr++) != '\0')
484        {
485          if (ch >= 0140)
486            ch -= 40;
487          val = ((val << 3) + (val >> 28) + ch);
488        };
489      val = (val < 0) ? -val : val;
490      return val;
491    }
492    
493    /* Comparison function for hash keys -- used by the underlying
494       hash table ADT when searching for a key match during name lookup.  */
495    int
496    m4_hash_string_cmp (const void *key, const void *try)
497    {
498      return (strcmp ((const char *) key, (const char *) try));
499    }

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

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26