diff options
Diffstat (limited to 'crawl-ref/source/util/gather_features')
-rwxr-xr-x | crawl-ref/source/util/gather_features | 21 |
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; } |