xref: /original-bsd/usr.bin/m4/TEST/hash.m4 (revision 35293e0f)
1#
2# Copyright (c) 1989 The Regents of the University of California.
3# All rights reserved.
4#
5# This code is derived from software contributed to Berkeley by
6# Ozan Yigit.
7#
8# Redistribution and use in source and binary forms are permitted
9# provided that the above copyright notice and this paragraph are
10# duplicated in all such forms and that any documentation,
11# advertising materials, and other materials related to such
12# distribution and use acknowledge that the software was developed
13# by the University of California, Berkeley.  The name of the
14# University may not be used to endorse or promote products derived
15# from this software without specific prior written permission.
16# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19#
20#	@(#)hash.m4	5.1 (Berkeley) 08/28/89
21#
22
23dnl	This probably will not run on any m4 that cannot
24dnl	handle char constants in eval.
25dnl
26changequote(<,>) define(HASHVAL,99) dnl
27define(hash,<eval(str(substr($1,1),0)%HASHVAL)>) dnl
28define(str,
29	<ifelse($1,",$2,
30		<str(substr(<$1>,1),<eval($2+'substr($1,0,1)')>)>)
31	>) dnl
32define(KEYWORD,<$1,hash($1),>) dnl
33define(TSTART,
34<struct prehash {
35	char *keyword;
36	int   hashval;
37} keytab[] = {>) dnl
38define(TEND,<	"",0
39};>) dnl
40