diff options
author | Norbert Preining <preining@logic.at> | 2009-06-02 12:47:36 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2009-06-02 12:47:36 +0000 |
commit | bdf77ac6b06ea9f7588ab8935385a1ea1cfdc543 (patch) | |
tree | e7853793294e0dc8317e549e954f7a4286bedac5 /Master/tlpkg/TeXLive/TLPOBJ.pm | |
parent | 953d46c5ce6c881f05f8a33d5ba3b9b5366a2389 (diff) |
factor out the parsing of AddFormat and AddHyphen lines to separate
function in TLUtils, use this function in TLPOBJ, and reuse this function
in check-execute_consistency to check the format execute consistency
git-svn-id: svn://tug.org/texlive/trunk@13577 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPOBJ.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLPOBJ.pm | 89 |
1 files changed, 15 insertions, 74 deletions
diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm index b192442f415..9e1bd093fa7 100644 --- a/Master/tlpkg/TeXLive/TLPOBJ.pm +++ b/Master/tlpkg/TeXLive/TLPOBJ.pm @@ -918,6 +918,7 @@ sub make_return_hash_from_executes { + # # execute stuff # @@ -928,51 +929,16 @@ sub fmtutil_cnf_lines { my $pkg = $obj->name; foreach my $e ($obj->executes) { if ($e =~ m/AddFormat\s+(.*)\s*/) { - my $name; - my $engine; - my $patterns = "-"; - my $options = ""; - my $mode = ""; + my %r = TeXLive::TLUtils::parse_AddFormat_line("$1"); + if (defined($r{"error"})) { + die "$r{'error'}, package $pkg, execute $e"; + } if ($first) { push @fmtlines, "#\n# from $pkg:\n"; $first = 0; } - for my $p (&TeXLive::TLUtils::quotewords('\s+', 0, "$1")) { - my ($a, $b); - if ($p =~ m/^(name|engine|mode|patterns|options)=(.*)$/) { - $a = $1; - $b = $2; - } else { - die "Unknown format directive $p in $pkg (line=$e)"; - } - if ($a eq "name") { - die "AddFormat line needs name=something: $pkg, $e" unless $b; - $name = $b; next; - } - if ($a eq "engine") { - die "AddFormat line needs engine=something: $pkg, $e" unless $b; - $engine = $b; next; - } - if ($a eq "patterns") { - $patterns = ( $b ? $b : "-"); - next; - } - if ($a eq "mode") { - if ($b eq "disabled") { - $mode = "#! "; - } else { - $mode = ""; - } - next; - } - if ($a eq "options") { - $options = ( $b ? $b : ""); - next; - } - # should not be reached at all - die "Unknown language directive in $pkg: $e"; - } - push @fmtlines, "$mode$name $engine $patterns $options\n"; + my $mode = ($r{"mode"} ? "" : "#! "); + push @fmtlines, "$mode$r{'name'} $r{'engine'} $r{'patterns'} $r{'options'}\n"; } } return @fmtlines; @@ -1045,43 +1011,18 @@ sub _parse_hyphen_execute { my $first = 1; foreach my $e ($obj->executes) { if ($e =~ m/AddHyphen\s+(.*)\s*/) { - my $name; - my $lefthyphenmin; - my $righthyphenmin; - my $file; - my @synonyms; + my %r = TeXLive::TLUtils::parse_AddHyphen_line("$1"); + if (defined($r{"error"})) { + die "$r{'error'}, package $pkg, execute $e"; + } if ($first) { push @langlines, "% from $pkg:\n"; $first = 0; } - foreach my $p (split(' ', $1)) { - my ($a, $b) = split /=/, $p; - if ($a eq "name") { - die "$0: AddHyphen line needs name=something: $pkg, $e" unless $b; - $name = $b; next; - } - if ($a eq "lefthyphenmin") { - # lefthyphenmin default to 3 - $lefthyphenmin = ( $b ? $b : 2 ); - next; - } - if ($a eq "righthyphenmin") { - $righthyphenmin = ( $b ? $b : 3); - next; - } - if ($a eq "file") { - die "$0: AddHyphen line needs file=something: $pkg, $e" unless $b; - $file = $b; - next; - } - if ($a eq "synonyms") { - @synonyms = split /,/, $b; - next; - } - die "$0: Unknown language directive in $pkg: $e"; - } - my @foo = &$coderef ($name, $lefthyphenmin, $righthyphenmin, - $file, @synonyms); + my @syns; + @syns = @{$r{"synonyms"}} if (defined($r{"synonyms"})); + my @foo = &$coderef ($r{"name"}, $r{"lefthyphenmin"}, + $r{"righthyphenmin"}, $r{"file"}, @syns); push @langlines, @foo; } } |