|
|
@ -1,7 +1,7 @@ |
|
|
|
: |
|
|
|
: |
|
|
|
# remove extra #include's |
|
|
|
# remove extra #include's |
|
|
|
|
|
|
|
|
|
|
|
# $PostgreSQL: pgsql/src/tools/pginclude/pgrminclude,v 1.12 2006/07/11 20:51:25 momjian Exp $ |
|
|
|
# $PostgreSQL: pgsql/src/tools/pginclude/pgrminclude,v 1.13 2006/07/12 16:28:27 momjian Exp $ |
|
|
|
|
|
|
|
|
|
|
|
trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15 |
|
|
|
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 -name '*.[ch]' -print | |
|
|
|
find . \( -name CVS -a -prune \) -o -type f -name '*.[ch]' -print | |
|
|
@ -15,18 +15,15 @@ do |
|
|
|
else IS_INCLUDE="N" |
|
|
|
else IS_INCLUDE="N" |
|
|
|
fi |
|
|
|
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 |
|
|
|
# loop through all includes |
|
|
|
cat /tmp/$$a | grep "^#include" | |
|
|
|
cat "$FILE" | grep "^#include" | |
|
|
|
sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' | |
|
|
|
sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' | |
|
|
|
while read INCLUDE |
|
|
|
while read INCLUDE |
|
|
|
do |
|
|
|
do |
|
|
|
|
|
|
|
if [ "$1" = "-v" ] |
|
|
|
|
|
|
|
then echo "checking $FILE $INCLUDE" |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
[ -s /usr/include/$INCLUDE ] && continue |
|
|
|
[ -s /usr/include/$INCLUDE ] && continue |
|
|
|
[ "$INCLUDE" = postgres.h ] && continue |
|
|
|
[ "$INCLUDE" = postgres.h ] && continue |
|
|
|
[ "$INCLUDE" = config.h ] && continue |
|
|
|
[ "$INCLUDE" = config.h ] && continue |
|
|
@ -39,9 +36,17 @@ do |
|
|
|
grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | |
|
|
|
grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" | |
|
|
|
egrep -q '^#else|^#endif' && continue |
|
|
|
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 |
|
|
|
# set up initial file contents |
|
|
|
cat /tmp/$$a | |
|
|
|
grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' \ |
|
|
|
grep -v '^#include[ ]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b |
|
|
|
/tmp/$$a >/tmp/$$b |
|
|
|
|
|
|
|
|
|
|
|
if [ "$IS_INCLUDE" = "Y" ] |
|
|
|
if [ "$IS_INCLUDE" = "Y" ] |
|
|
|
then echo "#include \"postgres.h\"" >/tmp/$$.c |
|
|
|
then echo "#include \"postgres.h\"" >/tmp/$$.c |
|
|
|
else >/tmp/$$.c |
|
|
|
else >/tmp/$$.c |
|
|
@ -66,11 +71,7 @@ do |
|
|
|
cat /tmp/$$b |
|
|
|
cat /tmp/$$b |
|
|
|
cat /tmp/$$.c |
|
|
|
cat /tmp/$$.c |
|
|
|
fi |
|
|
|
fi |
|
|
|
grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" >/tmp/$$b |
|
|
|
|
|
|
|
mv /tmp/$$b "$FILE" |
|
|
|
mv /tmp/$$b "$FILE" |
|
|
|
elif [ "$1" = "-v" ] |
|
|
|
|
|
|
|
then echo "$FILE" |
|
|
|
|
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
done |
|
|
|
done |
|
|
|
done |
|
|
|
done |
|
|
|