We currently have a policy that config.h MUST be included first so as to
pull in the portability definitions early. It MAY be included via the
legacy squid.h at present.
This alteration to the source maintenance script validates that each .c
and .cc file in the sources includes config.h or squid.h first in its
include order. Also that each .h and .cci do not include config.h which
is a double include with enforced .c/.cc requirement.
* an ERROR: line is produces for each violating file
* as yet the maintenance run is not blocked so as to catch as many
errors as possible in one run
* detection only, as yet no code alterations are performed by this script
* FORMAT: informative lines are silenced to make ERROR: more visible
srcformat ()
{
PWD=`pwd`
-echo "FORMAT: ${PWD}..."
+#echo "FORMAT: ${PWD}..."
for FILENAME in `ls -1`; do
fi
fi
+ #
+ # REQUIRE config.h/squid.h as first #include
+ #
+ case ${FILENAME} in
+ *.c|*.cc)
+ FI=`grep "#include" ${FILENAME} | head -1`;
+ if test "${FI}" != "#include \"config.h\"" -a "${FI}" != "#include \"squid.h\"" ; then
+ echo "ERROR: ${PWD}/${FILENAME} does not include config.h or squid.h first!"
+ fi
+ ;;
+ *.h|*.cci)
+ FI=`grep "#include \"config.h\"" ${FILENAME}`;
+ if test "x${FI}" != "x" ; then
+ echo "ERROR: ${PWD}/${FILENAME} duplicate include of config.h"
+ fi
+ ;;
+ esac
+
#
# DEBUG Section list maintenance
#