mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Clean up #include in /include directory. Add scripts for checking includes.
This commit is contained in:
13
src/tools/pginclude/pgdefine
Executable file
13
src/tools/pginclude/pgdefine
Executable file
@@ -0,0 +1,13 @@
|
||||
:
|
||||
trap "rm -f /tmp/$$" 0 1 2 3 15
|
||||
for FILE
|
||||
do
|
||||
cat "$FILE" | grep "^#define" >/tmp/$$
|
||||
cat /tmp/$$ | sed -n 's/^#define[ ][ ]*\([a-zA-Z0-9_]*\)[ ][ ]*[^ ].*$/(void)\1;/p'
|
||||
cat /tmp/$$ | sed -n 's/^#define[ ][ ]*\([a-zA-Z0-9_]*([^)]*)\).*$/(=void)\1;/p' |
|
||||
sed 's/([a-zA-Z0-9_ ][a-zA-Z0-9_ ]*)/(0)/g' |
|
||||
sed 's/([a-zA-Z0-9_ ]*,/(0,/g' |
|
||||
sed 's/,[a-zA-Z0-9_ ]*,/,0,/g' |
|
||||
sed 's/,[a-zA-Z0-9_ ]*)/,0)/g' |
|
||||
sed 's/(=void)/(void)/g'
|
||||
done
|
20
src/tools/pginclude/pginclude
Executable file
20
src/tools/pginclude/pginclude
Executable file
@@ -0,0 +1,20 @@
|
||||
:
|
||||
trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a" 0 1 2 3 15
|
||||
find . \( -name CVS -a -prune \) -o -name '*.[ch]' -type f -print | while read FILE
|
||||
do
|
||||
sed 's/->[a-zA-Z0-9_\.]*//g' "$FILE" >/tmp/$$a
|
||||
echo "#include \"postgres.h\"" >/tmp/$$.c
|
||||
echo "#include \"/tmp/$$a\"" >>/tmp/$$.c
|
||||
echo "void main() {" >>/tmp/$$.c
|
||||
pgdefine "$FILE" >>/tmp/$$.c
|
||||
echo "}" >>/tmp/$$.c
|
||||
cc -Werror -Wall -I/pg/include -I/pg/backend -c /tmp/$$.c -o /tmp/$$.o >/tmp/$$ 2>&1
|
||||
if [ "$?" -ne 0 ]
|
||||
then echo "$FILE"
|
||||
if [ "$1" = "-v" ]
|
||||
then cat /tmp/$$
|
||||
nl /tmp/$$.c
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
done
|
28
src/tools/pginclude/pgnoinclude
Executable file
28
src/tools/pginclude/pgnoinclude
Executable file
@@ -0,0 +1,28 @@
|
||||
:
|
||||
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 -print | while read FILE
|
||||
do
|
||||
cat "$FILE" | grep -v "^#if" | grep -v "^#else" |
|
||||
grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a
|
||||
cat /tmp/$$a | grep "^#include" |
|
||||
sed 's/#include[ ]*[<"]\([^>"]*\).*$/\1/g' |
|
||||
while read INCLUDE
|
||||
do
|
||||
[ -s /usr/include/$INCLUDE ] && continue
|
||||
cat /tmp/$$a |
|
||||
grep -v '^#include[ ]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b
|
||||
echo "#include \"postgres.h\"" >/tmp/$$.c
|
||||
echo "#include \"/tmp/$$b\"" >>/tmp/$$.c
|
||||
echo "void main() {" >>/tmp/$$.c
|
||||
pgdefine "$FILE" >>/tmp/$$.c
|
||||
echo "}" >>/tmp/$$.c
|
||||
cc -Werror -Wall -I/pg/include -I/pg/backend -c /tmp/$$.c -o /tmp/$$.o >/tmp/$$ 2>&1
|
||||
if [ "$?" -eq 0 ]
|
||||
then echo "$FILE $INCLUDE"
|
||||
if [ "$1" = "-v" ]
|
||||
then cat /tmp/$$
|
||||
cat /tmp/$$.c
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
Reference in New Issue
Block a user