#!/bin/bash . "${0%/*}"/../lib.sh findfiles() { find "${top_srcdir}" \ '(' -type d -a '(' -name .git -o -name autotools ')' -prune ')' \ -o '(' '(' -name '*.[ch]' -a ! -name 'probes.h' ')' -print0 ')' } # # don't allow obsolete functions # findfiles | xargs -0 \ grep -n -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes)\>[[:space:]]*\(' \ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.obsolete.funcs testit src.obsolete.funcs # # make sure people use our constants # findfiles | xargs -0 \ grep -n -E -e '\' | grep -v __PAX_UTILS_PATH_MAX \ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.bad.constants testit src.bad.constants # # don't allow obsolete headers # findfiles | xargs -0 \ grep -n -E -e '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' \ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.obsolete.headers testit src.obsolete.headers # # make sure people use the x* helper funcs # xfuncs=$(printf '%s|' $(sed -n 's:.*x\([^(]*\)(.*:\1:p' "${top_srcdir}"/xfuncs.h)) xfuncs=${xfuncs:0:${#xfuncs}-1} findfiles | xargs -0 \ grep -n -E -e "\<(${xfuncs})[[:space:]]*\(" \ | grep -v xfuncs.c \ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.use.xfuncs testit src.use.xfuncs # # check for style # findfiles | xargs -0 \ grep -n -E \ -e '\<(for|if|switch|while)\(' \ -e '\<(for|if|switch|while) \( ' \ -e ' ;' \ -e '[[:space:]]$' \ -e '\){' \ -e '(^|[^:])//' \ | sed -e "s:^\.\./\.\./::g" > "${builddir}"/src.style testit src.style # # Auto clean up the space issues # while read -d'\0' x; do case ${x} in */elf.h) continue ;; # Not our files esac ./space "${x}" > "${builddir}/${x}~" if ! diff -u "${x}" "${builddir}/${x}~" ; then echo "New file: ${x}~" else rm -f "${builddir}/${x}~" fi done > "${builddir}"/src.space < <(findfiles) testit src.space # # Make sure we don't keep re-importing stuff into elf.h that # breaks non-GNU systems. #507470 # grep -E "features.h|_DECLS" "${top_srcdir}"/elf.h > "${builddir}"/src.elf.h testit src.elf.h # # Python checks # if pyflakes /dev/null; then find "${top_srcdir}" \ '!' -ipath '*/tests/*' \ -name '*.py' \ -exec pyflakes {} + > "${builddir}"/src.pyflakes testit src.pyflakes fi exit ${ret}