1132718Skan#! /bin/sh
2169689Skan##############################################################################
3132718Skan# Copyright 2019-2020,2021 Thomas E. Dickey                                  #
4132718Skan# Copyright 1998-2015,2017 Free Software Foundation, Inc.                    #
5132718Skan#                                                                            #
6132718Skan# Permission is hereby granted, free of charge, to any person obtaining a    #
7132718Skan# copy of this software and associated documentation files (the "Software"), #
8132718Skan# to deal in the Software without restriction, including without limitation  #
9132718Skan# the rights to use, copy, modify, merge, publish, distribute, distribute    #
10132718Skan# with modifications, sublicense, and/or sell copies of the Software, and to #
11132718Skan# permit persons to whom the Software is furnished to do so, subject to the  #
12132718Skan# following conditions:                                                      #
13132718Skan#                                                                            #
14132718Skan# The above copyright notice and this permission notice shall be included in #
15132718Skan# all copies or substantial portions of the Software.                        #
16132718Skan#                                                                            #
17132718Skan# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18169689Skan# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19169689Skan# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20132718Skan# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21132718Skan# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22132718Skan# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23132718Skan# DEALINGS IN THE SOFTWARE.                                                  #
24132718Skan#                                                                            #
25132718Skan# Except as contained in this notice, the name(s) of the above copyright     #
26132718Skan# holders shall not be used in advertising or otherwise to promote the sale, #
27169689Skan# use or other dealings in this Software without prior written               #
28132718Skan# authorization.                                                             #
29132718Skan##############################################################################
30132718Skan#
31132718Skan# Author: Thomas E. Dickey, 1997-on
32132718Skan#
33169689Skan# $Id: MKexpanded.sh,v 1.24 2022/02/05 17:27:18 tom Exp $
34132718Skan#
35132718Skan# Script to generate 'expanded.c', a dummy source that contains functions
36169689Skan# corresponding to complex macros used in this library.  By making functions,
37132718Skan# we simplify analysis and debugging.
38132718Skan
39132718Skanif test $# != 0; then
40132718Skanpreprocessor="$1"
41132718Skanelse
42132718Skanpreprocessor="cc -E"
43132718Skanfi
44132718Skanshift
45132718Skanif test $# != 0 ; then
46132718Skan	preprocessor="$preprocessor $*"
47132718Skanelse
48132718Skan	preprocessor="$preprocessor -DHAVE_CONFIG_H -I. -I../include"
49132718Skanfi
50132718Skan
51132718SkanTMP=gen$$.c
52132718Skantrap "rm -f $TMP; exit 1" 1 2 3 15
53169689Skantrap "rm -f $TMP" 0
54132718Skan
55169689Skancat <<EOF
56132718Skan/* generated by MKexpanded.sh */
57169689Skan#define NEED_NCURSES_CH_T 1
58169689Skan#include <curses.priv.h>
59169689Skan
60169689Skan#ifndef CUR
61169689Skan#define CUR SP_TERMTYPE
62132718Skan#endif
63169689Skan
64169689Skan#if NCURSES_EXPANDED
65169689SkanEOF
66132718Skan
67169689Skancat >$TMP <<EOF
68169689Skan#include <ncurses_cfg.h>
69169689Skan#undef NCURSES_EXPANDED /* this probably is set in ncurses_cfg.h */
70169689Skan#include <curses.priv.h>
71169689Skan/* these are names we'd like to see */
72169689Skan#undef ALL_BUT_COLOR
73132718Skan#undef PAIR_NUMBER
74169689Skan#undef TRUE
75132718Skan#undef FALSE
76169689Skan/* this is a marker */
77132718SkanIGNORE
78169689SkanNCURSES_EXPORT(void)
79169689Skan_nc_toggle_attr_on (attr_t *S, attr_t at)
80169689Skan{
81132718Skan	toggle_attr_on(*S,at);
82132718Skan}
83169689Skan
84132718SkanNCURSES_EXPORT(void)
85169689Skan_nc_toggle_attr_off (attr_t *S, attr_t at)
86132718Skan{
87169689Skan	toggle_attr_off(*S,at);
88169689Skan}
89132718Skan
90132718SkanNCURSES_EXPORT(int)
91169689SkanNCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int count)
92132718Skan{
93169689Skan	return DelCharCost(SP_PARM, count);
94132718Skan}
95169689Skan
96169689SkanNCURSES_EXPORT(int)
97169689SkanNCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int count)
98132718Skan{
99169689Skan	return InsCharCost(SP_PARM, count);
100169689Skan}
101169689Skan
102169689SkanNCURSES_EXPORT(void)
103132718SkanNCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T c)
104169689Skan{
105169689Skan	UpdateAttrs(SP_PARM, CHDEREF(c));
106169689Skan}
107169689Skan
108132718Skan@if_NCURSES_SP_FUNCS
109132718SkanNCURSES_EXPORT(int)
110132718Skan_nc_DelCharCost (int count)
111169689Skan{
112132718Skan	return NCURSES_SP_NAME(_nc_DelCharCost) (CURRENT_SCREEN, count);
113169689Skan}
114169689Skan
115132718SkanNCURSES_EXPORT(int)
116169689Skan_nc_InsCharCost (int count)
117132718Skan{
118169689Skan	return NCURSES_SP_NAME(_nc_InsCharCost)(CURRENT_SCREEN, count);
119169689Skan}
120132718Skan
121169689SkanNCURSES_EXPORT(void)
122132718Skan_nc_UpdateAttrs (CARG_CH_T c)
123132718Skan{
124169689Skan	NCURSES_SP_NAME(_nc_UpdateAttrs)(CURRENT_SCREEN,c);
125132718Skan}
126169689Skan@endif
127169689SkanEOF
128132718Skan
129169689Skan$preprocessor $TMP 2>/dev/null | \
130132718Skan	sed -e '1,/^IGNORE$/d' -e 's/^@/#/' -e 's/^#[ 	]*if_/#if /' -e "s,$TMP,expanded.c,"
131169689Skan
132169689Skancat <<EOF
133169689Skan#else /* ! NCURSES_EXPANDED */
134132718SkanNCURSES_EXPORT(void) _nc_expanded (void) { }
135169689Skan#endif /* NCURSES_EXPANDED */
136169689SkanEOF
137132718Skan