X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2FMKlib_gen.sh;h=0a29c6085f62bad34fa6571e7a46ae2b437e8a70;hp=a08dc0a0c45709db782997f52129eb2ecae7b46b;hb=refs%2Ftags%2Fv4.2;hpb=3a9b6a3bf0269231bef7de74757a910dedd04e0c diff --git a/ncurses/MKlib_gen.sh b/ncurses/MKlib_gen.sh index a08dc0a0..0a29c608 100755 --- a/ncurses/MKlib_gen.sh +++ b/ncurses/MKlib_gen.sh @@ -2,7 +2,7 @@ # # MKlib_gen.sh -- generate sources from curses.h macro definitions # -# ($Id: MKlib_gen.sh,v 1.9 1997/05/10 23:48:19 tom Exp $) +# ($Id: MKlib_gen.sh,v 1.11 1998/01/17 14:16:52 Juan.Jose.Garcia.Ripoll Exp $) # # The XSI Curses standard requires all curses entry points to exist as # functions, even though many definitions would normally be shadowed @@ -28,8 +28,12 @@ preprocessor="$1 -I../include" AWK="$2" +ED1=sed1$$.sed +ED2=sed2$$.sed +ED3=sed3$$.sed +AW1=awk1$$.awk TMP=gen$$.c -trap "rm -f $TMP" 0 1 2 5 15 +trap "rm -f $ED1 $ED2 $ED3 $AW1 $TMP" 0 1 2 5 15 (cat < @@ -38,32 +42,76 @@ trap "rm -f $TMP" 0 1 2 5 15 DECLARATIONS EOF -sed -n -e "/^extern.*generated/s/^extern \([^;]*\);.*/\1/p" \ -| sed \ - -e "/(void)/b nc" \ - -e "s/,/ a1% /" \ - -e "s/,/ a2% /" \ - -e "s/,/ a3% /" \ - -e "s/,/ a4% /" \ - -e "s/,/ a5% /" \ - -e "s/,/ a6% /" \ - -e "s/,/ a7% /" \ - -e "s/,/ a8% /" \ - -e "s/,/ a9% /" \ - -e "s/,/ a10% /" \ - -e "s/,/ a11% /" \ - -e "s/,/ a12% /" \ - -e "s/,/ a13% /" \ - -e "s/,/ a14% /" \ - -e "s/,/ a15% /" \ - -e "s/*/ * /g" \ - -e "s/%/ , /g" \ - -e "s/)/ z)/" \ - -e ":nc" \ - -e "/(/s// ( /" \ - -e "s/)/ )/" \ -| $AWK '{ - print "\n" +cat >$ED1 <$ED2 <$ED3 <$AW1 <<\EOF1 +BEGIN { + skip=0; + } + /^P_#if/ { + print "\n" + print $0 + skip=0; + } + /^P_#endif/ { + print $0 + skip=1; + } + $0 !~ /^P_/ { + if (skip) + print "\n" + skip=1; print "M_" $2 print $0; @@ -171,7 +219,10 @@ sed -n -e "/^extern.*generated/s/^extern \([^;]*\);.*/\1/p" \ print "%%returnVoid;" print "}"; } -' ) \ +EOF1 + +sed -n -f $ED1 | sed -f $ED2 \ +| $AWK -f $AW1 ) \ | sed \ -e '/^\([a-z_][a-z_]*\) /s//\1 gen_/' >$TMP $preprocessor $TMP 2>/dev/null \ @@ -182,15 +233,13 @@ BEGIN { print " * It is generated by MKlib_gen.sh." print " *" print " * This is a file of trivial functions generated from macro" - print " * definitions in curses.h in order to satisfy the XSI Curses" - print " * requirement that every macro also exist as a callable" - print " * function." + print " * definitions in curses.h to satisfy the XSI Curses requirement" + print " * that every macro also exist as a callable function." print " *" print " * It will never be linked unless you call one of the entry" print " * points with its normal macro definition disabled. In that" print " * case, if you have no shared libraries, it will indirectly" print " * pull most of the rest of the library into your link image." - print " * Cope with it." print " */" print "#include " print "" @@ -198,14 +247,7 @@ BEGIN { /^DECLARATIONS/ {start = 1; next;} {if (start) print $0;} ' \ -| sed \ - -e 's/ */ /g' \ - -e 's/ */ /g' \ - -e 's/ ,/,/g' \ - -e 's/ )/)/g' \ - -e 's/ gen_/ /' \ - -e 's/^M_/#undef /' \ - -e '/^%%/s// /' \ +| sed -f $ED3 \ | sed \ -e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \ -e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/'