xref: /freebsd/contrib/ncurses/include/MKparametrized.sh (revision aae38d10b4eebf81c0942947e8b83a9bb8651d88)
10e3d5408SPeter Wemm#!/bin/sh
24a1a9510SRong-En Fan##############################################################################
3*aae38d10SBaptiste Daroussin# Copyright (c) 1998-2017,2019 Free Software Foundation, Inc.                #
44a1a9510SRong-En Fan#                                                                            #
54a1a9510SRong-En Fan# Permission is hereby granted, free of charge, to any person obtaining a    #
64a1a9510SRong-En Fan# copy of this software and associated documentation files (the "Software"), #
74a1a9510SRong-En Fan# to deal in the Software without restriction, including without limitation  #
84a1a9510SRong-En Fan# the rights to use, copy, modify, merge, publish, distribute, distribute    #
94a1a9510SRong-En Fan# with modifications, sublicense, and/or sell copies of the Software, and to #
104a1a9510SRong-En Fan# permit persons to whom the Software is furnished to do so, subject to the  #
114a1a9510SRong-En Fan# following conditions:                                                      #
124a1a9510SRong-En Fan#                                                                            #
134a1a9510SRong-En Fan# The above copyright notice and this permission notice shall be included in #
144a1a9510SRong-En Fan# all copies or substantial portions of the Software.                        #
154a1a9510SRong-En Fan#                                                                            #
164a1a9510SRong-En Fan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
174a1a9510SRong-En Fan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
184a1a9510SRong-En Fan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
194a1a9510SRong-En Fan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
204a1a9510SRong-En Fan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
214a1a9510SRong-En Fan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
224a1a9510SRong-En Fan# DEALINGS IN THE SOFTWARE.                                                  #
234a1a9510SRong-En Fan#                                                                            #
244a1a9510SRong-En Fan# Except as contained in this notice, the name(s) of the above copyright     #
254a1a9510SRong-En Fan# holders shall not be used in advertising or otherwise to promote the sale, #
264a1a9510SRong-En Fan# use or other dealings in this Software without prior written               #
274a1a9510SRong-En Fan# authorization.                                                             #
284a1a9510SRong-En Fan##############################################################################
29*aae38d10SBaptiste Daroussin# $Id: MKparametrized.sh,v 1.9 2019/04/13 20:36:24 tom Exp $
300e3d5408SPeter Wemm#
310e3d5408SPeter Wemm# MKparametrized.sh -- generate indirection vectors for various sort methods
320e3d5408SPeter Wemm#
330e3d5408SPeter Wemm# The output of this script is C source for an array specifying whether
340e3d5408SPeter Wemm# termcap strings should undergo parameter and padding translation.
350e3d5408SPeter Wemm#
36*aae38d10SBaptiste Daroussin[ $# = 0 ] && set - Caps
37*aae38d10SBaptiste Daroussin
380e3d5408SPeter Wemmcat <<EOF
39*aae38d10SBaptiste Daroussin#ifndef PARAMETRIZED_H
40*aae38d10SBaptiste Daroussin#define PARAMETRIZED_H 1
410e3d5408SPeter Wemm/*
420e3d5408SPeter Wemm * parametrized.h --- is a termcap capability parametrized?
430e3d5408SPeter Wemm *
4418259542SPeter Wemm * Note: this file is generated using MKparametrized.sh, do not edit by hand.
450e3d5408SPeter Wemm * A value of -1 in the table means suppress both pad and % translations.
460e3d5408SPeter Wemm * A value of 0 in the table means do pad but not % translations.
470e3d5408SPeter Wemm * A value of 1 in the table means do both pad and % translations.
480e3d5408SPeter Wemm */
490e3d5408SPeter Wemm
500e3d5408SPeter Wemmstatic short const parametrized[] = {
510e3d5408SPeter WemmEOF
520e3d5408SPeter Wemm
530e3d5408SPeter Wemm# We detect whether % translations should be done by looking for #[0-9] in the
540e3d5408SPeter Wemm# description field.  We presently suppress padding translation only for the
550e3d5408SPeter Wemm# XENIX acs_* capabilities.  Maybe someday we'll dedicate a flag field for
560e3d5408SPeter Wemm# this, that would be cleaner....
570e3d5408SPeter Wemm
58*aae38d10SBaptiste Daroussincat "$@" | ${AWK-awk} '
59*aae38d10SBaptiste Daroussin
60*aae38d10SBaptiste Daroussin/^#/ { next ; }
61*aae38d10SBaptiste Daroussin/^capalias/ { next ; }
62*aae38d10SBaptiste Daroussin/^infoalias/ { next ; }
63*aae38d10SBaptiste Daroussin/^used_by/ { next ; }
64*aae38d10SBaptiste Daroussin/^userdef/ { next ; }
65*aae38d10SBaptiste Daroussin
660e3d5408SPeter Wemm$3 != "str"		{next;}
670e3d5408SPeter Wemm$1 ~ /^acs_/		{print "-1,\t/* ", $2, " */"; count++; next;}
68*aae38d10SBaptiste Daroussin$1 ~ /^label_format/	{print "-1,\t/* ", $2, " */"; count++; next;}
690e3d5408SPeter Wemm$0 ~ /#[0-9]/		{print "1,\t/* ", $2, " */"; count++; next;}
700e3d5408SPeter Wemm			{print "0,\t/* ", $2, " */"; count++;}
710e3d5408SPeter WemmEND			{printf("} /* %d entries */;\n\n", count);}
720e3d5408SPeter Wemm'
730e3d5408SPeter Wemm
74*aae38d10SBaptiste Daroussinecho "#endif /* PARAMETRIZED_H */"
75