summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/includes.sh
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-09 13:03:06 +0200
committerRobert Vollmert <rvollmert@gmx.net>2009-10-09 13:05:36 +0200
commit731382be4957e6dd99ffcb69c14f1f0bc641fb35 (patch)
treeb238a45ed94a20869135552392f21a5a951c9cb9 /crawl-ref/source/util/includes.sh
parentf4fbc401fe0032429008bcc541587f8f2d77cc08 (diff)
downloadcrawl-ref-731382be4957e6dd99ffcb69c14f1f0bc641fb35.tar.gz
crawl-ref-731382be4957e6dd99ffcb69c14f1f0bc641fb35.zip
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.
Diffstat (limited to 'crawl-ref/source/util/includes.sh')
-rw-r--r--crawl-ref/source/util/includes.sh34
1 files changed, 29 insertions, 5 deletions
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
}
+