Skip to content

Commit 99ac1e6

Browse files
committed
Fix pgrminclude to work for stripping include files.
1 parent de7e81f commit 99ac1e6

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/tools/pginclude/pgrminclude

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
:
22
# remove extra #include's
33

4-
# $PostgreSQL: pgsql/src/tools/pginclude/pgrminclude,v 1.12 2006/07/11 20:51:25 momjian Exp $
4+
# $PostgreSQL: pgsql/src/tools/pginclude/pgrminclude,v 1.13 2006/07/12 16:28:27 momjian Exp $
55

66
trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
77
find . \( -name CVS -a -prune \) -o -type f -name '*.[ch]' -print |
@@ -15,18 +15,15 @@ do
1515
else IS_INCLUDE="N"
1616
fi
1717

18-
# remove defines
19-
if [ "$IS_INCLUDE" = "Y" ]
20-
then cat "$FILE" | grep -v "^#if" | grep -v "^#else" |
21-
grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a
22-
else cat "$FILE" >/tmp/$$a
23-
fi
24-
2518
# loop through all includes
26-
cat /tmp/$$a | grep "^#include" |
19+
cat "$FILE" | grep "^#include" |
2720
sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' |
2821
while read INCLUDE
2922
do
23+
if [ "$1" = "-v" ]
24+
then echo "checking $FILE $INCLUDE"
25+
fi
26+
3027
[ -s /usr/include/$INCLUDE ] && continue
3128
[ "$INCLUDE" = postgres.h ] && continue
3229
[ "$INCLUDE" = config.h ] && continue
@@ -39,9 +36,17 @@ do
3936
grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" |
4037
egrep -q '^#else|^#endif' && continue
4138

39+
# remove defines from include files
40+
if [ "$IS_INCLUDE" = "Y" ]
41+
then cat "$FILE" | grep -v "^#if" | grep -v "^#else" |
42+
grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a
43+
else cat "$FILE" >/tmp/$$a
44+
fi
45+
4246
# set up initial file contents
43-
cat /tmp/$$a |
44-
grep -v '^#include[ ]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b
47+
grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' \
48+
/tmp/$$a >/tmp/$$b
49+
4550
if [ "$IS_INCLUDE" = "Y" ]
4651
then echo "#include \"postgres.h\"" >/tmp/$$.c
4752
else >/tmp/$$.c
@@ -66,11 +71,7 @@ do
6671
cat /tmp/$$b
6772
cat /tmp/$$.c
6873
fi
69-
grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" >/tmp/$$b
7074
mv /tmp/$$b "$FILE"
71-
elif [ "$1" = "-v" ]
72-
then echo "$FILE"
7375
fi
74-
7576
done
7677
done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy