1
by Andreas Hoenen
Import upstream version 0.1.9 |
1 |
#!/usr/bin/env perl
|
2 |
eval 'exec /usr/bin/env perl -S $0 ${1+"$@"}' |
|
3 |
if $running_under_some_shell; |
|
4 |
||
5 |
use File::Basename; |
|
6 |
use Getopt::Std; |
|
7 |
||
8 |
#
|
|
9 |
# Basically, the script translate the parameters from the spec file to options
|
|
10 |
# passed to the dblatex script
|
|
11 |
#
|
|
12 |
||
13 |
BEGIN { |
|
14 |
%specs_mapping = ( |
|
15 |
'TexInputs' => '--texinputs' , |
|
16 |
'PdfInputs' => '--pdfinputs' , |
|
17 |
'TexStyle' => '--style' , |
|
18 |
'TexPost' => '--texpost' , |
|
19 |
'XslParam' => '-p' , |
|
20 |
'Options' => '' , |
|
21 |
'FigInputs' => '-I' |
|
22 |
);
|
|
23 |
}
|
|
24 |
||
25 |
sub specs2option |
|
26 |
{
|
|
27 |
local($specs) = $_[0]; |
|
28 |
my @a = (); |
|
29 |
my $opt = ""; |
|
30 |
my $dirspecs = dirname($specs); |
|
31 |
||
32 |
open(SPECS, "<$specs") || die "Cannot open $specs\n"; |
|
33 |
||
34 |
while (<SPECS>) { |
|
35 |
$line = $_; |
|
36 |
||
37 |
# first, remove the comments
|
|
38 |
@a = split('#', $line, 2); |
|
39 |
||
40 |
# let's get the parameter key
|
|
41 |
($key = $a[0]) =~ s/^\s*([^:]*).*/$1/; |
|
42 |
chomp $key; |
|
43 |
||
44 |
if (exists $specs_mapping{"$key"}) { |
|
45 |
($p = $a[0]) =~ s/^\s*$key:\s*//; |
|
46 |
chomp $p; |
|
47 |
if (($key =~ /TexInputs/) || |
|
48 |
($key =~ /PdfInputs/) || |
|
49 |
($key =~ /XslParam/) || |
|
50 |
($key =~ /TexPost/)){ |
|
51 |
if (not($p =~ /^\//)) { |
|
52 |
$p = "$dirspecs/$p"; |
|
53 |
}
|
|
54 |
}
|
|
55 |
$opt .= "$specs_mapping{$key} $p "; |
|
56 |
}
|
|
57 |
}
|
|
58 |
return $opt; |
|
59 |
}
|
|
60 |
||
61 |
$file = $ARGV[0]; |
|
62 |
$opt = specs2option($file); |
|
63 |
||
64 |
print "$opt\n"; |
|
65 |