diff options
author | Karl Berry <karl@freefriends.org> | 2010-12-30 01:09:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-12-30 01:09:42 +0000 |
commit | d406d15b92210aa3bc187073d0e2b1ac23c8e7ec (patch) | |
tree | 9d96394702d85d056caab6adc8ee1df1a9cd5421 /Master | |
parent | 472e6fd0b5ea269f9946989092417642c3f3aeaf (diff) |
luamplib 1.07 (28dec10)
git-svn-id: svn://tug.org/texlive/trunk@20881 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/NEWS | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf | bin | 167686 -> 302763 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex | 9 | ||||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex | 7 | ||||
-rw-r--r-- | Master/texmf-dist/source/luatex/luamplib/Makefile | 110 | ||||
-rw-r--r-- | Master/texmf-dist/source/luatex/luamplib/luamplib.dtx | 466 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua | 55 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 167 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 54 |
9 files changed, 272 insertions, 601 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS index a9f08e5ee6f..d1214c0e98d 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/NEWS +++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS @@ -1,5 +1,10 @@ History of the luamplib package +2010/12/28 + * fix two bugs reported by Arno Trautmann that made the package crash with + luatex 0.65 (mp 1.5+). + * remove support for using .mem files (to fix the second bug) + 2010/10/17 v1.06 * bugfix from Hans (bad function name) diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf Binary files differindex 5ae070a30fe..db0da7647a4 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf +++ b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf diff --git a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex new file mode 100644 index 00000000000..fc1b189169e --- /dev/null +++ b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex @@ -0,0 +1,9 @@ +\documentclass{article} +\usepackage{luamplib} +\begin{document} +\begin{mplibcode} +beginfig(1); + fill fullcircle scaled 20; +endfig; +\end{mplibcode} +\end{document} diff --git a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex new file mode 100644 index 00000000000..fb45fb058f0 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex @@ -0,0 +1,7 @@ +\input luamplib.sty +\mplibcode +beginfig(1); + fill fullcircle scaled 20; +endfig; +\endmplibcode +\bye diff --git a/Master/texmf-dist/source/luatex/luamplib/Makefile b/Master/texmf-dist/source/luatex/luamplib/Makefile index c1c7ceda970..8089ad6ff73 100644 --- a/Master/texmf-dist/source/luatex/luamplib/Makefile +++ b/Master/texmf-dist/source/luatex/luamplib/Makefile @@ -1,53 +1,51 @@ -# Makefile for luamplib - -NAME = luamplib -DOC = $(NAME).pdf -DTX = $(NAME).dtx - -# Files grouped by generation mode -COMPILED = $(DOC) -UNPACKED = luamplib-createmem.lua luamplib.lua luamplib.sty -SOURCE = $(DTX) README Makefile NEWS -GENERATED = $(COMPILED) $(UNPACKED) - -# Files grouped by installation location -RUNFILES = $(UNPACKED) -DOCFILES = $(DOC) README NEWS -SRCFILES = $(DTX) Makefile - -# The following definitions should be equivalent -# ALL_FILES = $(RUNFILES) $(DOCFILES) $(SRCFILES) -ALL_FILES = $(GENERATED) $(SOURCE) - -# Installation locations -FORMAT = luatex -RUNDIR = $(TEXMFROOT)/tex/$(FORMAT)/$(NAME) -DOCDIR = $(TEXMFROOT)/doc/$(FORMAT)/$(NAME) -SRCDIR = $(TEXMFROOT)/source/$(FORMAT)/$(NAME) -TEXMFROOT = ./texmf +NAME = luamplib +FORMAT = luatex + +DTX = $(NAME).dtx +DOC = $(NAME).pdf +STY = $(NAME).sty +LUA = $(NAME).lua +TEST = test-$(NAME)-plain.tex test-$(NAME)-latex.tex + +UNPACKED = $(STY) $(LUA) +GENERATED = $(UNPACKED) $(DOC) +SOURCES = $(DTX) README NEWS Makefile $(TEST) + +DOCFILES = $(DOC) $(TEST) README NEWS +SRCFILES = $(DTX) Makefile +RUNFILES = $(STY) $(LUA) + +ALL = $(SRCFILES) $(DOCFILES) $(RUNFILES) -CTAN_ZIP = $(NAME).zip -TDS_ZIP = $(NAME).tds.zip -ZIPS = $(CTAN_ZIP) $(TDS_ZIP) +TEXMFROOT = ./texmf +RUNDIR = $(TEXMFROOT)/tex/$(FORMAT)/$(NAME) +DOCDIR = $(TEXMFROOT)/doc/$(FORMAT)/$(NAME) +SRCDIR = $(TEXMFROOT)/source/$(FORMAT)/$(NAME) -DO_TEX = tex --interaction=batchmode $< >/dev/null -DO_PDFLATEX = pdflatex --interaction=batchmode $< >/dev/null +CTAN_ZIP = $(NAME).zip +TDS_ZIP = $(NAME).tds.zip +ZIPS = $(CTAN_ZIP) $(TDS_ZIP) all: $(GENERATED) doc: $(COMPILED) unpack: $(UNPACKED) -ctan: $(CTAN_ZIP) +ctan: check $(CTAN_ZIP) tds: $(TDS_ZIP) world: all ctan -$(COMPILED): $(DTX) - $(DO_PDFLATEX) - $(DO_PDFLATEX) +.PHONY: all doc unpack ctan tds check world + +%.pdf: %.dtx + latexmk -pdf -silent $< >/dev/null $(UNPACKED): $(DTX) - $(DO_TEX) + tex -interaction=batchmode $< >/dev/null + +check: $(UNPACKED) + luatex -interaction=batchmode test-$(NAME)-plain.tex >/dev/null + lualatex -interaction=batchmode test-$(NAME)-latex.tex >/dev/null -$(CTAN_ZIP): $(SOURCE) $(COMPILED) $(TDS_ZIP) +$(CTAN_ZIP): $(SOURCES) $(COMPILED) $(TDS_ZIP) @echo "Making $@ for CTAN upload." @$(RM) -- $@ @zip -9 $@ $^ >/dev/null @@ -59,29 +57,35 @@ define run-install endef $(TDS_ZIP): TEXMFROOT=./tmp-texmf -$(TDS_ZIP): $(ALL_FILES) +$(TDS_ZIP): $(ALL) @echo "Making TDS-ready archive $@." @$(RM) -- $@ + @if test -e $(TEXMFROOT); then echo 'bad TEXMFROOT'; false; fi $(run-install) - @cd $(TEXMFROOT) && zip -9 ../$@ -r . >/dev/null + @cd $(TEXMFROOT) && zip -q -9 ../$@ -r . @$(RM) -r -- $(TEXMFROOT) -.PHONY: install manifest clean mrproper +.PHONY: install clean mrproper help -install: $(ALL_FILES) +install: check $(ALL) @echo "Installing in '$(TEXMFROOT)'." $(run-install) -manifest: - @echo "Source files:" - @for f in $(SOURCE); do echo $$f; done - @echo "" - @echo "Derived files:" - @for f in $(GENERATED); do echo $$f; done - -clean: - @$(RM) -- *.log *.aux *.toc *.idx *.ind *.ilg *.out +clean: + @latexmk -silent -c $(DTX) >/dev/null + @rm -f -- *.log mrproper: clean - @$(RM) -- $(GENERATED) $(ZIPS) - + @rm -f -- $(GENERATED) $(ZIPS) + +help: + @echo '$(NAME) makefile targets:' + @echo ' help - (this message)' + @echo ' all - (default target) all generated files' + @echo ' world - synonymous for ctan' + @echo ' unpack - extract all files' + @echo ' doc - compile documentation' + @echo ' ctan - run check & generate archive for CTAN' + @echo ' tds - generate a TDS compliant archive' + @echo ' check - run the test files' + @echo ' install TEXMFROOT=<path> - install in <path>' diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx index ed2680ef509..d6aa0c705d2 100644 --- a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx +++ b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx @@ -1,29 +1,22 @@ -% \iffalse meta-comment +% \iffalse meta-comment -- by the way, this file contains UTF-8 % -% Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux -% <elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) +% Copyright (C) 2008-2010 by Hans Hagen, Taco Hoekwater, Elie Roux, and +% Manuel Pégourié-Gonnard. +% Currently maintained by Manuel Pégourié-Gonnard <mpg@elzevir.fr> +% Support: <lualatex-dev@tug.org> % % This work is under the CC0 license. % -% This Current Maintainer of this work is Elie Roux. -% % This work consists of the main source file luamplib.dtx % and the derived files -% luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. -% +% luamplib.sty, luamplib.lua and luamplib.pdf. % % Unpacking: % tex luamplib.dtx -% +% % Documentation: % pdflatex luamplib.dtx % -% The class ltxdoc loads the configuration file ltxdoc.cfg -% if available. Here you can specify further options, e.g. -% use A4 as paper format: -% \PassOptionsToClass{a4paper}{article} -% -% %<*ignore> \begingroup \def\x{LaTeX2e}% @@ -46,18 +39,8 @@ \let\MetaPrefix\relax \preamble -This is a generated file. -Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux -<elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) - -This work is under the CC0 license. - -This Current Maintainer of this work is Elie Roux. - -This work consists of the main source file luamplib.dtx -and the derived files - luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. +See source file '\inFileName' for licencing and contact information. \endpreamble @@ -68,9 +51,6 @@ and the derived files \file{luamplib.sty}{\from{luamplib.dtx}{package}}% } -% The following hacks are to generate a lua file with lua comments starting by -% -- instead of %% - \def\MetaPrefix{-- } \def\luapostamble{% @@ -83,7 +63,6 @@ and the derived files \generate{% \usedir{tex/luatex/mplib}% \file{luamplib.lua}{\from{luamplib.dtx}{lua}}% - \file{luamplib-createmem.lua}{\from{luamplib.dtx}{gen-lua}}% } \obeyspaces @@ -104,19 +83,29 @@ and the derived files \fi %</ignore> %<*driver> -\NeedsTeXFormat{LaTeX2e} -\ProvidesFile{luamplib.drv}% - [2010/10/17 v1.06 mplib package for LuaTeX]% \documentclass{ltxdoc} -\usepackage{hyperref} -\newcommand*\email[1]{\href{mailto:#1}{#1}} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage{lmodern} +\usepackage{fixltx2e} + +\usepackage[a4paper]{geometry} +\usepackage[english]{babel} +\usepackage[colorlinks]{hyperref} +\usepackage{bookmark} + +\newcommand*\email [1] {<\href{mailto:#1}{#1}>} +\newcommand \file {\nolinkurl} +\newcommand \pk {\textsf} + \begin{document} \DocInput{luamplib.dtx}% \end{document} %</driver> % \fi % -% \CheckSum{2} +% \CheckSum{0} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -135,9 +124,10 @@ and the derived files % Right brace \} Tilde \~} % % \title{The \textsf{luamplib} package} -% \date{2010/10/17 v1.06} % \author{Hans Hagen, Taco Hoekwater and Elie Roux \\ +% Maintainer: Manuel Pégourié-Gonnard --- % Support: \email{lualatex-dev@tug.org}} +% \date{2010/12/28 v1.07} % % \maketitle % @@ -153,7 +143,7 @@ and the derived files % wrapper (in Lua) for the Lua \texttt{mplib} functions and some \TeX\ % functions to have the output of the \texttt{mplib} functions in the pdf. % -% The package need to be in PDF mode in order to output something, as PDF +% The package needs to be in PDF mode in order to output something, as PDF % specials are not supported by the DVI format and tools. % % The metapost figures are put in a \TeX\ \texttt{hbox} with dimensions @@ -166,248 +156,153 @@ and the derived files % \begin{itemize} % \item a \LaTeX\ environment % \item all \TeX\ macros start by \texttt{mplib} -% \item use of the luatexbase printing and module functions -% \item adapted warning, error and log messages +% \item use of luatexbase for errors, warnings and declaration % \end{itemize} % % Using this package is easy: in Plain, type your metapost code between the % macros \texttt{mplibcode} and \texttt{endmplibcode}, and in \LaTeX\ in the % \texttt{mplibcode} environment. % -% In order to use metapost, some \texttt{.mem} files are needed. These files -% must be generated with the same version of \texttt{mplib} as the version of -% Lua\TeX . These files names can be changed, they are by default -% \texttt{mpost.mem} and \texttt{mpfun.mem}. If this package is -% to be included in a distribution, some values may have to be changed in the -% file \texttt{luamplib.lua}, see comments. -% -% If your distribution does not provide valid \texttt{.mem} files (\TeX Live -% 2009 will be the first), you'll have to generate and install them by hand, -% with the script \texttt{luamplib-createmem.lua} included in this package -% if you want them. +% There are (basically) two formats for metapost: \emph{plain} and +% \emph{mpfun}. By default, the \emph{plain} format is used, but you can set +% the format to be used by future figures at any time using +% \cs{mplibsetformat}\marg{format name}. % -% These .mem files are not mandatory though. If this package doesn't find the -% mem files, it will just input the \texttt{.mp} file, and work without problem; -% the only difference is that it may be a bit slower but this is not noticeable -% on a modern computer. +% \section{Implementation} % -% \section{Files} -% -% This package contains three files: -% \begin{itemize} -% \item \texttt{luamplib.lua} containing the lua code that calls mplib -% \item \texttt{luamplib.sty} containing the macros for \LaTeX\ and Plain -% \item \texttt{create-mem.lua}, a standalone mem generation script -% \end{itemize} +% \subsection{Lua module} % -% \iffalse +% \begin{macrocode} %<*lua> -% \fi -% -% \subsection{\texttt{luamplib.lua}} +% \end{macrocode} % -% First the \texttt{luamplib} module is registered as a Lua\TeX\ module, -% with some informations. Here we can't name it \texttt{mplib}, as the name -% is already taken. +% Use the |luamplib| namespace, since |mplib| is for the metapost library +% itself. % % \begin{macrocode} - module('luamplib', package.seeall) - -luamplib.module = { +% \end{macrocode} +% +% Identification, and additional reporting function, for compatibility with +% the original |report()| function and associated data structure. +% +% \begin{macrocode} +local err, warn, info, log = luatexbase.provides_module({ name = "luamplib", - version = 1.06, - date = "2010/10/17", + version = 1.07, + date = "2010/12/28", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", - author = "Hans Hagen, Taco Hoekwater & Elie Roux", - copyright = "ConTeXt Development Team & Elie Roux", - license = "CC0", -} +}) -luatexbase.provides_module(luamplib.module) +local function term(...) + texio.write_nl('term', 'luamplib: ' .. string.format(...)) +end % \end{macrocode} +% % This module is a stripped down version of libraries that are used by -% Con\TeX t. +% Con\TeX t. Provide a few ``shortcuts'' expected by the imported code. +% % \begin{macrocode} - local format, concat, abs = string.format, table.concat, math.abs % \end{macrocode} -% -% The \texttt{mem} file and the format name are hardcoded, and they can be -% set with \TeX\ if it's useful. The \TeX\ distributions should change -% these values if necessary. +% +% This is a small trick for \LaTeX . In \LaTeX\ we read the metapost code +% line by line, but it needs to be passed entirely to |process()|, so we +% simply add the lines in |data| and at the end we call |process(data)|. % % \begin{macrocode} +local data = "" -luamplib.currentformat = "plain" -luamplib.currentmem = "mplib-luatex" - -local currentformat = luamplib.currentformat -local currentmem = luamplib.currentmem - -function luamplib.setformat (name) - luamplib.currentformat = name +local function resetdata() + data = "" end - -function luamplib.setmemfile(name) - luamplib.currentmem = name +function addline(line) + data = data .. '\n' .. line +end +function processlines() + process(data) + resetdata() end % \end{macrocode} % -% We use the \texttt{kpse} library and make it behave like when used -% with Metapost. To find the .mem files with kpse, we have to make a -% small hack... that might be a little bug. +% As the finder function for |mplib|, use the |kpse| library and +% make it behave like as if MetaPost was used (or almost, since the engine +% name is not set this way---not sure if this is a problem). % % \begin{macrocode} +local mpkpse = kpse.new("luatex", "mpost") -local mpkpse = kpse.new("luatex","mpost") - -function luamplib.finder(name, mode, ftype) +local function finder(name, mode, ftype) if mode == "w" then return name else - local result = mpkpse:find_file(name,ftype) - if not result and ftype == "mem" then - result = mpkpse:find_file("metapost/"..name,ftype) - end - return result + return mpkpse:find_file(name,ftype) end end -function luamplib.info (...) - luatexbase.module_info('luamplib', format(...)) -end - -function luamplib.log (...) - luatexbase.module_log('luamplib', format(...)) -end - -function luamplib.term (...) - luatexbase.module_term('luamplib', format(...)) -end - -function luamplib.warning (...) - luatexbase.module_warning('luamplib', format(...)) -end - -function luamplib.error (...) - luatexbase.module_error('luamplib', format(...)) -end - % \end{macrocode} % -% This is a small hack for \LaTeX . In \LaTeX\ we read the metapost code -% line by line, but it needs to be passed entirely to -% \texttt{luamplib.process}, so we simply add the lines in -% \texttt{luamplib.data} and at the end we call \texttt{luamplib.process} -% on \texttt{luamplib.data}. +% Default format name, and a public function to change it. % % \begin{macrocode} +local currentformat = "plain" -luamplib.data = "" - -function luamplib.resetdata() - luamplib.data = "" -end - -function luamplib.addline(line) - luamplib.data = luamplib.data .. '\n' .. line -end - -function luamplib.processlines() - luamplib.process(luamplib.data) - luamplib.resetdata() +function setformat (name) + currentformat = name end % \end{macrocode} % -% -% \begin{macro}{luamplib.input mp} -% -% This function creates a new mplib object and inputs the -% good .mp file. It's less efficient than loading the .mem -% file, but it works more safely, as the .mp file does not -% depend on the version of the mpost program. +% Create a new mplib object and input the correct .mp file as given by +% |currentformat|. With older versions of MetaPost, using a |mem| file may +% be more efficient, but newer versions don't support it any more so for +% the sake of simplicity, don't even try to use a |mem| file. +% |ini_version| is ignored by new versions but is useful to prevent old +% ones from trying to load a |mem| file. % % \begin{macrocode} - -function luamplib.input_mp(name) +function load() local mpx = mplib.new { + find_file = finder, ini_version = true, - find_file = luamplib.finder, - job_name = name, - } - mpx:execute(format("input %s ;",name)) - return mpx -end - -% \end{macrocode} -% -% \end{macro} -% -% \begin{macro}{luamplib.load} -% -% This function is the one loading the metapost format we want. It uses the -% \texttt{luamplib.currentformat} and \texttt{luamplib.currentmem} to -% determine the format and the mem file to use. -% -% The rest of this module is not documented. More info can be found in the -% Lua\TeX\ manual, articles in user group journals and the files that ship -% with Con\TeX t. -% -% \begin{macrocode} - -function luamplib.load() - local mpx = mplib.new { - ini_version = false, - mem_name = currentmem, - find_file = luamplib.finder } - if mpx then - luamplib.log("using mem file %s", luamplib.finder(currentmem, 'r', 'mem')) - else - mpx = luamplib.input_mp(currentformat) - if mpx then - luamplib.log("using mp file %s", luamplib.finder(currentformat, 'r', 'mp')) - else - luamplib.error("unable to load the metapost format.") - end - end + mpx:execute(format("input %s ;", currentformat)) return mpx end % \end{macrocode} % -% \end{macro} +% The rest of this module is not documented. More information can be found +% in the Lua\TeX\ manual, articles in user group journals and the files +% that ship with Con\TeX t. % % \begin{macrocode} - -function luamplib.report(result) +function report(result) if not result then - luamplib.error("no result object") + err("no result object") elseif result.status > 0 then local t, e, l, f = result.term, result.error, result.log if l then - luamplib.log(l) + log(l) end if t then - luamplib.term(t) + term(t) end if e then if result.status == 1 then - luamplib.warning(e) + warn(e) else - luamplib.error(e) + err(e) end end if not t and not e and not l then if result.status == 1 then - luamplib.warning("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") + warn("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") else - luamplib.error("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") + err("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") end end else @@ -416,20 +311,20 @@ function luamplib.report(result) return false end -function luamplib.process(data) +function process(data) local converted, result = false, {} - local mpx = luamplib.load() + local mpx = load() if mpx and data then local result = mpx:execute(data) - if luamplib.report(result) then + if report(result) then if result.fig then - converted = luamplib.convert(result) + converted = convert(result) else - luamplib.warning("no figure output") + warn("no figure output") end end else - luamplib.error("Mem file unloadable. Maybe generated with a different version of mplib?") + err("Mem file unloadable. Maybe generated with a different version of mplib?") end return converted, result end @@ -438,8 +333,8 @@ local function getobjects(result,figure,f) return figure:objects() end -function luamplib.convert(result, flusher) - luamplib.flush(result, flusher) +function convert(result, flusher) + flush(result, flusher) return true -- done end @@ -557,13 +452,12 @@ end % Support for specials in DVI has been removed. % % \begin{macrocode} - -function luamplib.flush(result,flusher) +function flush(result,flusher) if result then local figures = result.fig if figures then for f=1, #figures do - luamplib.log("flushing figure %s",f) + log("flushing figure %s",f) local figure = figures[f] local objects = getobjects(result,figure,f) local fignum = tonumber((figure:filename()):match("([%d]+)$") or figure:charcode() or 0) @@ -600,7 +494,7 @@ function luamplib.flush(result,flusher) else local cs = object.color if cs and #cs > 0 then - pdf_literalcode(luamplib.colorconverter(cs)) + pdf_literalcode(colorconverter(cs)) end local ml = object.miterlimit if ml and ml ~= miterlimit then @@ -698,7 +592,7 @@ function luamplib.flush(result,flusher) end end -function luamplib.colorconverter(cr) +function colorconverter(cr) local n = #cr if n == 4 then local c, m, y, k = cr[1], cr[2], cr[3], cr[4] @@ -713,63 +607,48 @@ function luamplib.colorconverter(cr) end % \end{macrocode} % -% \iffalse +% \begin{macrocode} %</lua> -% \fi +% \end{macrocode} % -% \subsection{\texttt{luamplib.sty}} +% \subsection{\texorpdfstring{\TeX}{TeX} package} % -% \iffalse +% \begin{macrocode} %<*package> -% \fi -% +% \end{macrocode} % % First we need to load fancyvrb, to define the environment mplibcode. % % \begin{macrocode} - \bgroup\expandafter\expandafter\expandafter\egroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax \input luatexbase-modutils.sty \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2010/10/17 v1.06 mplib package for LuaTeX] + [2010/12/28 v1.07 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} \RequirePackage{fancyvrb} \fi - % \end{macrocode} -% Loading of lua code. +% +% Loading of lua code. +% % \begin{macrocode} - \RequireLuaModule{luamplib} - % \end{macrocode} % -% -% -% There are (basically) two formats for metapost: \emph{plain} and -% \emph{mpfun}. The corresponding \texttt{.mem} files are -% \texttt{mplib-luatex.mem} in \TeX Live 2010. -% With these functions you can set the format and the mem files that will -% be used by this package. Warning: the package never generates the mem -% files, you have to do it by hand, with \texttt{create-mem.lua}. +% Set the format for metapost. % % \begin{macrocode} - -\def\mplibsetformat#1{\directlua{luamplib.setformat([[#1]])}} - -\def\mplibsetmemfile#1{\directlua{luamplib.setmemfile([[#1]])}} - +\def\mplibsetformat#1{% + \directlua{luamplib.setformat("\luatexluaescapestring{#1}")}} % \end{macrocode} % -% % MPLib only works in PDF mode, we don't do anything if we are in DVI mode, % and we output a warning. % % \begin{macrocode} - \ifnum\pdfoutput>0 \let\mplibtoPDF\pdfliteral \else @@ -783,43 +662,35 @@ end \PackageWarning{mplib}{MPLib only works in PDF mode, no figure will be output.} \fi \fi - % \end{macrocode} % % The Plain-specific stuff. % % \begin{macrocode} - \bgroup\expandafter\expandafter\expandafter\egroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax - \def\mplibsetupcatcodes{ \catcode`\{=12 \catcode`\}=12 \catcode`\#=12 \catcode`\^=12 \catcode`\~=12 - \catcode`\_=12 \catcode`\%=12 \catcode`\&=12 \catcode`\$=12 + \catcode`\_=12 \catcode`\%=12 \catcode`\&=12 \catcode`\$=12 } - \def\mplibcode{% \bgroup % \mplibsetupcatcodes % \mplibdocode % } - \long\def\mplibdocode#1\endmplibcode{% \egroup % \mplibprocess{#1}% } - \long\def\mplibprocess#1{% - \directlua{luamplib.process([[#1]])}% + \directlua{luamplib.process("\luatexluaescapestring{#1}")}% } - \else - % \end{macrocode} +% % The \LaTeX-specific parts. First a Hack for the catcodes in \LaTeX . +% % \begin{macrocode} - -\makeatletter \begingroup \catcode`\,=13 \catcode`\-=13 @@ -828,28 +699,26 @@ end \def-{\string-}% } \endgroup - % \end{macrocode} +% % In \LaTeX\ (it's not the case in plain\TeX ), we get the metapost code % line by line, here is the function handling a line. +% % \begin{macrocode} - \newcommand\mplibaddlines[1]{% \begingroup % \FV@hack % \def\FV@ProcessLine##1{% - \directlua{luamplib.addline([[##1]])}% + \directlua{luamplib.addline("\luatexluaescapestring{##1}")}% }% \csname FV@SV@#1\endcsname % \endgroup % } - -\makeatother - % \end{macrocode} +% % The \LaTeX\ environment is a modified \texttt{verbatim} environment. +% % \begin{macrocode} - \newenvironment{mplibcode}{% \VerbatimEnvironment % \begin{SaveVerbatim}{memoire}% @@ -860,17 +729,17 @@ end } \fi - % \end{macrocode} +% % We use a dedicated scratchbox. +% % \begin{macrocode} - \ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi - % \end{macrocode} +% % We encapsulate the litterals. +% % \begin{macrocode} - \def\mplibstarttoPDF#1#2#3#4{ \hbox\bgroup \xdef\MPllx{#1}\xdef\MPlly{#2}% @@ -884,7 +753,9 @@ end \setbox\mplibscratchbox\vbox\bgroup \noindent } - +% \end{macrocode} +% +% \begin{macrocode} \def\mplibstoptoPDF{% \egroup % \setbox\mplibscratchbox\hbox % @@ -903,11 +774,11 @@ end \box\mplibscratchbox \egroup } - % \end{macrocode} +% % Text items have a special handler. +% % \begin{macrocode} - \def\mplibtextext#1#2#3#4#5{% \begingroup \setbox\mplibscratchbox\hbox @@ -924,67 +795,14 @@ end \box\mplibscratchbox \endgroup } - % \end{macrocode} % -% \iffalse -%</package> -% \fi -% -% \iffalse -%<*gen-lua> -% \fi -% -% \subsection{\texttt{luamplib-createmem.lua}} -% -% Finally a small standalone file to call with \texttt{texlua} that -% generates \texttt{mplib-luatex.mem} in the current directory. To generate -% other formats in other names, simply change the last line. After the -% \texttt{mem} generation, you'll have to install it in a directory -% searchable by \TeX . +% That's all folks! % % \begin{macrocode} - -kpse.set_program_name("kpsewhich") - -function finder (name, mode, ftype) - if mode == "w" then - return name - else - local result = kpse.find_file(name,ftype) - return result - end -end - -local preamble = [[ -input %s ; dump ; -]] - +%</package> % \end{macrocode} % -% \begin{macro}{makeformat} -% \begin{macrocode} - -makeformat = function (name, mem_name) - local mpx = mplib.new { - ini_version = true, - find_file = finder, - job_name = mem_name, - } - if mpx then - local result - result = mpx:execute(string.format(preamble,name)) - print(string.format("dumping format %s in %s", name, mem_name)) - mpx:finish() - end -end - -makeformat("plain", "mplib-luatex.mem") - -% \end{macrocode} -% \end{macro} -% \iffalse -%</gen-lua> -% \fi +% % \Finale \endinput diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua deleted file mode 100644 index 4066758e9bd..00000000000 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua +++ /dev/null @@ -1,55 +0,0 @@ --- --- This is file `luamplib-createmem.lua', --- generated with the docstrip utility. --- --- The original source files were: --- --- luamplib.dtx (with options: `gen-lua') --- This is a generated file. --- --- Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux --- <elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) --- --- This work is under the CC0 license. --- --- This Current Maintainer of this work is Elie Roux. --- --- This work consists of the main source file luamplib.dtx --- and the derived files --- luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. --- - -kpse.set_program_name("kpsewhich") - -function finder (name, mode, ftype) - if mode == "w" then - return name - else - local result = kpse.find_file(name,ftype) - return result - end -end - -local preamble = [[ -input %s ; dump ; -]] - - -makeformat = function (name, mem_name) - local mpx = mplib.new { - ini_version = true, - find_file = finder, - job_name = mem_name, - } - if mpx then - local result - result = mpx:execute(string.format(preamble,name)) - print(string.format("dumping format %s in %s", name, mem_name)) - mpx:finish() - end -end - -makeformat("plain", "mplib-luatex.mem") - --- --- End of File `luamplib-createmem.lua'. diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index 2ff14676ff2..f5c7ef12141 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua @@ -5,158 +5,84 @@ -- The original source files were: -- -- luamplib.dtx (with options: `lua') --- This is a generated file. -- --- Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux --- <elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) +-- See source file 'luamplib.dtx' for licencing and contact information. -- --- This work is under the CC0 license. --- --- This Current Maintainer of this work is Elie Roux. --- --- This work consists of the main source file luamplib.dtx --- and the derived files --- luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. --- - module('luamplib', package.seeall) - -luamplib.module = { +local err, warn, info, log = luatexbase.provides_module({ name = "luamplib", - version = 1.06, - date = "2010/10/17", + version = 1.07, + date = "2010/12/28", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", - author = "Hans Hagen, Taco Hoekwater & Elie Roux", - copyright = "ConTeXt Development Team & Elie Roux", - license = "CC0", -} - -luatexbase.provides_module(luamplib.module) +}) +local function term(...) + texio.write_nl('term', 'luamplib: ' .. string.format(...)) +end local format, concat, abs = string.format, table.concat, math.abs +local data = "" -luamplib.currentformat = "plain" -luamplib.currentmem = "mplib-luatex" - -local currentformat = luamplib.currentformat -local currentmem = luamplib.currentmem - -function luamplib.setformat (name) - luamplib.currentformat = name +local function resetdata() + data = "" end - -function luamplib.setmemfile(name) - luamplib.currentmem = name +function addline(line) + data = data .. '\n' .. line +end +function processlines() + process(data) + resetdata() end +local mpkpse = kpse.new("luatex", "mpost") -local mpkpse = kpse.new("luatex","mpost") - -function luamplib.finder(name, mode, ftype) +local function finder(name, mode, ftype) if mode == "w" then return name else - local result = mpkpse:find_file(name,ftype) - if not result and ftype == "mem" then - result = mpkpse:find_file("metapost/"..name,ftype) - end - return result + return mpkpse:find_file(name,ftype) end end -function luamplib.info (...) - luatexbase.module_info('luamplib', format(...)) -end - -function luamplib.log (...) - luatexbase.module_log('luamplib', format(...)) -end - -function luamplib.term (...) - luatexbase.module_term('luamplib', format(...)) -end +local currentformat = "plain" -function luamplib.warning (...) - luatexbase.module_warning('luamplib', format(...)) +function setformat (name) + currentformat = name end -function luamplib.error (...) - luatexbase.module_error('luamplib', format(...)) -end - - -luamplib.data = "" - -function luamplib.resetdata() - luamplib.data = "" -end - -function luamplib.addline(line) - luamplib.data = luamplib.data .. '\n' .. line -end - -function luamplib.processlines() - luamplib.process(luamplib.data) - luamplib.resetdata() -end - - -function luamplib.input_mp(name) +function load() local mpx = mplib.new { + find_file = finder, ini_version = true, - find_file = luamplib.finder, - job_name = name, - } - mpx:execute(format("input %s ;",name)) - return mpx -end - - -function luamplib.load() - local mpx = mplib.new { - ini_version = false, - mem_name = currentmem, - find_file = luamplib.finder } - if mpx then - luamplib.log("using mem file %s", luamplib.finder(currentmem, 'r', 'mem')) - else - mpx = luamplib.input_mp(currentformat) - if mpx then - luamplib.log("using mp file %s", luamplib.finder(currentformat, 'r', 'mp')) - else - luamplib.error("unable to load the metapost format.") - end - end + mpx:execute(format("input %s ;", currentformat)) return mpx end - -function luamplib.report(result) +function report(result) if not result then - luamplib.error("no result object") + err("no result object") elseif result.status > 0 then local t, e, l, f = result.term, result.error, result.log if l then - luamplib.log(l) + log(l) end if t then - luamplib.term(t) + term(t) end if e then if result.status == 1 then - luamplib.warning(e) + warn(e) else - luamplib.error(e) + err(e) end end if not t and not e and not l then if result.status == 1 then - luamplib.warning("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") + warn("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") else - luamplib.error("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") + err("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") end end else @@ -165,20 +91,20 @@ function luamplib.report(result) return false end -function luamplib.process(data) +function process(data) local converted, result = false, {} - local mpx = luamplib.load() + local mpx = load() if mpx and data then local result = mpx:execute(data) - if luamplib.report(result) then + if report(result) then if result.fig then - converted = luamplib.convert(result) + converted = convert(result) else - luamplib.warning("no figure output") + warn("no figure output") end end else - luamplib.error("Mem file unloadable. Maybe generated with a different version of mplib?") + err("Mem file unloadable. Maybe generated with a different version of mplib?") end return converted, result end @@ -187,8 +113,8 @@ local function getobjects(result,figure,f) return figure:objects() end -function luamplib.convert(result, flusher) - luamplib.flush(result, flusher) +function convert(result, flusher) + flush(result, flusher) return true -- done end @@ -301,13 +227,12 @@ local function flushconcatpath(path,open) return t end - -function luamplib.flush(result,flusher) +function flush(result,flusher) if result then local figures = result.fig if figures then for f=1, #figures do - luamplib.log("flushing figure %s",f) + log("flushing figure %s",f) local figure = figures[f] local objects = getobjects(result,figure,f) local fignum = tonumber((figure:filename()):match("([%d]+)$") or figure:charcode() or 0) @@ -344,7 +269,7 @@ function luamplib.flush(result,flusher) else local cs = object.color if cs and #cs > 0 then - pdf_literalcode(luamplib.colorconverter(cs)) + pdf_literalcode(colorconverter(cs)) end local ml = object.miterlimit if ml and ml ~= miterlimit then @@ -442,7 +367,7 @@ function luamplib.flush(result,flusher) end end -function luamplib.colorconverter(cr) +function colorconverter(cr) local n = #cr if n == 4 then local c, m, y, k = cr[1], cr[2], cr[3], cr[4] diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index acdf367c53f..6f6d90e0e9d 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty @@ -5,40 +5,22 @@ %% The original source files were: %% %% luamplib.dtx (with options: `package') -%% This is a generated file. %% -%% Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux -%% <elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) +%% See source file 'luamplib.dtx' for licencing and contact information. %% -%% This work is under the CC0 license. -%% -%% This Current Maintainer of this work is Elie Roux. -%% -%% This work consists of the main source file luamplib.dtx -%% and the derived files -%% luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. -%% - \bgroup\expandafter\expandafter\expandafter\egroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax \input luatexbase-modutils.sty \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2010/10/17 v1.06 mplib package for LuaTeX] + [2010/12/28 v1.07 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} \RequirePackage{fancyvrb} \fi - - \RequireLuaModule{luamplib} - - -\def\mplibsetformat#1{\directlua{luamplib.setformat([[#1]])}} - -\def\mplibsetmemfile#1{\directlua{luamplib.setmemfile([[#1]])}} - - +\def\mplibsetformat#1{% + \directlua{luamplib.setformat("\luatexluaescapestring{#1}")}} \ifnum\pdfoutput>0 \let\mplibtoPDF\pdfliteral \else @@ -52,35 +34,25 @@ \PackageWarning{mplib}{MPLib only works in PDF mode, no figure will be output.} \fi \fi - - \bgroup\expandafter\expandafter\expandafter\egroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax - \def\mplibsetupcatcodes{ \catcode`\{=12 \catcode`\}=12 \catcode`\#=12 \catcode`\^=12 \catcode`\~=12 \catcode`\_=12 \catcode`\%=12 \catcode`\&=12 \catcode`\$=12 } - \def\mplibcode{% \bgroup % \mplibsetupcatcodes % \mplibdocode % } - \long\def\mplibdocode#1\endmplibcode{% \egroup % \mplibprocess{#1}% } - \long\def\mplibprocess#1{% - \directlua{luamplib.process([[#1]])}% + \directlua{luamplib.process("\luatexluaescapestring{#1}")}% } - \else - - -\makeatletter \begingroup \catcode`\,=13 \catcode`\-=13 @@ -89,21 +61,15 @@ \def-{\string-}% } \endgroup - - \newcommand\mplibaddlines[1]{% \begingroup % \FV@hack % \def\FV@ProcessLine##1{% - \directlua{luamplib.addline([[##1]])}% + \directlua{luamplib.addline("\luatexluaescapestring{##1}")}% }% \csname FV@SV@#1\endcsname % \endgroup % } - -\makeatother - - \newenvironment{mplibcode}{% \VerbatimEnvironment % \begin{SaveVerbatim}{memoire}% @@ -114,11 +80,7 @@ } \fi - - \ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi - - \def\mplibstarttoPDF#1#2#3#4{ \hbox\bgroup \xdef\MPllx{#1}\xdef\MPlly{#2}% @@ -132,7 +94,6 @@ \setbox\mplibscratchbox\vbox\bgroup \noindent } - \def\mplibstoptoPDF{% \egroup % \setbox\mplibscratchbox\hbox % @@ -151,8 +112,6 @@ \box\mplibscratchbox \egroup } - - \def\mplibtextext#1#2#3#4#5{% \begingroup \setbox\mplibscratchbox\hbox @@ -169,7 +128,6 @@ \box\mplibscratchbox \endgroup } - \endinput %% %% End of file `luamplib.sty'. |