diff options
author | Didier Raboud <didier@raboud.com> | 2010-05-22 08:38:12 +0200 |
---|---|---|
committer | Didier Raboud <didier@raboud.com> | 2010-05-22 08:38:12 +0200 |
commit | ff7f3eaf811f597b94aa2a93a6bc349d2bec8dfd (patch) | |
tree | a226166a9e7c1d716b7d8e9ee6c3066a0655ad78 /makeMan.in |
Imported Upstream version 3.0.2-20050114upstream/3.0.2-20050114
Diffstat (limited to 'makeMan.in')
-rwxr-xr-x | makeMan.in | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/makeMan.in b/makeMan.in new file mode 100755 index 0000000..310b8e0 --- /dev/null +++ b/makeMan.in @@ -0,0 +1,49 @@ +#!@PERL@ -w +# +# Generates manpages from manpage.in files by substituting @...@ tags. +# + +use Getopt::Std; + +my (%opt,@files); +getopts( 'v', \%opt); +my $VERBOSE = defined $opt{v} ? $opt{v} : 0; + +if (@ARGV) +{ + @files = @ARGV; +} +else +{ + opendir CWD, "." or die "Ooops! Can't read current dir!"; + @files = readdir CWD; + closedir CWD; +} + +my $append; +FILE: +foreach my $file (@files) +{ + print STDERR "Checking file `$file' ... " if $VERBOSE; + $append = "discard\n"; + next unless -f $file and $file =~ /^(.*\.[1-9])\.in$/; + my ($man) = $1; + $man =~ s,.*/,,; + next unless ((`file $file` =~ m/\b[ntg]roff\b/) or + (`file $file` =~ m/\[nt\]roff/)); + print STDERR "MATCHED\n" if $VERBOSE; + $append = ''; + open IN, "<$file" or (warn "Can't read input file $file!" and next FILE); + unlink $man; + open OUT, ">$man" or (warn "Can't write output file $man!" and next FILE); + while (<IN>) + { + s/@@([^@]*)@@/eval $1/ge; + print OUT; + } + close IN; +} +continue +{ + print STDERR $append if $VERBOSE; +} |