-
Notifications
You must be signed in to change notification settings - Fork 4
/
makeMan.in
50 lines (46 loc) · 1.01 KB
/
makeMan.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!@PERL@ -w
#
# Generates manpages from manpage.in files by substituting @...@ tags.
#
use lib 'lib/Foomatic/';
use Defaults;
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 %sysdeps = %$Foomatic::Defaults::sysdeps;
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;
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);
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;
}