diff options
author | Bruce Momjian | 2000-06-15 03:33:12 +0000 |
---|---|---|
committer | Bruce Momjian | 2000-06-15 03:33:12 +0000 |
commit | df43800fc855bd64dbe6c85c4d13bda1ea6a33c9 (patch) | |
tree | 86eb611a5ef96008204350d7f72653657b92069e /src/tools | |
parent | e362d4e1eadd75f083dd0ed6a5304a0f057379fb (diff) |
Clean up #include's.
Diffstat (limited to 'src/tools')
-rwxr-xr-x | src/tools/pginclude/pgrminclude | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/tools/pginclude/pgrminclude b/src/tools/pginclude/pgrminclude index e91997bc3f5..60839c15dca 100755 --- a/src/tools/pginclude/pgrminclude +++ b/src/tools/pginclude/pgrminclude @@ -12,12 +12,15 @@ do then IS_INCLUDE="Y" 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" | sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' | while read INCLUDE @@ -26,11 +29,14 @@ do [ "$INCLUDE" = postgres.h ] && continue [ "$INCLUDE" = config.h ] && continue [ "$INCLUDE" = c.h ] && continue + # preserve configure-specific includes + # these includes are surrounded by #ifdef's 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" ] @@ -50,12 +56,6 @@ do 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/$$ |