]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/tty/MKexpanded.sh
65c6b93e46274e12f1131abcfb032b7899973b16
[ncurses.git] / ncurses / tty / MKexpanded.sh
1 #! /bin/sh
2 ##############################################################################
3 # Copyright 2019,2020 Thomas E. Dickey                                       #
4 # Copyright 1998-2015,2017 Free Software Foundation, Inc.                    #
5 #                                                                            #
6 # Permission is hereby granted, free of charge, to any person obtaining a    #
7 # copy of this software and associated documentation files (the "Software"), #
8 # to deal in the Software without restriction, including without limitation  #
9 # the rights to use, copy, modify, merge, publish, distribute, distribute    #
10 # with modifications, sublicense, and/or sell copies of the Software, and to #
11 # permit persons to whom the Software is furnished to do so, subject to the  #
12 # following conditions:                                                      #
13 #                                                                            #
14 # The above copyright notice and this permission notice shall be included in #
15 # all copies or substantial portions of the Software.                        #
16 #                                                                            #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23 # DEALINGS IN THE SOFTWARE.                                                  #
24 #                                                                            #
25 # Except as contained in this notice, the name(s) of the above copyright     #
26 # holders shall not be used in advertising or otherwise to promote the sale, #
27 # use or other dealings in this Software without prior written               #
28 # authorization.                                                             #
29 ##############################################################################
30 #
31 # Author: Thomas E. Dickey, 1997-on
32 #
33 # $Id: MKexpanded.sh,v 1.22 2020/02/02 23:34:34 tom Exp $
34 #
35 # Script to generate 'expanded.c', a dummy source that contains functions
36 # corresponding to complex macros used in this library.  By making functions,
37 # we simplify analysis and debugging.
38
39 if test $# != 0; then
40 preprocessor="$1"
41 else
42 preprocessor="cc -E"
43 fi
44 shift
45 if test $# != 0 ; then
46         preprocessor="$preprocessor $*"
47 else
48         preprocessor="$preprocessor -DHAVE_CONFIG_H -I. -I../include"
49 fi
50
51 TMP=gen$$.c
52 trap "rm -f $TMP" EXIT INT QUIT TERM HUP
53
54 cat <<EOF
55 /* generated by MKexpanded.sh */
56 #define NEED_NCURSES_CH_T 1
57 #include <curses.priv.h>
58
59 #ifndef CUR
60 #define CUR SP_TERMTYPE
61 #endif
62
63 #if NCURSES_EXPANDED
64 EOF
65
66 cat >$TMP <<EOF
67 #include <ncurses_cfg.h>
68 #undef NCURSES_EXPANDED /* this probably is set in ncurses_cfg.h */
69 #include <curses.priv.h>
70 /* these are names we'd like to see */
71 #undef ALL_BUT_COLOR
72 #undef PAIR_NUMBER
73 #undef TRUE
74 #undef FALSE
75 /* this is a marker */
76 IGNORE
77 NCURSES_EXPORT(void)
78 _nc_toggle_attr_on (attr_t *S, attr_t at)
79 {
80         toggle_attr_on(*S,at);
81 }
82
83 NCURSES_EXPORT(void)
84 _nc_toggle_attr_off (attr_t *S, attr_t at) 
85 {
86         toggle_attr_off(*S,at);
87 }
88
89 NCURSES_EXPORT(int)
90 NCURSES_SP_NAME(_nc_DelCharCost) (NCURSES_SP_DCLx int count)
91 {
92         return DelCharCost(SP_PARM, count);
93 }
94
95 NCURSES_EXPORT(int)
96 NCURSES_SP_NAME(_nc_InsCharCost) (NCURSES_SP_DCLx int count)
97 {
98         return InsCharCost(SP_PARM, count);
99 }
100
101 NCURSES_EXPORT(void)
102 NCURSES_SP_NAME(_nc_UpdateAttrs) (NCURSES_SP_DCLx CARG_CH_T c)
103 {
104         UpdateAttrs(SP_PARM, CHDEREF(c));
105 }
106
107 @if_NCURSES_SP_FUNCS
108 NCURSES_EXPORT(int)
109 _nc_DelCharCost (int count)
110 {
111         return NCURSES_SP_NAME(_nc_DelCharCost) (CURRENT_SCREEN, count);
112 }
113
114 NCURSES_EXPORT(int)
115 _nc_InsCharCost (int count)
116 {
117         return NCURSES_SP_NAME(_nc_InsCharCost)(CURRENT_SCREEN, count);
118 }
119
120 NCURSES_EXPORT(void)
121 _nc_UpdateAttrs (CARG_CH_T c)
122 {
123         NCURSES_SP_NAME(_nc_UpdateAttrs)(CURRENT_SCREEN,c);
124 }
125 @endif
126 EOF
127
128 $preprocessor $TMP 2>/dev/null | \
129         sed -e '1,/^IGNORE$/d' -e 's/^@/#/' -e 's/^#[   ]*if_/#if /' -e "s,$TMP,expanded.c,"
130
131 cat <<EOF
132 #else /* ! NCURSES_EXPANDED */
133 NCURSES_EXPORT(void) _nc_expanded (void) { }
134 #endif /* NCURSES_EXPANDED */
135 EOF