From d0a562dbd34e1049feb01612499bf73a9b03b00e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 8 Jul 2015 22:43:36 +0000 Subject: makeglossaries-lite git-svn-id: svn://tug.org/texlive/trunk@37813 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/texk/texlive/linked_scripts/Makefile.am | 1 + .../source/texk/texlive/linked_scripts/Makefile.in | 1 + .../linked_scripts/glossaries/makeglossaries | 27 +- .../glossaries/makeglossaries-lite.lua | 469 +++++++++++++++++++++ .../source/texk/texlive/linked_scripts/scripts.lst | 1 + .../texk/texlive/linked_scripts/texlive/fmtutil.pl | 17 +- 6 files changed, 500 insertions(+), 16 deletions(-) create mode 100755 Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries-lite.lua (limited to 'Build') diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am index 17a15f0eac7..b12aa912f75 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.am +++ b/Build/source/texk/texlive/linked_scripts/Makefile.am @@ -113,6 +113,7 @@ texmf_other_scripts = \ fragmaster/fragmaster.pl \ getmap/getmapdl.lua \ glossaries/makeglossaries \ + glossaries/makeglossaries-lite.lua \ jfontmaps/kanji-config-updmap-sys.sh \ jfontmaps/kanji-config-updmap.pl \ jfontmaps/kanji-fontmap-creator.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in index 572170f8982..eb7278edb78 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.in +++ b/Build/source/texk/texlive/linked_scripts/Makefile.in @@ -329,6 +329,7 @@ texmf_other_scripts = \ fragmaster/fragmaster.pl \ getmap/getmapdl.lua \ glossaries/makeglossaries \ + glossaries/makeglossaries-lite.lua \ jfontmaps/kanji-config-updmap-sys.sh \ jfontmaps/kanji-config-updmap.pl \ jfontmaps/kanji-fontmap-creator.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries b/Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries index 90dc2a85dbc..d540043cfb6 100755 --- a/Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries +++ b/Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries @@ -2,7 +2,6 @@ # File : makeglossaries # Author : Nicola Talbot -# Version : 2.15 (2014/07/30) # Description: simple Perl script that calls makeindex or xindy. # Intended for use with "glossaries.sty" (saves having to remember # all the various switches) @@ -27,9 +26,13 @@ # glossary-super.sty, glossaries.perl. # Also makeglossaries and makeglossaries. -my $version="2.15 (2014-07-30)"; +my $version="2.16 (2015-06-28)"; # History: +# v2.16 (2015/06/28) +# * Added check for "german" and codepage that doesn't contain +# "din5007", "duden" or "braille". If missing, "din5007-" is +# prefixed to the codepage. # v2.15 (2014/07/30) # * Removed hard-coded three character extension assumption # www.dickimaw-books.com/cgi-bin/bugtracker.cgi?action=view&key=55 @@ -143,6 +146,7 @@ my %languagemap = 'magyar' => 'hungarian', 'naustrian' => 'german', 'ngermanb' => 'german', + 'ngerman' => 'german', # v2.16 'norsk' => 'norwegian', 'portuges' => 'portuguese', 'russianb' => 'russian', @@ -943,7 +947,7 @@ sub xindy{ } elsif ($language eq 'german') { - $codepage = "din"; + $codepage = "din5007"; } elsif ($language eq 'gypsy') { @@ -978,6 +982,13 @@ sub xindy{ $codepage = "utf"; } } + elsif ($language eq 'german' and $codepage!~/(din5007|duden|braille)/) + { +#v2.16 added check for german din/duden + + $codepage = "din5007-$codepage"; + } + my $codepageparam = ""; @@ -1141,6 +1152,7 @@ sub HELP_MESSAGE{ print "-q\t\tQuiet mode.\n"; print "-Q\t\tSilence unable to fork warning.\n"; print "-k\t\tDon't try to use piped redirection.\n"; + print "-l\t\tLetter ordering.\n"; print "-s \tEmploy as the style file.\n"; print "-t \tEmploy as the transcript file.\n"; print "\t\t(Don't use -t if you have more than one glossary\n"; @@ -1160,7 +1172,6 @@ sub HELP_MESSAGE{ print "options.)\n\n"; print "-c\t\tCompress intermediate blanks.\n"; print "-g\t\tEmploy German word ordering.\n"; - print "-l\t\tLetter ordering.\n"; print "-p \tSet the starting page number to be .\n"; print "-r\t\tDisable implicit page range formation.\n"; print "-m \tFull path to makeindex executable.\n", @@ -1230,6 +1241,10 @@ they have different style files. Use I as the transcript file. +=item B<-l> + +Letter ordering. + =item B<-L> I This option only has an effect if B is called. Sets the @@ -1243,10 +1258,6 @@ Compress intermediate blanks (B only). Employ German word ordering (B only). -=item B<-l> - -Letter ordering (B only). - =item B<-p> I Sets the starting page number to be I (B only). diff --git a/Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries-lite.lua b/Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries-lite.lua new file mode 100755 index 00000000000..0fc924d9881 --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/glossaries/makeglossaries-lite.lua @@ -0,0 +1,469 @@ +#!/usr/bin/env lua +--[[ + File : makeglossaries.lua + Author : Nicola Talbot + + Lua alternative to the makeglossaries Perl script. + + Since Lua has limitations, this script isn't an exact + replacement to the Perl script. In particular the makeglossaries -d + switch isn't implemented in this Lua version. + This also doesn't provide the more detailed diagnostics that the Perl + version does nor does it attempt any language mappings. Since xindy + requires Perl, don't use this script if you want to use xindy. Instead + use the Perl makeglossaries script. + + This file is distributed as part of the glossaries LaTeX package. + Copyright 2015 Nicola L.C. Talbot + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license or any later version. + The latest version of this license is in + http://www.latex-project.org/lppl.txt + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + +--]] + +thisversion = "1.0 2015-06-20" + +quiet = false +dryrun = false + +infile = nil +outfile = nil +styfile = nil +logfile = nil + +isxindy = false + +xindylang = nil +xindyexec = "xindy" + +makeindex_c = false +makeindex_g = false +letterorder = false +makeindex_r = false +makeindex_p = nil +makeindex_m = "makeindex" + +function version() + print(string.format("makeglossaries.lua version %s", thisversion)) + print("Copyright (C) 2015 Nicola L C Talbot") + print("This material is subject to the LaTeX Project Public License.") +end + +function help() + version() + print([[ +Syntax : makeglossaries.lua [options] + +For use with the glossaries package to pass relevant +files to makeindex or xindy. + + Base name of glossary file(s). This should + be the name of your main LaTeX document without any + extension. If you do add an extension, only that + glossary file will be processed. + +General Options: + +-o Use as the output file. + (Don't use -o if you have more than one glossary.) +-s Employ as the style file. +-t Employ as the transcript file. + (Don't use -t if you have more than one glossary + or the transcripts will be overwritten.) +-q Quiet mode. +-l Letter ordering. +-n Print the command that would normally be executed, + but don't execute it (dry run). +--help Print this help message. +--version Print the version. + +Xindy Options: + +-L Use . +-x Full path to xindy executable. + (Default assumes xindy is on the operating system's path.) + +Makeindex Options: +(See makeindex documentation for further details on these options.) + +-c Compress intermediate blanks. +-g Employ German word ordering. +-p Set the starting page number to be . +-r Disable implicit page range formation. +-m Full path to makeindex executable. + (Default assumes makeindex is on the operating system's path.) + +This is a light-weight Lua alternative to the makeglossaries Perl script. +If you want to use xindy, it's better to use the Perl makeglossaries version +instead. +]]) +end + +function dorun(name, glg, gls, glo, language, codepage) + + if isxindy then + doxindy(name, glg, gls, glo, language, codepage) + else + domakeindex(name, glg, gls, glo) + end + +end + +function doxindy(name, glg, gls, glo, language, codepage) + + cmd = string.format('"%s" -I xindy -L %s -C %s -M "%s" -t "%s" -o "%s"', + xindyexec, language, codepage, styfile, glg, gls) + + if letterorder then cmd = string.format('%s -M ord/letorder', cmd) end + + if quiet then cmd = string.format('%s -q', cmd) end + + cmd = string.format('%s "%s"', cmd, glo) + + if dryrun then + + print(cmd) + + else + + assert(os.execute(cmd), + string.format("Failed to execute '%s'", cmd)) + + end + +end + +function domakeindex(name, glg, gls, glo) + + cmd = string.format('"%s"', makeindex_m) + + if makeindex_c then cmd = cmd .. " -c" end + + if makeindex_g then cmd = cmd .. " -g" end + + if letterorder then cmd = cmd .. " -l" end + + if quiet then cmd = cmd .. " -q" end + + if glg ~= nil then cmd = string.format('%s -t "%s"', cmd, glg) end + + if gls ~= nil then cmd = string.format('%s -o "%s"', cmd, gls) end + + if makeindex_p ~= nil then + cmd = string.format("%s -p %s", cmd, makeindex_p) + end + + if styfile ~= nil then + cmd = string.format('%s -s "%s"', cmd, styfile) + end + + cmd = string.format('%s "%s"', cmd, glo) + + if dryrun then + print(cmd) + else + assert(os.execute(cmd), + string.format("Failed to execute '%s'", cmd)) + end + +end + +if #arg < 1 +then + error("Syntax error: filename expected. Use --help for help.") +end + +i = 1 + +while i <= #arg do + +-- General Options + if arg[i] == "-q" then + quiet = true + elseif arg[i] == "-n" + then + dryrun = true + elseif arg[i] == "-o" + then + i = i + 1 + if i > #arg then error("-o requires a filename") end + outfile = arg[i] + elseif arg[i] == "-s" + then + i = i + 1 + if i > #arg then error("-s requires a filename") end + styfile = arg[i] + elseif arg[i] == "-t" + then + i = i + 1 + if i > #arg then error("-t requires a filename") end + logfile = arg[i] + elseif arg[i] == "--version" + then + version() + os.exit() + elseif arg[i] == "--help" + then + help() + os.exit() +-- General options for the Perl version that aren't implemented by +-- this light-weight version: + elseif (arg[i] == "-Q") or (arg[i] == "-k") + then + print(string.format("Ignoring option '%s' (only available with the Perl version).", arg[i])) + elseif arg[i] == "-d" + then + error(string.format( + "The '%s' option isn't available for this light-weight version.\nYou will need to use the Perl version instead.", + arg[i])) + +-- Xindy Options + elseif arg[i] == "-L" + then + i = i + 1 + if i > #arg then error("-L requires a language name") end + xindylang = arg[i] + elseif arg[i] == "-x" + then + i = i + 1 + if i > #arg then error("-x requires a filename") end + xindyexec = arg[i] + +-- Makeindex Options + elseif arg[i] == "-c" + then + makeindex_c = true + elseif arg[i] == "-g" + then + makeindex_g = true + elseif arg[i] == "-l" + then + letterorder = true + elseif arg[i] == "-r" + then + makeindex_r = true + elseif arg[i] == "-p" + then + i = i + 1 + if i > #arg then error("-p requires a page number") end + makeindex_p = arg[i] + elseif arg[i] == "-m" + then + i = i + 1 + if i > #arg then error("-m requires a filename") end + makeindex_m = arg[i] + +-- Unknown Option + elseif string.sub(arg[i], 1, 1) == "-" + then + error( + string.format("Syntax error: unknown option '%s'. Use '--help' for help.", + arg[i])); + +-- Input file + elseif infile == nil + then + infile = arg[i] + else + error("Syntax error: only one filename permitted"); + end + + i = i + 1 +end + +if not quiet then + print(string.format("makeglossaries.lua version %s", thisversion)) +end + +if infile == nil +then + error("Syntax error: missing filename") +end + +i, j = string.find(infile, "%.%a*$") + +ext = nil +inbase = infile + +if i ~= nil +then + ext = string.sub(infile, i, j); + + lext = string.lower(ext) + + inbase = string.sub(infile, 1, i-1); + + -- Just in case user has accidentally specified the aux or tex file + if lext == ".aux" or lext == ".tex" + then + ext = nil + infile = inbase + end +end + +auxfile = inbase..".aux" + +if not quiet then print(string.format("Parsing '%s'", auxfile)) end + +assert(io.input(auxfile), + string.format("Unable to open '%s'", auxfile)) + +aux = io.read("*a") + +if styfile == nil +then + styfile = string.match(aux, "\\@istfilename{\"?([^}]*%.?%a*)\"?}") + + if styfile == nil + then + error([[ +No \@istfilename found. +Did your LaTeX run fail? +Did your LaTeX run produce any output? +Did you remember to use \makeglossaries? + ]]) + end +end + +i = string.len(styfile) + +if string.sub(styfile, i-3, i) == ".xdy" +then + isxindy = true +end + +if not letterorder +then + if string.match(aux, "\\@glsorder{letter}") ~= nil + then + letterorder = true + end +end + +if dryrun then print("Dry run mode. No commands will be executed.") end + +onlyname = nil + +glossaries = {} + +for name, glg, gls, glo in + string.gmatch(aux, "\\@newglossary{([^}]+)}{([^}]+)}{([^}]+)}{([^}]+)}") do + + if not quiet then + print(string.format("Found glossary type '%s' (%s,%s,%s)", + name, glg, gls, glo)) + end + + glossaries[name] = {} + + glossaries[name].glg = glg + glossaries[name].gls = gls + glossaries[name].glo = glo + + if "."..glo == ext then + + onlyname = name + + end + + if isxindy then + + if xindylang == nil then + glossaries[name].language = string.match(aux, + "\\@xdylanguage{"..name.."}{([^}]+)}"); + else + glossaries[name].language = xindylang + end + + glossaries[name].codepage = string.match(aux, + "\\@gls@codepage{"..name.."}{([^}]+)}"); + + end + +end + + +if ext == nil +then + + done = false + + for name, value in pairs(glossaries) do + + glg = value.glg + gls = value.gls + glo = value.glo + + if logfile == nil then + glg = inbase .. "." .. glg + else + glg = logfile + end + + if outfile == nil then + gls = inbase .. "." .. gls + else + gls = outfile + end + + glo = infile .. "." .. glo + + dorun(name, glg, gls, glo, value.language, value.codepage) + + done = true + end + + if not done then + error([[ +No \@newglossary commands found in aux file. +Did you remember to use \makeglossaries? +Did you accidentally suppress the default glossary using "nomain" +and not provide an alternative glossary? +]]) + end + +else + + if onlyname == nil then + + glo = infile + gls = outfile + glg = logfile + + language = xindylang + codepage = 'utf8' + + if language == nil then language = 'english' end + + if gls == nil then gls = infile..".gls" end + + else + + value = glossaries[onlyname] + + glg = value.glg + gls = value.gls + glo = infile + + if logfile == nil then + glg = inbase .. "." .. glg + else + glg = logfile + end + + if outfile == nil then + gls = inbase .. "." .. gls + else + gls = outfile + end + + end + + dorun(onlyname, glg, gls, glo, language, codepage) +end diff --git a/Build/source/texk/texlive/linked_scripts/scripts.lst b/Build/source/texk/texlive/linked_scripts/scripts.lst index 881374bee1d..1df5fa74d6b 100644 --- a/Build/source/texk/texlive/linked_scripts/scripts.lst +++ b/Build/source/texk/texlive/linked_scripts/scripts.lst @@ -59,6 +59,7 @@ fontools/ot2kpx fragmaster/fragmaster.pl getmap/getmapdl.lua glossaries/makeglossaries +glossaries/makeglossaries-lite.lua jfontmaps/kanji-config-updmap-sys.sh jfontmaps/kanji-config-updmap.pl jfontmaps/kanji-fontmap-creator.pl diff --git a/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl b/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl index 9585cfb9d9f..f3b09ceab7b 100755 --- a/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl +++ b/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl @@ -716,10 +716,11 @@ sub callback_enable_disable_format { if ($alldata->{'merged'}{$fmt}) { my @engs = keys %{$alldata->{'merged'}{$fmt}}; if (($#engs > 0) || ($#engs == -1)) { - print_warning("Selected format $fmt not uniquely defined,\n"); - print_warning("possible format/engines combinations:\n"); + print_warning("Selected format $fmt not uniquely defined;\n"); + print_warning("possible format/engine combinations:\n"); for my $e (@engs) { - print_warning(" $fmt/$e (currently " . $alldata->{'merged'}{$fmt}{$e}{'status'} . ")\n"); + print_warning(" $fmt/$e (currently " + . $alldata->{'merged'}{$fmt}{$e}{'status'} . ")\n"); } print_warning("Please select one by fully specifying $fmt/ENGINE\n"); print_warning("No changes done.\n"); @@ -729,8 +730,8 @@ sub callback_enable_disable_format { return enable_disable_format_engine($tc, $fmt, $engs[0], $mode); } } else { - print_warning("Format $fmt is not defined.\n"); - print_warning("Cannot (de)activate it.\n"); + print_warning("Format $fmt is not defined;\n"); + print_warning("cannot (de)activate it.\n"); return -1; } } @@ -1175,9 +1176,9 @@ Commands: --byhyphen HYPHENFILE (re)create formats that depend on HYPHENFILE --enablefmt FORMATNAME[/ENGINE] enable formatname in config file --disablefmt FORMATNAME[/ENGINE] disable formatname in config file - If more formats share the same name but have - different engines, the ENGINE parameter is - obligatory. + If multiple formats have the same name but + different engines, the /ENGINE specifier is + required. --listcfg list (enabled and disabled) configurations, filtered to available formats --catcfg output the content of the config file -- cgit v1.2.3