From 731382be4957e6dd99ffcb69c14f1f0bc641fb35 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 9 Oct 2009 13:03:06 +0200 Subject: Extend and correct includes.sh slightly. You can now do say $ . util/include.sh $ checkhdr view.h | removelst to remove all doubtful includes of view.h. --- crawl-ref/source/util/includes.sh | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source/util/includes.sh') diff --git a/crawl-ref/source/util/includes.sh b/crawl-ref/source/util/includes.sh index ac96baca10..7eedf1d3c6 100644 --- a/crawl-ref/source/util/includes.sh +++ b/crawl-ref/source/util/includes.sh @@ -38,19 +38,43 @@ includes () check () { if includes $1 $2 > /dev/null && ! mightuse $1 $2 > /dev/null; then - echo $hdr $src; + echo $1 $2; fi } -# run check on all pairs -- should really cache the result of "names" +# run check on all source for a given header +# should really cache the result of "names" +checkhdr () +{ + for src in *.cc; do + check $1 $src + done +} + +# run check on all pairs checkall () { for hdr in *.h; do if [ $hdr = AppHdr.h ]; then continue; fi - for src in *.cc; do - check $hdr $src - done + checkhdr $hdr + done +} + +# remove #include of $1 from $2 +remove () +{ + b=$(basename $1 .h) + sed -e '/^#include "'$b'\.h"$/d' < $2 > $2.rmincl + mv $2.rmincl $2 +} + +# remove doubtful includes for a list as output by checkall. +removelst () +{ + while read hdr src; do + remove $hdr $src done } + -- cgit v1.2.3-54-g00ecf