home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 138.lha / M4 / Examples / hash.m4 < prev    next >
M4 Source File  |  1986-11-20  |  477b  |  18 lines

  1. dnl     This probably will not run on any m4 that cannot
  2. dnl     handle char constants in eval.
  3. dnl
  4. changequote(<,>) define(HASHVAL,99) dnl
  5. define(hash,<eval(str(substr($1,1),0)%HASHVAL)>) dnl
  6. define(str,
  7.         <ifelse($1,",$2,
  8.                 <str(substr(<$1>,1),<eval($2+'substr($1,0,1)')>)>)
  9.         >) dnl
  10. define(KEYWORD,<$1,hash($1),>) dnl
  11. define(TSTART,
  12. <struct prehash {
  13.         char *keyword;
  14.         int   hashval;
  15. } keytab[] = {>) dnl
  16. define(TEND,<   "",0
  17. };>) dnl
  18.