xref: /netbsd-src/lib/libterminfo/genthash (revision 9e5def586b636b85607872122d0b5abfee0a6ea6)
14ca00e00Sroy#!/bin/sh
2*9e5def58Sroy# $NetBSD: genthash,v 1.5 2011/11/02 12:09:25 roy Exp $
34ca00e00Sroy
4*9e5def58Sroy# Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
54ca00e00Sroy#
64ca00e00Sroy# This code is derived from software contributed to The NetBSD Foundation
74ca00e00Sroy# by Roy Marples.
84ca00e00Sroy#
94ca00e00Sroy# Redistribution and use in source and binary forms, with or without
104ca00e00Sroy# modification, are permitted provided that the following conditions
114ca00e00Sroy# are met:
124ca00e00Sroy# 1. Redistributions of source code must retain the above copyright
134ca00e00Sroy#    notice, this list of conditions and the following disclaimer.
144ca00e00Sroy# 2. Redistributions in binary form must reproduce the above copyright
154ca00e00Sroy#    notice, this list of conditions and the following disclaimer in the
164ca00e00Sroy#    documentation and/or other materials provided with the distribution.
174ca00e00Sroy#
184ca00e00Sroy# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
194ca00e00Sroy# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
204ca00e00Sroy# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
214ca00e00Sroy# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
224ca00e00Sroy# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
234ca00e00Sroy# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
244ca00e00Sroy# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254ca00e00Sroy# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
264ca00e00Sroy# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
274ca00e00Sroy# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
284ca00e00Sroy
294ca00e00Sroy
304ca00e00Sroy# Generate string and hash tables for our termcap strings in termcap.c
314ca00e00Sroy
32ca77b139Sroyset -e
334ca00e00Sroy: ${TOOL_NBPERF:=nbperf}
344ca00e00Sroy: ${TOOL_SED:=sed}
354ca00e00Sroy
364ca00e00SroyTERMCAPC=${1:-termcap_map.c}
374ca00e00Sroy
384ca00e00Sroycat <<EOF
394ca00e00Sroy/* DO NOT EDIT
404ca00e00Sroy * Automatically generated from termcap.c */
414ca00e00Sroy
42eedd9adeSroy#include <stdint.h>
434ca00e00Sroy#include <stdlib.h>
444ca00e00Sroy#include <term_private.h>
454ca00e00Sroy
464ca00e00SroyEOF
474ca00e00Sroy
484ca00e00Sroy$TOOL_SED -n -e "1,/_ti_cap_flagids/d" -e '/};/,$d' \
494ca00e00Sroy	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
50*9e5def58Sroy	$TOOL_NBPERF -p -s -n _t_flaghash
514ca00e00Sroyecho
524ca00e00Sroy$TOOL_SED -n -e "1,/_ti_cap_numids/d" -e '/};/,$d' \
534ca00e00Sroy	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
54*9e5def58Sroy	$TOOL_NBPERF -p -s -n _t_numhash
554ca00e00Sroyecho
564ca00e00Sroy$TOOL_SED -n -e "1,/_ti_cap_strids/d" -e '/};/,$d' \
574ca00e00Sroy	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
58*9e5def58Sroy	$TOOL_NBPERF -p -s -n _t_strhash
59