|
1 | 1 | : |
2 | 2 | # remove extra #include's |
3 | 3 |
|
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 $ |
5 | 5 |
|
6 | 6 | trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15 |
7 | 7 | find . \( -name CVS -a -prune \) -o -type f -name '*.[ch]' -print | |
|
15 | 15 | elseIS_INCLUDE="N" |
16 | 16 | fi |
17 | 17 |
|
18 | | -# remove defines |
19 | | -if [ "$IS_INCLUDE" = "Y" ] |
20 | | -thencat "$FILE" | grep -v "^#if" | grep -v "^#else" | |
21 | | -grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a |
22 | | -elsecat "$FILE" >/tmp/$$a |
23 | | -fi |
24 | | - |
25 | 18 | # loop through all includes |
26 | | -cat/tmp/$$a | grep "^#include" | |
| 19 | +cat"$FILE" | grep "^#include" | |
27 | 20 | sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' | |
28 | 21 | while read INCLUDE |
29 | 22 | do |
| 23 | +if [ "$1" = "-v" ] |
| 24 | +thenecho "checking $FILE $INCLUDE" |
| 25 | +fi |
| 26 | + |
30 | 27 | [ -s /usr/include/$INCLUDE ] && continue |
31 | 28 | [ "$INCLUDE" = postgres.h ] && continue |
32 | 29 | [ "$INCLUDE" = config.h ] && continue |
|
39 | 36 | grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | |
40 | 37 | egrep -q '^#else|^#endif' && continue |
41 | 38 |
|
| 39 | +# remove defines from include files |
| 40 | +if [ "$IS_INCLUDE" = "Y" ] |
| 41 | +thencat "$FILE" | grep -v "^#if" | grep -v "^#else" | |
| 42 | +grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a |
| 43 | +elsecat "$FILE" >/tmp/$$a |
| 44 | +fi |
| 45 | + |
42 | 46 | # 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 | + |
45 | 50 | if [ "$IS_INCLUDE" = "Y" ] |
46 | 51 | thenecho "#include \"postgres.h\"" >/tmp/$$.c |
47 | 52 | else>/tmp/$$.c |
|
66 | 71 | cat /tmp/$$b |
67 | 72 | cat /tmp/$$.c |
68 | 73 | fi |
69 | | -grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" >/tmp/$$b |
70 | 74 | mv /tmp/$$b "$FILE" |
71 | | -elif [ "$1" = "-v" ] |
72 | | -thenecho "$FILE" |
73 | 75 | fi |
74 | | - |
75 | 76 | done |
76 | 77 | done |