~ubuntu-branches/ubuntu/lucid/dblatex/lucid

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env perl
    eval 'exec /usr/bin/env perl -S $0 ${1+"$@"}'
        if $running_under_some_shell;

use File::Basename;
use Getopt::Std;

#
# Basically, the script translate the parameters from the spec file to options
# passed to the dblatex script
#

BEGIN {
%specs_mapping = (
  'TexInputs' => '--texinputs' ,
  'PdfInputs' => '--pdfinputs' ,
  'TexStyle'  => '--style'     ,
  'TexPost'   => '--texpost'   ,
  'XslParam'  => '-p'          ,
  'Options'   => ''            ,
  'FigInputs' => '-I'
);
}

sub specs2option
{
  local($specs) = $_[0];
  my @a = ();
  my $opt = "";
  my $dirspecs = dirname($specs);

  open(SPECS, "<$specs") || die "Cannot open $specs\n";

  while (<SPECS>) {
    $line = $_;

    # first, remove the comments
    @a = split('#', $line, 2);

    # let's get the parameter key
    ($key = $a[0]) =~ s/^\s*([^:]*).*/$1/;
    chomp $key;

    if (exists $specs_mapping{"$key"}) {
      ($p = $a[0]) =~ s/^\s*$key:\s*//;
      chomp $p;
      if (($key =~ /TexInputs/) ||
          ($key =~ /PdfInputs/) ||
          ($key =~ /XslParam/) ||
          ($key =~ /TexPost/)){
        if (not($p =~ /^\//)) {
          $p = "$dirspecs/$p";
        }
      }
      $opt .= "$specs_mapping{$key} $p ";
    }
  }
  return $opt;
}

$file =  $ARGV[0];
$opt = specs2option($file);

print "$opt\n";