diff options
author | Bruce Momjian | 2006-07-12 16:28:27 +0000 |
---|---|---|
committer | Bruce Momjian | 2006-07-12 16:28:27 +0000 |
commit | 313b2bb7bd361485db91166aa785d49cf95b80f0 (patch) | |
tree | 7309466b4b5d8ecda28cb77aa2a58d09051a5693 | |
parent | e336fa87127f7a76c307b79b230ad27adb98a21a (diff) |
Fix pgrminclude to work for stripping include files.
-rwxr-xr-x | src/tools/pginclude/pgrminclude | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/tools/pginclude/pgrminclude b/src/tools/pginclude/pgrminclude index 97ab5a3646..1421015595 100755 --- a/src/tools/pginclude/pgrminclude +++ b/src/tools/pginclude/pgrminclude @@ -15,18 +15,15 @@ do else IS_INCLUDE="N" fi - # remove defines - 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 - # loop through all includes - cat /tmp/$$a | grep "^#include" | + cat "$FILE" | grep "^#include" | sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' | while read INCLUDE do + if [ "$1" = "-v" ] + then echo "checking $FILE $INCLUDE" + fi + [ -s /usr/include/$INCLUDE ] && continue [ "$INCLUDE" = postgres.h ] && continue [ "$INCLUDE" = config.h ] && continue @@ -39,9 +36,17 @@ do grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | egrep -q '^#else|^#endif' && continue + # remove defines from include files + 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 + # set up initial file contents - cat /tmp/$$a | - grep -v '^#include[ ]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b + grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' \ + /tmp/$$a >/tmp/$$b + if [ "$IS_INCLUDE" = "Y" ] then echo "#include \"postgres.h\"" >/tmp/$$.c else >/tmp/$$.c @@ -66,11 +71,7 @@ do cat /tmp/$$b cat /tmp/$$.c fi - grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" >/tmp/$$b mv /tmp/$$b "$FILE" - elif [ "$1" = "-v" ] - then echo "$FILE" fi - done done |