diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-05-20 17:08:42 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-05-20 17:08:42 +0000 |
commit | cce69ad0b59b059976669eb922832fd161493af8 (patch) | |
tree | 7ea283771d719501e6af00fe5df7643769331d68 /Master/tlpkg | |
parent | 3df5aab7ab8f7c7d8b9c11ddfb4278a4f6948f7c (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')
-rw-r--r-- | Master/tlpkg/TeXLive/TLPDB.pm | 24 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLPOBJ.pm | 59 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLPSRC.pm | 11 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 53 |
4 files changed, 125 insertions, 22 deletions
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm index 811556c77bc..8993105264c 100644 --- a/Master/tlpkg/TeXLive/TLPDB.pm +++ b/Master/tlpkg/TeXLive/TLPDB.pm @@ -52,6 +52,7 @@ C<TeXLive::TLPDB> -- A database of TeX Live Packages $tlpdb->fmtutil_cnf_lines; $tlpdb->language_dat_lines; $tlpdb->language_def_lines; + $tlpdb->language_lua_lines; $tlpdb->package_revision("packagename"); $tlpdb->location; $tlpdb->config_src_container; @@ -1346,7 +1347,28 @@ sub language_def_lines { } return(@lines); } - + +=item C<< $tlpdb->language_lua_lines ( [@disabled_hyphen_names] ) >> + +The function C<language_lua_lines> returns the list of all +lines for language.dat.lua that can be generated from the tlpdb. + +Every hyphenation pattern listed in the tlpdb but listed in the arguments +will not be included in the list of lines returned. + +=cut + +sub language_lua_lines { + my $self = shift; + my @lines; + foreach my $p ($self->list_packages) { + my $obj = $self->get_package ($p); + die "$0: No TeX Live package named $p, strange" if ! $obj; + push @lines, $obj->language_lua_lines(@_); + } + return(@lines); +} + =back =pod 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 diff --git a/Master/tlpkg/TeXLive/TLPSRC.pm b/Master/tlpkg/TeXLive/TLPSRC.pm index b5f044402b0..d3b870c490d 100644 --- a/Master/tlpkg/TeXLive/TLPSRC.pm +++ b/Master/tlpkg/TeXLive/TLPSRC.pm @@ -791,8 +791,15 @@ the font cache for luatex. activates the hyphenation pattern with name I<texlang> and load the file I<file> for that language. The additional variables I<var> are: -C<lefthyphenmin>, C<righthyphenmin> (both integers), and C<synonyms> (a -comma-separated list of alias names for that hyphenation). +C<lefthyphenmin>, C<righthyphenmin> (both integers), C<synonyms> (a +comma-separated list of alias names for that hyphenation), C<databases> +(a comma-separated list of databases the entry should go in; currently +recognized are: C<dat> (C<language.dat>), C<def> (C<language.def>) and +C<lua> (C<language.dat.lua>)), C<txtpatt> and C<txthyph> (files with the +patterns (resp. exceptions) in plain txt), and C<luaspecial> (string). + +The variable C<databases> defaults to C<dat,def>, or C<dat,def,lua> if +one of the keys C<txtpatt>, C<txthyph> or C<luaspecial> is used. =item C<execute AddFormat name=I<fmt> engine=I<eng> [I<var>...]> diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index b416a008242..f2504f62d5c 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -69,6 +69,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure TeXLive::TLUtils::create_updmap($tlpdb,$dest,$localconf); TeXLive::TLUtils::create_language_dat($tlpdb,$dest,$localconf); TeXLive::TLUtils::create_language_def($tlpdb,$dest,$localconf); + TeXLive::TLUtils::create_language_lua($tlpdb,$dest,$localconf); TeXLive::TLUtils::time_estimate($totalsize, $donesize, $starttime) TeXLive::TLUtils::install_packages($from_tlpdb,$media,$to_tlpdb,$what,$opt_src, $opt_doc)>); TeXLive::TLUtils::install_package($what, $filelistref, $target, $platform); @@ -129,6 +130,7 @@ BEGIN { &create_updmap &create_language_dat &create_language_def + &create_language_lua &parse_AddFormat_line &parse_AddHyphen_line &sort_uniq @@ -2344,11 +2346,13 @@ sub make_local_skeleton { =item C<create_language_def($tlpdb, $dest, $localconf)> -These four functions create C<fmtutil.cnf>, C<updmap.cfg>, C<language.dat>, -and C<language.def> respectively, in C<$dest> (which by default is below -C<$TEXMFSYSVAR>). These functions merge the information present in the -TLPDB C<$tlpdb> (formats, maps, hyphenations) with local configuration -additions: C<$localconf>. +=item C<create_language_lua($tlpdb, $dest, $localconf)> + +These five functions create C<fmtutil.cnf>, C<updmap.cfg>, C<language.dat>, +C<language.def>, and C<language.dat.lua> respectively, in C<$dest> (which by +default is below C<$TEXMFSYSVAR>). These functions merge the information +present in the TLPDB C<$tlpdb> (formats, maps, hyphenations) with local +configuration additions: C<$localconf>. Currently the merging is done by omitting disabled entries specified in the local file, and then appending the content of the local @@ -2497,6 +2501,16 @@ sub create_language_def { _create_config_files ($tlpdb, "texmf/tex/generic/config/language.us.def", $dest, $localconf, 1, '%', \@lines, @postlines); } +sub create_language_lua { + my ($tlpdb,$dest,$localconf) = @_; + # no checking for disabled stuff for language.dat and .lua + my @lines = $tlpdb->language_lua_lines( + get_disabled_local_configs($localconf, '--')); + my @postlines = ("}\n"); + _create_config_files ($tlpdb, "texmf/tex/generic/config/language.us.lua", + $dest, $localconf, 0, '--', \@lines, @postlines); +} + sub _create_config_files { my ($tlpdb, $headfile, $dest,$localconf, $keepfirstline, $cc, $tlpdblinesref, @postlines) = @_; my $root = $tlpdb->root; @@ -2533,11 +2547,13 @@ sub _create_config_files { sub parse_AddHyphen_line { my $line = shift; my %ret; + # default values my $default_lefthyphenmin = 2; my $default_righthyphenmin = 3; $ret{"lefthyphenmin"} = $default_lefthyphenmin; $ret{"righthyphenmin"} = $default_righthyphenmin; - for my $p (split(' ', $line)) { + $ret{"synonyms"} = []; + for my $p (quotewords('\s+', 0, "$line")) { my ($a, $b) = split /=/, $p; if ($a eq "name") { if (!$b) { @@ -2563,6 +2579,22 @@ sub parse_AddHyphen_line { $ret{"file"} = $b; next; } + if ($a eq "txtpatt") { + $ret{"txtpatt"} = $b; + next; + } + if ($a eq "txthyph") { + $ret{"txthyph"} = $b; + next; + } + if ($a eq "luaspecial") { + $ret{"luaspecial"} = $b; + next; + } + if ($a eq "databases") { + @{$ret{"databases"}} = split /,/, $b; + next; + } if ($a eq "synonyms") { @{$ret{"synonyms"}} = split /,/, $b; next; @@ -2571,6 +2603,15 @@ sub parse_AddHyphen_line { $ret{"error"} = "Unknown language directive $e"; return %ret; } + # this default value couldn't be set earlier + if (not defined($ret{"databases"})) { + if (defined $ret{"txtpatt"} or defined $ret{"txthyph"} + or defined $ret{"luaspecial"}) { + @{$ret{"databases"}} = qw(dat def lua); + } else { + @{$ret{"databases"}} = qw(dat def); + } + } return %ret; } |