hash.m4 revision 1590
18870Srgrimes# 250476Speter# Copyright (c) 1989, 1993 38870Srgrimes# The Regents of the University of California. All rights reserved. 42116Sjkh# 52116Sjkh# This code is derived from software contributed to Berkeley by 68870Srgrimes# Ozan Yigit. 72116Sjkh# 82116Sjkh# Redistribution and use in source and binary forms, with or without 98870Srgrimes# modification, are permitted provided that the following conditions 102116Sjkh# are met: 112116Sjkh# 1. Redistributions of source code must retain the above copyright 128870Srgrimes# notice, this list of conditions and the following disclaimer. 138870Srgrimes# 2. Redistributions in binary form must reproduce the above copyright 142116Sjkh# notice, this list of conditions and the following disclaimer in the 152116Sjkh# documentation and/or other materials provided with the distribution. 162116Sjkh# 3. All advertising materials mentioning features or use of this software 172116Sjkh# must display the following acknowledgement: 188870Srgrimes# This product includes software developed by the University of 198870Srgrimes# California, Berkeley and its contributors. 202116Sjkh# 4. Neither the name of the University nor the names of its contributors 212116Sjkh# may be used to endorse or promote products derived from this software 222116Sjkh# without specific prior written permission. 232116Sjkh# 242116Sjkh# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 252116Sjkh# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 268870Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 272116Sjkh# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 282116Sjkh# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 292116Sjkh# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 302116Sjkh# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 318870Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 322116Sjkh# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 332116Sjkh# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 348870Srgrimes# SUCH DAMAGE. 352116Sjkh# 362116Sjkh# @(#)hash.m4 8.1 (Berkeley) 6/6/93 378870Srgrimes# 382116Sjkh 392116Sjkhdnl This probably will not run on any m4 that cannot 408870Srgrimesdnl handle char constants in eval. 412116Sjkhdnl 428870Srgrimeschangequote(<,>) define(HASHVAL,99) dnl 432116Sjkhdefine(hash,<eval(str(substr($1,1),0)%HASHVAL)>) dnl 4433662Sjbdefine(str, 4533662Sjb <ifelse($1,",$2, 4633662Sjb <str(substr(<$1>,1),<eval($2+'substr($1,0,1)')>)>) 4733662Sjb >) dnl 4833662Sjbdefine(KEYWORD,<$1,hash($1),>) dnl 4933662Sjbdefine(TSTART, 5033662Sjb<struct prehash { 5142044Sdfr char *keyword; 5242044Sdfr int hashval; 5333662Sjb} keytab[] = {>) dnl 5422808Sbdedefine(TEND,< "",0 5524964Sbde};>) dnl 562116Sjkh