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