X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxml2man.pl;h=a4d9538e4730d4fa8a11a46fb354022a255cac71;hb=3f1091236d800c43a3124c44c7da54e53f205b13;hp=e6b69d7834f9242e3d379dd4934d12c27d33a717;hpb=13dbc569cdc6e29019722c0ef9b932a925efbcad;p=xscreensaver diff --git a/hacks/xml2man.pl b/hacks/xml2man.pl index e6b69d78..a4d9538e 100755 --- a/hacks/xml2man.pl +++ b/hacks/xml2man.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2002 Jamie Zawinski +# Copyright © 2002-2013 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -24,7 +24,7 @@ use strict; use Text::Wrap; my $progname = $0; $progname =~ s@.*/@@g; -my $version = q{ $Revision: 1.2 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; +my $version = q{ $Revision: 1.5 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; my $verbose = 0; @@ -60,7 +60,7 @@ my $man_suffix = (".SH ENVIRONMENT\n" . ".BR X (1),\n" . ".BR xscreensaver (1)\n" . ".SH COPYRIGHT\n" . - "Copyright \\(co 2002 by %AUTHOR%. " . + "Copyright \\(co %YEAR% by %AUTHOR%. " . "Permission to use, copy, modify, \n" . "distribute, and sell this software and its " . "documentation for any purpose is \n" . @@ -76,8 +76,9 @@ my $man_suffix = (".SH ENVIRONMENT\n" . ".SH AUTHOR\n" . "%AUTHOR%.\n"); -sub xml2man { +sub xml2man($) { my ($exe) = @_; + $exe =~ s/\.xml$//s; my $cfgdir = (-d "config" ? "config" : "../config"); my $xml = "$cfgdir/$exe.xml"; my $man = "$exe.man"; @@ -118,6 +119,7 @@ sub xml2man { my $carg = $arg; my $boolp = m/^= 10000) { $label = "Per-frame delay, in microseconds."; - $def = sprintf ("%d (%0.2f seconds.)", $def, ($def/1000000.0)); + $def = sprintf ("%d (%0.2f seconds)", $def, ($def/1000000.0)); $low = $hi = undef; + } elsif ($carg eq '-speed \fInumber\fP') { + $label = "Animation speed. 2.0 means twice as fast, " . + "0.5 means half as fast."; + $novalsp = 1; } elsif ($boolp) { $label .= ". Boolean."; } elsif ($label) { @@ -164,8 +170,10 @@ sub xml2man { $args .= "[\\$carg]\n"; - $label .= " $low - $hi." if (defined($low) && defined($hi)); - $label .= " Default: $def." if (defined ($def)); + if (! $novalsp) { + $label .= " $low - $hi." if (defined($low) && defined($hi)); + $label .= " Default: $def." if (defined ($def)); + } $label = wrap ("", "", $label); $body .= ".TP 8\n.B \\$arg\n$label"; @@ -192,6 +200,8 @@ sub xml2man { $author = "UNKNOWN"; } + $desc =~ s@http://en\.wikipedia\.org/[^\s]+@@gs; + $desc = wrap ("", "", $desc); $body = (".TH XScreenSaver 1 \"\" \"X Version 11\"\n" . @@ -208,7 +218,11 @@ sub xml2man { $body . $man_suffix); + my $year = $1 if ($author =~ s/; (\d{4})$//s); + $year = (localtime)[5] + 1900 unless $year; + $body =~ s/%AUTHOR%/$author/g; + $body =~ s/%YEAR%/$year/g; #print $body; exit 0; @@ -220,18 +234,18 @@ sub xml2man { } -sub error { - ($_) = @_; - print STDERR "$progname: $_\n"; +sub error($) { + my ($err) = @_; + print STDERR "$progname: $err\n"; exit 1; } -sub usage { +sub usage() { print STDERR "usage: $progname [--verbose] programs...\n"; exit 1; } -sub main { +sub main() { my @progs = (); while ($_ = $ARGV[0]) { shift @ARGV; @@ -246,5 +260,5 @@ sub main { foreach (@progs) { xml2man($_); } } -main; +main(); exit 0;