11.1Sroy#!/bin/sh
21.5Sroy# $NetBSD: genthash,v 1.5 2011/11/02 12:09:25 roy Exp $
31.1Sroy
41.5Sroy# Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
51.1Sroy#
61.1Sroy# This code is derived from software contributed to The NetBSD Foundation
71.1Sroy# by Roy Marples.
81.1Sroy#
91.1Sroy# Redistribution and use in source and binary forms, with or without
101.1Sroy# modification, are permitted provided that the following conditions
111.1Sroy# are met:
121.1Sroy# 1. Redistributions of source code must retain the above copyright
131.1Sroy#    notice, this list of conditions and the following disclaimer.
141.1Sroy# 2. Redistributions in binary form must reproduce the above copyright
151.1Sroy#    notice, this list of conditions and the following disclaimer in the
161.1Sroy#    documentation and/or other materials provided with the distribution.
171.1Sroy#
181.1Sroy# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
191.1Sroy# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
201.1Sroy# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
211.1Sroy# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
221.1Sroy# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
231.1Sroy# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
241.1Sroy# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
251.1Sroy# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
261.1Sroy# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
271.1Sroy# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
281.1Sroy
291.1Sroy
301.1Sroy# Generate string and hash tables for our termcap strings in termcap.c
311.1Sroy
321.4Sroyset -e
331.1Sroy: ${TOOL_NBPERF:=nbperf}
341.1Sroy: ${TOOL_SED:=sed}
351.1Sroy
361.1SroyTERMCAPC=${1:-termcap_map.c}
371.1Sroy
381.1Sroycat <<EOF
391.1Sroy/* DO NOT EDIT
401.1Sroy * Automatically generated from termcap.c */
411.1Sroy
421.3Sroy#include <stdint.h>
431.1Sroy#include <stdlib.h>
441.1Sroy#include <term_private.h>
451.1Sroy
461.1SroyEOF
471.1Sroy
481.1Sroy$TOOL_SED -n -e "1,/_ti_cap_flagids/d" -e '/};/,$d' \
491.1Sroy	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
501.5Sroy	$TOOL_NBPERF -p -s -n _t_flaghash
511.1Sroyecho
521.1Sroy$TOOL_SED -n -e "1,/_ti_cap_numids/d" -e '/};/,$d' \
531.1Sroy	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
541.5Sroy	$TOOL_NBPERF -p -s -n _t_numhash
551.1Sroyecho
561.1Sroy$TOOL_SED -n -e "1,/_ti_cap_strids/d" -e '/};/,$d' \
571.1Sroy	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
581.5Sroy	$TOOL_NBPERF -p -s -n _t_strhash
59