3 # autodocufier.pl - extracts usage messages from busybox usage.c and
4 # pretty-prints them to stdout.
13 open(USAGE, 'usage.h') or die "usage.h: $!";
15 while (defined($line = <USAGE>)) {
17 if ($line =~ /^#define (\w+)_trivial_usage/) {
18 # grab the applet name
22 while (defined($line = <USAGE>)) {
26 } else { print "\t"; }
27 $full_usage = $applet . "_full_usage";
28 last if ( $line =~ /$full_usage/ );
29 # Skip preprocessor stuff
30 next if $line =~ /^\s*#/;
31 # Strip the continuation char
36 # substitute escape sequences
37 # (there's probably a better way to do this...)
40 # fix up preprocessor macros
41 $line =~ s/USAGE_\w+\([\s]*?(".*?").*?\)/$1/sg;
42 # Strip any empty quotes out
43 $line =~ s/"[\s]*"//sg;
44 # strip line end quotes, again
52 while (defined($line = <USAGE>)) {
56 } else { print "\t"; }
57 # we're done if we hit a line lacking a '\' at the end
58 #last if ! $line !~ /\\$/;
59 if ( $line !~ /\\$/ ) {
60 #print "Got one at $line\n";
63 # Skip preprocessor stuff
64 next if $line =~ /^\s*#/;
65 # Strip the continuation char
70 # substitute escape sequences
71 # (there's probably a better way to do this...)
74 # Automagically #define all preprocessor lines
75 #$line =~ s/USAGE_\w+\([\s]*?(".*?")\s,\s".*"\s\)/$1/sg;
76 $line =~ s/USAGE_\w+\(\s*?(".*").*\)/$1/sg;
77 # Strip any empty quotes out
78 $line =~ s/"[\s]*"//sg;
79 # strip line end quotes, again