xref: /csrg-svn/usr.bin/m4/TEST/hash.m4 (revision 62077)
138815Sbostic#
2*62077Sbostic# Copyright (c) 1989, 1993
3*62077Sbostic#	The Regents of the University of California.  All rights reserved.
438815Sbostic#
538815Sbostic# This code is derived from software contributed to Berkeley by
638815Sbostic# Ozan Yigit.
738815Sbostic#
847964Sbostic# %sccs.include.redist.sh%
938815Sbostic#
10*62077Sbostic#	@(#)hash.m4	8.1 (Berkeley) 06/06/93
1138815Sbostic#
1238815Sbostic
1338815Sbosticdnl	This probably will not run on any m4 that cannot
1438815Sbosticdnl	handle char constants in eval.
1538815Sbosticdnl
1638815Sbosticchangequote(<,>) define(HASHVAL,99) dnl
1738815Sbosticdefine(hash,<eval(str(substr($1,1),0)%HASHVAL)>) dnl
1838815Sbosticdefine(str,
1938815Sbostic	<ifelse($1,",$2,
2038815Sbostic		<str(substr(<$1>,1),<eval($2+'substr($1,0,1)')>)>)
2138815Sbostic	>) dnl
2238815Sbosticdefine(KEYWORD,<$1,hash($1),>) dnl
2338815Sbosticdefine(TSTART,
2438815Sbostic<struct prehash {
2538815Sbostic	char *keyword;
2638815Sbostic	int   hashval;
2738815Sbostic} keytab[] = {>) dnl
2838815Sbosticdefine(TEND,<	"",0
2938815Sbostic};>) dnl
30