summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLPOBJ.pm
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-05-20 17:08:42 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-05-20 17:08:42 +0000
commitcce69ad0b59b059976669eb922832fd161493af8 (patch)
tree7ea283771d719501e6af00fe5df7643769331d68 /Master/tlpkg/TeXLive/TLPOBJ.pm
parent3df5aab7ab8f7c7d8b9c11ddfb4278a4f6948f7c (diff)
Implement generation of language.dat.lua by extending execute AddHyphen.
git-svn-id: svn://tug.org/texlive/trunk@18379 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPOBJ.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLPOBJ.pm59
1 files changed, 46 insertions, 13 deletions
diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm
index b867ab7b4a0..2ad420f657c 100644
--- a/Master/tlpkg/TeXLive/TLPOBJ.pm
+++ b/Master/tlpkg/TeXLive/TLPOBJ.pm
@@ -1024,15 +1024,15 @@ sub updmap_cfg_lines {
sub language_dat_lines {
my $self = shift;
local @disabled = @_; # we use @disabled in the nested sub
- my @lines = $self->_parse_hyphen_execute(\&make_dat_lines);
+ my @lines = $self->_parse_hyphen_execute(\&make_dat_lines, 'dat');
return @lines;
sub make_dat_lines {
- my ($name, $lhm, $rhm, $file, @syn) = @_;
+ my ($name, $lhm, $rhm, $file, $syn) = @_;
my @ret;
return if TeXLive::TLUtils::member($name, @disabled);
push @ret, "$name $file\n";
- foreach (@syn) {
+ foreach (@$syn) {
push @ret, "=$_\n";
}
return @ret;
@@ -1043,16 +1043,16 @@ sub language_dat_lines {
sub language_def_lines {
my $self = shift;
local @disabled = @_; # we use @disabled in the nested sub
- my @lines = $self->_parse_hyphen_execute(\&make_def_lines);
+ my @lines = $self->_parse_hyphen_execute(\&make_def_lines, 'def');
return @lines;
sub make_def_lines {
- my ($name, $lhm, $rhm, $file, @syn) = @_;
+ my ($name, $lhm, $rhm, $file, $syn) = @_;
return if TeXLive::TLUtils::member($name, @disabled);
my $exc = "";
my @ret;
push @ret, "\\addlanguage\{$name\}\{$file\}\{$exc\}\{$lhm\}\{$rhm\}\n";
- foreach (@syn) {
+ foreach (@$syn) {
# synonyms in language.def ???
push @ret, "\\addlanguage\{$_\}\{$file\}\{$exc\}\{$lhm\}\{$rhm\}\n";
#debug("Ignoring synonym $_ for $name when creating language.def\n");
@@ -1060,10 +1060,36 @@ sub language_def_lines {
return @ret;
}
}
-
+
+
+sub language_lua_lines {
+ my $self = shift;
+ local @disabled = @_; # we use @disabled in the nested sub
+ my @lines = $self->_parse_hyphen_execute(\&make_lua_lines, 'lua', '--');
+ return @lines;
+
+ sub make_lua_lines {
+ my ($name, $lhm, $rhm, $file, $syn, $patt, $hyph, $special) = @_;
+ return if TeXLive::TLUtils::member($name, @disabled);
+ my @syn = (@$syn); # avoid modifying the original
+ map { $_ = "'$_'" } @syn;
+ my @ret;
+ push @ret, "['$name'] = {", "\tloader = '$file',",
+ "\tlefthyphenmin = $lhm,", "\trighthyphenmin = $rhm,",
+ "\tsynonyms = { " . join(', ', @syn) . " },";
+ push @ret, "\tpatterns = '$patt'," if defined $patt;
+ push @ret, "\thyphenation = '$hyph'," if defined $hyph;
+ push @ret, "\tspecial = '$special'," if defined $special;
+ push @ret, '},';
+ map { $_ = "\t$_\n" } @ret;
+ return @ret;
+ }
+}
+
sub _parse_hyphen_execute {
- my ($obj, $coderef) = @_;
+ my ($obj, $coderef, $db, $cc) = @_;
+ $cc ||= '%'; # default comment char
my @langlines = ();
my $pkg = $obj->name;
my $first = 1;
@@ -1073,14 +1099,16 @@ sub _parse_hyphen_execute {
if (defined($r{"error"})) {
die "$r{'error'}, package $pkg, execute $e";
}
+ if (not TeXLive::TLUtils::member($db, @{$r{"databases"}})) {
+ next;
+ }
if ($first) {
- push @langlines, "% from $pkg:\n";
+ push @langlines, "$cc from $pkg:\n";
$first = 0;
}
- my @syns;
- @syns = @{$r{"synonyms"}} if (defined($r{"synonyms"}));
- my @foo = &$coderef ($r{"name"}, $r{"lefthyphenmin"},
- $r{"righthyphenmin"}, $r{"file"}, @syns);
+ my @foo = &$coderef ($r{"name"}, $r{"lefthyphenmin"},
+ $r{"righthyphenmin"}, $r{"file"}, $r{"synonyms"},
+ $r{"txtpatt"}, $r{"txthyph"}, $r{"luaspecial"});
push @langlines, @foo;
}
}
@@ -1638,6 +1666,11 @@ lines for language.dat that can be generated from the tlpobj
The function C<language_def_lines> returns the list of all
lines for language.def that can be generated from the tlpobj.
+=item C<< $tlpobj->language_lua_lines >>
+
+The function C<language_lua_lines> returns the list of all
+lines for language.dat.lua that can be generated from the tlpobj.
+
=back
=head1 SEE ALSO