| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
use warnings; |
| 4 |
|
| 5 |
# extract(fn, start, end[, per-line) |
| 6 |
# |
| 7 |
# Gather quoted strings from the file named fn, in the region between the first |
| 8 |
# occurrence of the start string and the next line that contains only the end |
| 9 |
# string. If per_line is true, take only the first string from each line. |
| 10 |
sub extract($$$;$) |
| 11 |
{ |
| 12 |
my ($fn, $start, $end, $per_line) = @_; |
| 13 |
open my $in, "util/cpp_version $fn|" or die "Can't read $fn: $!\n"; |
| 14 |
undef local $/; |
| 15 |
my $data = <$in>; |
| 16 |
close $in; |
| 17 |
|
| 18 |
$data =~ s/.*\Q$start\E(.*?)\Q$end\E.*/$1/s |
| 19 |
or die "Can't find \"$start\" in $fn\n"; |
| 20 |
$data =~ s|//.*$||mg; |
| 21 |
my $consume = $per_line ? '.*' : ''; |
| 22 |
return grep { |
| 23 |
$_ ne "" and $_ !~ /^<.*>$/ |
| 24 |
} ($data =~ /"([^"\n]*)"$consume/g); |
| 25 |
} |
| 26 |
|
| 27 |
for (extract "cloud.cc", "clouds[] =", "};", "per-line") |
| 28 |
{ |
| 29 |
$features{$_ . " cloud" } = 1 unless $_ eq "?"; |
| 30 |
} |
| 31 |
|
| 32 |
print join("\n", sort keys %features), "\n"; |