From 8e6697fcd9da32e42e206cc6012f18d3328d2f12 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 14 Jun 2000 22:28:16 +0000 Subject: Update include scripts --- src/tools/pginclude/README | 10 ++++++ src/tools/pginclude/pgdefine | 2 ++ src/tools/pginclude/pgfixinclude | 2 +- src/tools/pginclude/pginclude | 3 +- src/tools/pginclude/pgnoinclude | 66 ---------------------------------------- src/tools/pginclude/pgrminclude | 66 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 68 deletions(-) create mode 100644 src/tools/pginclude/README delete mode 100755 src/tools/pginclude/pgnoinclude create mode 100755 src/tools/pginclude/pgrminclude (limited to 'src') diff --git a/src/tools/pginclude/README b/src/tools/pginclude/README new file mode 100644 index 00000000000..9ed3ebae97b --- /dev/null +++ b/src/tools/pginclude/README @@ -0,0 +1,10 @@ +These utilities help clean up #include file usage: + +pgfixinclude change #include's to <> or "" +pgrminclude remove extra #include's +pginclude [-v] report which #include files can not compile on their own + +pgdefine create macro calls for all defines in the file (used by + the above routines) + + diff --git a/src/tools/pginclude/pgdefine b/src/tools/pginclude/pgdefine index 3411c358561..953a29684a1 100755 --- a/src/tools/pginclude/pgdefine +++ b/src/tools/pginclude/pgdefine @@ -1,4 +1,6 @@ : +# create macro calls for all defines in the file + trap "rm -f /tmp/$$" 0 1 2 3 15 for FILE do diff --git a/src/tools/pginclude/pgfixinclude b/src/tools/pginclude/pgfixinclude index 6e70ad696c6..d76710a0624 100755 --- a/src/tools/pginclude/pgfixinclude +++ b/src/tools/pginclude/pgfixinclude @@ -1,5 +1,5 @@ : -# mark includes as <> or "" +# change #include's to <> or "" trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15 find . \( -name CVS -a -prune \) -o -type f -print | diff --git a/src/tools/pginclude/pginclude b/src/tools/pginclude/pginclude index b7b0449e7d0..4658d48b38b 100755 --- a/src/tools/pginclude/pginclude +++ b/src/tools/pginclude/pginclude @@ -1,5 +1,6 @@ : -# report which include files can not compile on their own +# report which #include files can not compile on their own +# takes -v option to display compile failure message and line numbers trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a" 0 1 2 3 15 find . \( -name CVS -a -prune \) -o -name '*.[ch]' -type f -print | while read FILE diff --git a/src/tools/pginclude/pgnoinclude b/src/tools/pginclude/pgnoinclude deleted file mode 100755 index 29dc60bc272..00000000000 --- a/src/tools/pginclude/pgnoinclude +++ /dev/null @@ -1,66 +0,0 @@ -: -# report which files have extra includes - -trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15 -find . \( -name CVS -a -prune \) -o -type f -print | -grep -v '\./postgres.h' | -grep -v '\./config.h' | -grep -v '\./c.h' | -while read FILE -do - if [ "`echo $FILE | sed -n 's/^.*\.\([^\.]*\)$/\1/p'`" = "h" ] - then IS_INCLUDE="Y" - else IS_INCLUDE="N" - fi - - if [ "$IS_INCLUDE" = "Y" ] - then cat "$FILE" | grep -v "^#if" | grep -v "^#else" | - grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a - else cat "$FILE" >/tmp/$$a - fi - cat /tmp/$$a | grep "^#include" | - sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' | - while read INCLUDE - do - [ -s /usr/include/$INCLUDE ] && continue - [ "$INCLUDE" = postgres.h ] && continue - [ "$INCLUDE" = config.h ] && continue - [ "$INCLUDE" = c.h ] && continue - # preserve configure-specific includes - grep -B1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | - egrep -q '^#if|^#else' && continue - grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | - egrep -q '^#else|^#endif' && continue - cat /tmp/$$a | - grep -v '^#include[ ]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b - if [ "$IS_INCLUDE" = "Y" ] - then echo "#include \"postgres.h\"" >/tmp/$$.c - else >/tmp/$$.c - fi - echo "#include \"/tmp/$$b\"" >>/tmp/$$.c - echo "void include_test(void);" >>/tmp/$$.c - echo "void include_test() {" >>/tmp/$$.c - if [ "$IS_INCLUDE" = "Y" ] - then pgdefine "$FILE" >>/tmp/$$.c - fi - echo "}" >>/tmp/$$.c - cc -fsyntax-only -Werror -Wall -Wmissing-prototypes -Wmissing-declarations -I/pg/include -I/pg/backend -c /tmp/$$.c -o /tmp/$$.o >/tmp/$$ 2>&1 - if [ "$?" -eq 0 ] - then echo "$FILE $INCLUDE" - if [ "$IS_INCLUDE" = "N" ] - then grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" >/tmp/$$b - mv /tmp/$$b "$FILE" - # reload after #include removal - if [ "$IS_INCLUDE" = "Y" ] - then cat "$FILE" | grep -v "^#if" | grep -v "^#else" | - grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a - else cat "$FILE" >/tmp/$$a - fi - fi - if [ "$1" = "-v" ] - then cat /tmp/$$ - cat /tmp/$$.c - fi - fi - done -done diff --git a/src/tools/pginclude/pgrminclude b/src/tools/pginclude/pgrminclude new file mode 100755 index 00000000000..e91997bc3f5 --- /dev/null +++ b/src/tools/pginclude/pgrminclude @@ -0,0 +1,66 @@ +: +# remove extra #include's + +trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15 +find . \( -name CVS -a -prune \) -o -type f -print | +grep -v '\./postgres.h' | +grep -v '\./config.h' | +grep -v '\./c.h' | +while read FILE +do + if [ "`echo $FILE | sed -n 's/^.*\.\([^\.]*\)$/\1/p'`" = "h" ] + then IS_INCLUDE="Y" + else IS_INCLUDE="N" + fi + + if [ "$IS_INCLUDE" = "Y" ] + then cat "$FILE" | grep -v "^#if" | grep -v "^#else" | + grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a + else cat "$FILE" >/tmp/$$a + fi + cat /tmp/$$a | grep "^#include" | + sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' | + while read INCLUDE + do + [ -s /usr/include/$INCLUDE ] && continue + [ "$INCLUDE" = postgres.h ] && continue + [ "$INCLUDE" = config.h ] && continue + [ "$INCLUDE" = c.h ] && continue + # preserve configure-specific includes + grep -B1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | + egrep -q '^#if|^#else' && continue + grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | + egrep -q '^#else|^#endif' && continue + cat /tmp/$$a | + grep -v '^#include[ ]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b + if [ "$IS_INCLUDE" = "Y" ] + then echo "#include \"postgres.h\"" >/tmp/$$.c + else >/tmp/$$.c + fi + echo "#include \"/tmp/$$b\"" >>/tmp/$$.c + echo "void include_test(void);" >>/tmp/$$.c + echo "void include_test() {" >>/tmp/$$.c + if [ "$IS_INCLUDE" = "Y" ] + then pgdefine "$FILE" >>/tmp/$$.c + fi + echo "}" >>/tmp/$$.c + cc -fsyntax-only -Werror -Wall -Wmissing-prototypes -Wmissing-declarations -I/pg/include -I/pg/backend -c /tmp/$$.c -o /tmp/$$.o >/tmp/$$ 2>&1 + if [ "$?" -eq 0 ] + then echo "$FILE $INCLUDE" + if [ "$IS_INCLUDE" = "N" ] + then grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" >/tmp/$$b + mv /tmp/$$b "$FILE" + # reload after #include removal + if [ "$IS_INCLUDE" = "Y" ] + then cat "$FILE" | grep -v "^#if" | grep -v "^#else" | + grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a + else cat "$FILE" >/tmp/$$a + fi + fi + if [ "$1" = "-v" ] + then cat /tmp/$$ + cat /tmp/$$.c + fi + fi + done +done -- cgit v1.2.3