xref: /original-bsd/usr.bin/m4/TEST/hash.m4 (revision c3e32dec)
1#
2# Copyright (c) 1989, 1993
3#	The Regents of the University of California.  All rights reserved.
4#
5# This code is derived from software contributed to Berkeley by
6# Ozan Yigit.
7#
8# %sccs.include.redist.sh%
9#
10#	@(#)hash.m4	8.1 (Berkeley) 06/06/93
11#
12
13dnl	This probably will not run on any m4 that cannot
14dnl	handle char constants in eval.
15dnl
16changequote(<,>) define(HASHVAL,99) dnl
17define(hash,<eval(str(substr($1,1),0)%HASHVAL)>) dnl
18define(str,
19	<ifelse($1,",$2,
20		<str(substr(<$1>,1),<eval($2+'substr($1,0,1)')>)>)
21	>) dnl
22define(KEYWORD,<$1,hash($1),>) dnl
23define(TSTART,
24<struct prehash {
25	char *keyword;
26	int   hashval;
27} keytab[] = {>) dnl
28define(TEND,<	"",0
29};>) dnl
30