1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

How many options remain available?

This commit is contained in:
Micah Cowan 2008-10-25 06:49:35 -07:00
parent 86d7168105
commit a32d41c5d0

48
util/freeopts Executable file
View File

@ -0,0 +1,48 @@
#!/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 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%+/";
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 }) {
print $opt;
} else {
print ' ';
}
}
print "\n";
}