xref: /openbsd/lib/libcurses/tty/MKexpanded.sh (revision c7ef0cfc)
1*c7ef0cfcSnicm# $OpenBSD: MKexpanded.sh,v 1.5 2023/10/17 09:52:09 nicm Exp $
292dd1ec0Smillert#! /bin/sh
392dd1ec0Smillert##############################################################################
4*c7ef0cfcSnicm# Copyright 2019-2020,2021 Thomas E. Dickey                                  #
5*c7ef0cfcSnicm# Copyright 1998-2015,2017 Free Software Foundation, Inc.                    #
692dd1ec0Smillert#                                                                            #
792dd1ec0Smillert# Permission is hereby granted, free of charge, to any person obtaining a    #
892dd1ec0Smillert# copy of this software and associated documentation files (the "Software"), #
992dd1ec0Smillert# to deal in the Software without restriction, including without limitation  #
1092dd1ec0Smillert# the rights to use, copy, modify, merge, publish, distribute, distribute    #
1192dd1ec0Smillert# with modifications, sublicense, and/or sell copies of the Software, and to #
1292dd1ec0Smillert# permit persons to whom the Software is furnished to do so, subject to the  #
1392dd1ec0Smillert# following conditions:                                                      #
1492dd1ec0Smillert#                                                                            #
1592dd1ec0Smillert# The above copyright notice and this permission notice shall be included in #
1692dd1ec0Smillert# all copies or substantial portions of the Software.                        #
1792dd1ec0Smillert#                                                                            #
1892dd1ec0Smillert# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
1992dd1ec0Smillert# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
2092dd1ec0Smillert# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
2192dd1ec0Smillert# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
2292dd1ec0Smillert# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
2392dd1ec0Smillert# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
2492dd1ec0Smillert# DEALINGS IN THE SOFTWARE.                                                  #
2592dd1ec0Smillert#                                                                            #
2692dd1ec0Smillert# Except as contained in this notice, the name(s) of the above copyright     #
2792dd1ec0Smillert# holders shall not be used in advertising or otherwise to promote the sale, #
2892dd1ec0Smillert# use or other dealings in this Software without prior written               #
2992dd1ec0Smillert# authorization.                                                             #
3092dd1ec0Smillert##############################################################################
3192dd1ec0Smillert#
32*c7ef0cfcSnicm# Author: Thomas E. Dickey, 1997-on
3392dd1ec0Smillert#
34*c7ef0cfcSnicm# $Id: MKexpanded.sh,v 1.5 2023/10/17 09:52:09 nicm Exp $
3592dd1ec0Smillert#
3692dd1ec0Smillert# Script to generate 'expanded.c', a dummy source that contains functions
3792dd1ec0Smillert# corresponding to complex macros used in this library.  By making functions,
3892dd1ec0Smillert# we simplify analysis and debugging.
3992dd1ec0Smillert
4092dd1ec0Smillertif test $# != 0; then
4192dd1ec0Smillertpreprocessor="$1"
4292dd1ec0Smillertelse
4392dd1ec0Smillertpreprocessor="cc -E"
4492dd1ec0Smillertfi
4592dd1ec0Smillertshift
4692dd1ec0Smillertif test $# != 0 ; then
4792dd1ec0Smillert	preprocessor="$preprocessor $*"
4892dd1ec0Smillertelse
4992dd1ec0Smillert	preprocessor="$preprocessor -DHAVE_CONFIG_H -I. -I../include"
5092dd1ec0Smillertfi
5192dd1ec0Smillert
5292dd1ec0SmillertTMP=gen$$.c
53*c7ef0cfcSnicmtrap "rm -f $TMP; exit 1" 1 2 3 15
54*c7ef0cfcSnicmtrap "rm -f $TMP" 0
5592dd1ec0Smillert
5692dd1ec0Smillertcat <<EOF
5792dd1ec0Smillert/* generated by MKexpanded.sh */
58*c7ef0cfcSnicm#define NEED_NCURSES_CH_T 1
5992dd1ec0Smillert#include <curses.priv.h>
60*c7ef0cfcSnicm
61*c7ef0cfcSnicm#ifndef CUR
62*c7ef0cfcSnicm#define CUR SP_TERMTYPE
63*c7ef0cfcSnicm#endif
64*c7ef0cfcSnicm
6591421ef5Smillert#if NCURSES_EXPANDED
6692dd1ec0SmillertEOF
6792dd1ec0Smillert
6892dd1ec0Smillertcat >$TMP <<EOF
6992dd1ec0Smillert#include <ncurses_cfg.h>
7092dd1ec0Smillert#undef NCURSES_EXPANDED /* this probably is set in ncurses_cfg.h */
7192dd1ec0Smillert#include <curses.priv.h>
7292dd1ec0Smillert/* these are names we'd like to see */
7392dd1ec0Smillert#undef ALL_BUT_COLOR
7492dd1ec0Smillert#undef PAIR_NUMBER
7592dd1ec0Smillert#undef TRUE
7692dd1ec0Smillert#undef FALSE
7792dd1ec0Smillert/* this is a marker */
7892dd1ec0SmillertIGNORE
79*c7ef0cfcSnicmNCURSES_EXPORT(void)
80*c7ef0cfcSnicm_nc_toggle_attr_on (attr_t *S, attr_t at)
8192dd1ec0Smillert{
8292dd1ec0Smillert	toggle_attr_on(*S,at);
8392dd1ec0Smillert}
84*c7ef0cfcSnicm
85*c7ef0cfcSnicmNCURSES_EXPORT(void)
86*c7ef0cfcSnicm_nc_toggle_attr_off (attr_t *S, attr_t at)
8792dd1ec0Smillert{
8892dd1ec0Smillert	toggle_attr_off(*S,at);
8992dd1ec0Smillert}
90*c7ef0cfcSnicm
91*c7ef0cfcSnicmNCURSES_EXPORT(int)
92*c7ef0cfcSnicmNCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int count)
9392dd1ec0Smillert{
94*c7ef0cfcSnicm	return DelCharCost(SP_PARM, count);
9592dd1ec0Smillert}
96*c7ef0cfcSnicm
97*c7ef0cfcSnicmNCURSES_EXPORT(int)
98*c7ef0cfcSnicmNCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int count)
9992dd1ec0Smillert{
100*c7ef0cfcSnicm	return InsCharCost(SP_PARM, count);
10192dd1ec0Smillert}
102*c7ef0cfcSnicm
103*c7ef0cfcSnicmNCURSES_EXPORT(void)
104*c7ef0cfcSnicmNCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T c)
10592dd1ec0Smillert{
106*c7ef0cfcSnicm	UpdateAttrs(SP_PARM, CHDEREF(c));
10792dd1ec0Smillert}
108*c7ef0cfcSnicm
109*c7ef0cfcSnicm@if_NCURSES_SP_FUNCS
110*c7ef0cfcSnicmNCURSES_EXPORT(int)
111*c7ef0cfcSnicm_nc_DelCharCost (int count)
112*c7ef0cfcSnicm{
113*c7ef0cfcSnicm	return NCURSES_SP_NAME(_nc_DelCharCost) (CURRENT_SCREEN, count);
114*c7ef0cfcSnicm}
115*c7ef0cfcSnicm
116*c7ef0cfcSnicmNCURSES_EXPORT(int)
117*c7ef0cfcSnicm_nc_InsCharCost (int count)
118*c7ef0cfcSnicm{
119*c7ef0cfcSnicm	return NCURSES_SP_NAME(_nc_InsCharCost)(CURRENT_SCREEN, count);
120*c7ef0cfcSnicm}
121*c7ef0cfcSnicm
122*c7ef0cfcSnicmNCURSES_EXPORT(void)
123*c7ef0cfcSnicm_nc_UpdateAttrs (CARG_CH_T c)
124*c7ef0cfcSnicm{
125*c7ef0cfcSnicm	NCURSES_SP_NAME(_nc_UpdateAttrs)(CURRENT_SCREEN,c);
126*c7ef0cfcSnicm}
127*c7ef0cfcSnicm@endif
12892dd1ec0SmillertEOF
12992dd1ec0Smillert
130*c7ef0cfcSnicm$preprocessor $TMP 2>/dev/null | \
131*c7ef0cfcSnicm	sed -e '1,/^IGNORE$/d' -e 's/^@/#/' -e 's/^#[ 	]*if_/#if /' -e "s,$TMP,expanded.c,"
13292dd1ec0Smillert
13392dd1ec0Smillertcat <<EOF
13492dd1ec0Smillert#else /* ! NCURSES_EXPANDED */
13584af20ceSmillertNCURSES_EXPORT(void) _nc_expanded (void) { }
13692dd1ec0Smillert#endif /* NCURSES_EXPANDED */
13792dd1ec0SmillertEOF
138