2008-10-25 09:49:35 -04:00
|
|
|
#!/usr/bin/perl -n
|
|
|
|
# NOTE the use of -n above; this script is called in a loop.
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
our $scanning;
|
|
|
|
our %used_chars;
|
|
|
|
BEGIN {
|
|
|
|
$scanning = 0;
|
|
|
|
%used_chars = ();
|
|
|
|
|
|
|
|
open STDIN, "../src/main.c" or die "main.c: $!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (/^static struct cmdline_option option_data/) {
|
|
|
|
$scanning = 1;
|
|
|
|
}
|
|
|
|
elsif (/[}];/) {
|
|
|
|
$scanning = 0;
|
|
|
|
}
|
|
|
|
elsif (
|
|
|
|
$scanning &&
|
|
|
|
/^[\t ]*\{ "[^"]*", '(.)', OPT_[A-Z0-9_]*, /
|
|
|
|
) {
|
|
|
|
$used_chars{$1} = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
my $cols = 0;
|
|
|
|
my $max_cols = 13;
|
|
|
|
my $opt_chars =
|
2008-10-25 10:13:24 -04:00
|
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
2008-10-25 09:49:35 -04:00
|
|
|
print "Free chars:\n\t";
|
|
|
|
for (my $i = 0; $i < length $opt_chars; ++$i, ++$cols) {
|
|
|
|
if ($cols == $max_cols) {
|
|
|
|
$cols = 0;
|
|
|
|
print "\n\t";
|
|
|
|
}
|
|
|
|
my $opt = substr($opt_chars,$i,1);
|
|
|
|
print ' ';
|
|
|
|
if (!$used_chars{ $opt }) {
|
2008-10-25 10:13:24 -04:00
|
|
|
print "-$opt";
|
2008-10-25 09:49:35 -04:00
|
|
|
} else {
|
2008-10-25 10:13:24 -04:00
|
|
|
print ' ';
|
2008-10-25 09:49:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
}
|