summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-07-14 10:13:39 -0400
committerNeil Moore <neil@s-z.org>2014-07-14 10:13:39 -0400
commit85a9e77e0a38b5913d0d7c715202d997c0e61180 (patch)
treebea949049e0fe976b6a6c68325e1fa307ebc2cd9
parent844227159e91e64c90bbb66da27f92028f938cbf (diff)
downloadcrawl-ref-85a9e77e0a38b5913d0d7c715202d997c0e61180.tar.gz
crawl-ref-85a9e77e0a38b5913d0d7c715202d997c0e61180.zip
Handle feature-data.h in db_lint.
-rwxr-xr-xcrawl-ref/source/util/gather_features21
1 files changed, 15 insertions, 6 deletions
diff --git a/crawl-ref/source/util/gather_features b/crawl-ref/source/util/gather_features
index fe65c378f1..fa91cc5fa6 100755
--- a/crawl-ref/source/util/gather_features
+++ b/crawl-ref/source/util/gather_features
@@ -3,9 +3,14 @@
# Run gather_features -a if you want "A pigsty" rather than "pigsty".
my $art = grep /^-a$/, @ARGV;
-sub extract($$$)
+# extract(fn, start, end[, per-line)
+#
+# Gather quoted strings from the file named fn, in the region between the first
+# occurrence of the start string and the next line that contains only the end
+# string. If per_line is true, take only the first string from each line.
+sub extract($$$;$)
{
- my ($fn, $start, $end) = @_;
+ my ($fn, $start, $end, $per_line) = @_;
open my $in, "util/cpp_version $fn|" or die "Can't read $fn: $!\n";
undef local $/;
my $data = <$in>;
@@ -14,7 +19,10 @@ sub extract($$$)
$data =~ s/.*\Q$start\E(.*?)\n\Q$end\E\n.*/$1/s
or die "Can't find \"$start\" in $fn\n";
$data =~ s|//.*$||mg;
- return ($data =~ /"([^"\n]*)"/g);
+ my $consume = $per_line ? '.*' : '';
+ return grep {
+ $_ ne "" and $_ !~ /^<.*>$/
+ } ($data =~ /"([^"\n]*)"$consume/g);
}
sub articled($)
@@ -31,10 +39,11 @@ sub articled($)
for (extract "directn.cc", "_base_feature_desc(dungeon_feature_type", "}")
{
- next if /^$/;
- next if /^undefined trap$/;
- next if /^Error/;
+ $features{articled($_)} = 1;
+}
+for (extract "feature-data.h", "feat_defs[] =", "};", "per-line")
+{
$features{articled($_)} = 1;
}