xref: /minix3/lib/libterminfo/genthash (revision 0c3ae37f525eceade8dc047e551f5c9cb33faeb1)
151e66a47SVivek Prakash#!/bin/sh
2*0c3ae37fSLionel Sambuc# $NetBSD: genthash,v 1.5 2011/11/02 12:09:25 roy Exp $
351e66a47SVivek Prakash
4*0c3ae37fSLionel Sambuc# Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
551e66a47SVivek Prakash#
651e66a47SVivek Prakash# This code is derived from software contributed to The NetBSD Foundation
751e66a47SVivek Prakash# by Roy Marples.
851e66a47SVivek Prakash#
951e66a47SVivek Prakash# Redistribution and use in source and binary forms, with or without
1051e66a47SVivek Prakash# modification, are permitted provided that the following conditions
1151e66a47SVivek Prakash# are met:
1251e66a47SVivek Prakash# 1. Redistributions of source code must retain the above copyright
1351e66a47SVivek Prakash#    notice, this list of conditions and the following disclaimer.
1451e66a47SVivek Prakash# 2. Redistributions in binary form must reproduce the above copyright
1551e66a47SVivek Prakash#    notice, this list of conditions and the following disclaimer in the
1651e66a47SVivek Prakash#    documentation and/or other materials provided with the distribution.
1751e66a47SVivek Prakash#
1851e66a47SVivek Prakash# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1951e66a47SVivek Prakash# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2051e66a47SVivek Prakash# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2151e66a47SVivek Prakash# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2251e66a47SVivek Prakash# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2351e66a47SVivek Prakash# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2451e66a47SVivek Prakash# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2551e66a47SVivek Prakash# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2651e66a47SVivek Prakash# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2751e66a47SVivek Prakash# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2851e66a47SVivek Prakash
2951e66a47SVivek Prakash
3051e66a47SVivek Prakash# Generate string and hash tables for our termcap strings in termcap.c
3151e66a47SVivek Prakash
3251e66a47SVivek Prakashset -e
3351e66a47SVivek Prakash: ${TOOL_NBPERF:=nbperf}
3451e66a47SVivek Prakash: ${TOOL_SED:=sed}
3551e66a47SVivek Prakash
3651e66a47SVivek PrakashTERMCAPC=${1:-termcap_map.c}
3751e66a47SVivek Prakash
3851e66a47SVivek Prakashcat <<EOF
3951e66a47SVivek Prakash/* DO NOT EDIT
4051e66a47SVivek Prakash * Automatically generated from termcap.c */
4151e66a47SVivek Prakash
4251e66a47SVivek Prakash#include <stdint.h>
4351e66a47SVivek Prakash#include <stdlib.h>
4451e66a47SVivek Prakash#include <term_private.h>
4551e66a47SVivek Prakash
4651e66a47SVivek PrakashEOF
4751e66a47SVivek Prakash
4851e66a47SVivek Prakash$TOOL_SED -n -e "1,/_ti_cap_flagids/d" -e '/};/,$d' \
4951e66a47SVivek Prakash	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
50*0c3ae37fSLionel Sambuc	$TOOL_NBPERF -p -s -n _t_flaghash
5151e66a47SVivek Prakashecho
5251e66a47SVivek Prakash$TOOL_SED -n -e "1,/_ti_cap_numids/d" -e '/};/,$d' \
5351e66a47SVivek Prakash	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
54*0c3ae37fSLionel Sambuc	$TOOL_NBPERF -p -s -n _t_numhash
5551e66a47SVivek Prakashecho
5651e66a47SVivek Prakash$TOOL_SED -n -e "1,/_ti_cap_strids/d" -e '/};/,$d' \
5751e66a47SVivek Prakash	-e 's/.*"\([^"]*\)".*/\1/p' $TERMCAPC | \
58*0c3ae37fSLionel Sambuc	$TOOL_NBPERF -p -s -n _t_strhash
59