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