diff options
author | Hans Hagen <pragma@wxs.nl> | 2013-02-18 15:46:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2013-02-18 15:46:00 +0100 |
commit | 81f5a2e306755c030618f3a51229bce98df31f20 (patch) | |
tree | 6cca94fe0f06800b71ad5465ff3e50fbcede98bf /tex | |
parent | e85a18b025a884ca31f94408fa5e9d78f8cfd31d (diff) | |
download | context-81f5a2e306755c030618f3a51229bce98df31f20.tar.gz |
beta 2013.02.18 15:46
Diffstat (limited to 'tex')
22 files changed, 172 insertions, 74 deletions
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 02c90c61b..a982a819a 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.02.13 18:06} +\newcontextversion{2013.02.18 15:46} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index c9781dc1b..6e45607a8 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.02.13 18:06} +\newcontextversion{2013.02.18 15:46} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex efe94e504..8bf8163b4 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png Binary files differindex 1aaafe23f..91c290491 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 26687ca61..86748141b 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2013.02.13 18:06} +\edef\contextversion{2013.02.18 15:46} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 9782937a5..f31e16ad4 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.02.13 18:06} +\edef\contextversion{2013.02.18 15:46} %D For those who want to use this: diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua index 3cc670f5e..1bde59522 100644 --- a/tex/context/base/l-file.lua +++ b/tex/context/base/l-file.lua @@ -12,6 +12,10 @@ file = file or { } local file = file if not lfs then + lfs = optionalrequire("lfs") +end + +if not lfs then lfs = { getcurrentdir = function() diff --git a/tex/context/base/l-lua.lua b/tex/context/base/l-lua.lua index b62b7b070..7c78a4031 100644 --- a/tex/context/base/l-lua.lua +++ b/tex/context/base/l-lua.lua @@ -41,12 +41,11 @@ end -- table: --- Starting with version 5.2 Lua no longer provide ipairs, which makes --- sense. As we already used the for loop and # in most places the --- impact on ConTeXt was not that large; the remaining ipairs already --- have been replaced. In a similar fashion we also hardly used pairs. --- --- Hm, actually ipairs was retained, but we no longer use it anyway. +-- At some point it was announced that i[pairs would be dropped, which makes +-- sense. As we already used the for loop and # in most places the impact on +-- ConTeXt was not that large; the remaining ipairs already have been replaced. +-- Hm, actually ipairs was retained, but we no longer use it anyway (nor +-- pairs). -- -- Just in case, we provide the fallbacks as discussed in Programming -- in Lua (http://www.lua.org/pil/7.3.html): @@ -137,3 +136,14 @@ function inspect(...) -- global function end end end + +-- + +local dummy = function() end + +function optionalrequire(...) + local ok, result = xpcall(require,dummy,...) + if ok then + return result + end +end diff --git a/tex/context/base/l-md5.lua b/tex/context/base/l-md5.lua index c19c8248d..01f17d924 100644 --- a/tex/context/base/l-md5.lua +++ b/tex/context/base/l-md5.lua @@ -8,6 +8,10 @@ if not modules then modules = { } end modules ['l-md5'] = { -- This also provides file checksums and checkers. if not md5 then + md5 = optionalrequire("md5") +end + +if not md5 then md5 = { sum = function(str) print("error: md5 is not loaded (sum ignored)") return str end, sumhexa = function(str) print("error: md5 is not loaded (sumhexa ignored)") return str end, diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index 70d5e5514..418b9cc1b 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -605,7 +605,7 @@ function vfmath.define(specification,set,goodies) end end -- beware, loaded[1] is already passed to tex (we need to make a simple copy then .. todo) - local parent = loaded[1] -- a text font + local parent = loaded[1] or { } -- a text font local characters = { } local parameters = { } local mathparameters = { } diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 0f474fefe..6e660bdb6 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -4,23 +4,61 @@ %D title=\METAPOST\ Graphics, %D subtitle=Initialization, %D author=Hans Hagen, -%D date=\currentdate, +%D date=\ currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +% initializations: +% +% - pass settings from tex to mp (delayed expansion) +% - used by context core (and modules) +% - cummulative definitions +% - flushed each graphic +% - can be disabled per instance +% - managed at the tex end +% +% extensions: +% +% - add mp functionality (immediate expansion) +% - cummulative +% - all instances or subset of instances +% - can be disabled per instance +% - managed at the lua/mp end +% - could be managed at the tex end but no real reason and also messy +% +% definitions: +% +% - add mp functionality (delayed expansion) +% - cummulative +% - per instance +% - managed at the tex end +% +% inclusions: +% +% - add mp functionality (delayed expansion) +% - cummulative only when [+] +% - per instance +% - managed at the tex end +% +% order of execution: +% +% definitions +% extensions +% inclusions +% beginfig +% initializations +% graphic +% endfig + \writestatus{loading}{MetaPost Graphics / Initializations} \registerctxluafile{meta-ini}{1.001} \unprotect -\newtoks \t_meta_extensions % mp, once -\newtoks \t_meta_initializations % tex, each -\newtoks \t_meta_userinclusions % mp, user - \newtoks \everyMPgraphic % mp % public or not ? \appendtoks @@ -33,11 +71,16 @@ %installcorenamespace{graphicvariable} % todo \installcorenamespace{mpinstance} -\installcorenamespace{mpinstancetokens} +\installcorenamespace{mpinclusions} +\installcorenamespace{mpdefinitions} \installcorenamespace{mpgraphic} \installcorenamespace{mpstaticgraphic} \installcorenamespace{mpclip} +\newtoks \t_meta_initializations % tex, each +\def \t_meta_inclusions {\csname\??mpinclusions \currentMPinstance\endcsname} % token register +\def \t_meta_definitions {\csname\??mpdefinitions\currentMPinstance\endcsname} % token register + % The next command is, of course, dedicated to Mojca, who % needs it for gnuplot. Anyway, the whole multiple engine % mechanism is to keep her gnuplot from interfering. @@ -56,8 +99,11 @@ \let\stopMPdefinitions\relax -\unexpanded\def\startMPextensions#1\stopMPextensions % for all instances, when enabled - {\global\t_meta_extensions\expandafter{\the\t_meta_extensions#1}} +\unexpanded\def\startMPextensions + {\dosinglegroupempty\meta_start_extensions} + +\def\meta_start_extensions#1#2\stopMPextensions % we could use buffers instead + {\ctxlua{metapost.setextensions("#1",\!!bs#2\!!es)}} \let\stopMPextensions\relax @@ -69,24 +115,42 @@ \unexpanded\def\startMPinclusions {\dosingleempty\meta_start_inclusions} -\def\meta_start_inclusions[#1]#2\stopMPinclusions +\unexpanded\def\meta_start_inclusions[#1]% {\edef\m_meta_option{#1}% + \dosinglegroupempty\meta_start_inclusions_indeed} + +\def\meta_start_inclusions_indeed#1#2\stopMPinclusions + {\let\m_meta_saved_instance\currentMPinstance + \edef\currentMPinstance{#1}% + \ifx\currentMPinstance\empty + \let\currentMPinstance\defaultMPinstance + \fi \ifx\m_meta_option\!!plustoken \else - \global\t_meta_userinclusions\emptytoks + \global\t_meta_inclusions\emptytoks \fi - \global\t_meta_userinclusions\expandafter{\the\t_meta_userinclusions#2}} + \global\t_meta_inclusions\expandafter{\the\t_meta_inclusions#2}% + \let\currentMPinstance\m_meta_saved_instance} \let\stopMPinclusions\relax \unexpanded\def\MPinclusions {\dosingleempty\meta_inclusions} -\def\meta_inclusions[#1]#2% +\def\meta_inclusions[#1]% {\edef\m_meta_option{#1}% + \dosinglegroupempty\meta_inclusions_indeed} + +\def\meta_inclusions_indeed#1#2% + {\let\m_meta_saved_instance\currentMPinstance + \edef\currentMPinstance{#1}% + \ifx\currentMPinstance\empty + \let\currentMPinstance\defaultMPinstance + \fi \ifx\m_meta_option\!!plustoken \else - \global\t_meta_userinclusions\emptytoks + \global\t_meta_inclusions\emptytoks \fi - \global\t_meta_userinclusions\expandafter{\the\t_meta_userinclusions#2}} + \global\t_meta_inclusions\expandafter{\the\t_meta_inclusions#2}% + \let\currentMPinstance\m_meta_saved_instance} \def\meta_preset_definitions {\edef\overlaywidth {\overlaywidth \space}% @@ -95,8 +159,6 @@ \edef\currentwidth {\the\hsize \space}% \edef\currentheight {\the\vsize \space}} -\def\t_meta_definitions{\csname\??mpinstancetokens\currentMPinstance\endcsname} % token register - \installcommandhandler \??mpinstance {MPinstance} \??mpinstance \setupMPinstance @@ -108,10 +170,14 @@ \c!textcolor=] \appendtoks - \ifcsname\??mpinstancetokens\currentMPinstance\endcsname \else - \expandafter\newtoks\csname\??mpinstancetokens\currentMPinstance\endcsname + \ifcsname\??mpdefinitions\currentMPinstance\endcsname \else + \expandafter\newtoks\csname\??mpdefinitions\currentMPinstance\endcsname + \fi + \ifcsname\??mpinclusions\currentMPinstance\endcsname \else + \expandafter\newtoks\csname\??mpinclusions\currentMPinstance\endcsname \fi \t_meta_definitions\emptytoks % in case we redefine + \t_meta_inclusions \emptytoks % in case we redefine \to \everydefineMPinstance \unexpanded\def\resetMPinstance[#1]% @@ -125,7 +191,7 @@ \ifx\currentMPgraphicname\empty \edef\currentMPgraphicname{#1}% \let\currentMPinstance\defaultMPinstance - \else\ifcsname\??mpinstancetokens#1\endcsname + \else\ifcsname\??mpdefinitions#1\endcsname \edef\currentMPinstance{#1}% \else \let\currentMPinstance\defaultMPinstance @@ -143,7 +209,6 @@ \defineMPinstance[metapost] [\s!format=mpost] \defineMPinstance[nofun] [\s!format=mpost] -\newconditional\c_meta_include_extensions \newconditional\c_meta_include_initializations \def\meta_begin_graphic_group#1% @@ -161,44 +226,18 @@ \fi \theMPrandomseed;} -% \def\meta_flush_current_preamble -% {\ifconditional\c_meta_include_extensions -% \the\t_meta_extensions -% \the\t_meta_userinclusions -% \fi} - -\def\meta_flush_current_extensions - {\ifconditional\c_meta_include_extensions - \the\t_meta_extensions - \fi} - -\def\meta_flush_current_userinclusions - {\ifconditional\c_meta_include_extensions - \the\t_meta_userinclusions - \fi} +\def\meta_flush_current_inclusions + {\the\t_meta_inclusions} \def\meta_flush_current_definitions {\the\t_meta_definitions} -\def\meta_reset_current_preamble - {\ifconditional\c_meta_include_extensions - \global\t_meta_extensions\emptytoks - \fi} - \def\meta_start_current_graphic {\begingroup \meta_enable_include \the\everyMPgraphic \meta_preset_definitions \setMPrandomseed % this has to change - % we need to preexpand the token lists - \edef\p_extensions{\MPinstanceparameter\s!extensions}% - \ifx\p_extensions\v!yes - \settrue \c_meta_include_extensions - %\global\letMPinstanceparameter\s!extensions\v!no % needs checking - \else - \setfalse\c_meta_include_extensions - \fi \edef\p_initializations{\MPinstanceparameter\s!initializations}% \ifx\p_initializations\v!yes \settrue \c_meta_include_initializations @@ -213,6 +252,7 @@ \def\meta_stop_current_graphic {\global\t_meta_definitions\emptytoks + \global\t_meta_inclusions\emptytoks \endgroup} \def\meta_process_graphic_start @@ -231,14 +271,13 @@ format = "\currentMPformat", data = \!!bs#1;\!!es, initializations = \!!bs\meta_flush_current_initializations\!!es, - extensions = \!!bs\meta_flush_current_extensions\!!es, - inclusions = \!!bs\meta_flush_current_userinclusions\!!es, + useextensions = "\MPinstanceparameter\s!extensions", + inclusions = \!!bs\meta_flush_current_inclusions\!!es, definitions = \!!bs\meta_flush_current_definitions\!!es, figure = "\MPaskedfigure", method = "\MPinstanceparameter\c!method", }}}% \meta_process_graphic_stop - \meta_reset_current_preamble \meta_stop_current_graphic} \let\meta_process_graphic_figure_start\relax @@ -339,12 +378,11 @@ format = "\currentMPformat", data = \!!bs\getvalue{\??mpclip#1}\!!es, initializations = \!!bs\meta_flush_current_initializations\!!es, - extensions = \!!bs\meta_flush_current_extensions\!!es, - inclusions = \!!bs\meta_flush_current_userinclusions\!!es, + useextensions = "\MPinstanceparameter\s!extensions", + inclusions = \!!bs\meta_flush_current_inclusions\!!es, method = "\MPinstanceparameter\c!method", }}}}% \meta_stop_current_graphic - \meta_reset_current_preamble \ifx\MPclippath\empty \xdef\MPclippath{#4}% \fi diff --git a/tex/context/base/mlib-ctx.lua b/tex/context/base/mlib-ctx.lua index 5d976d161..a795b0214 100644 --- a/tex/context/base/mlib-ctx.lua +++ b/tex/context/base/mlib-ctx.lua @@ -9,6 +9,7 @@ if not modules then modules = { } end modules ['mlib-ctx'] = { -- todo local format, concat = string.format, table.concat +local settings_to_hash = utilities.parsers.settings_to_hash local report_metapost = logs.reporter("metapost") @@ -19,6 +20,8 @@ local mplib = mplib metapost = metapost or {} local metapost = metapost +local v_no = interfaces.variables.no + metapost.defaultformat = "metafun" metapost.defaultinstance = "metafun" metapost.defaultmethod = "default" @@ -42,6 +45,38 @@ local function setmpsformat(specification) specification.mpx = metapost.format(instance,format,method) end +local extensiondata = metapost.extensiondata or storage.allocate { } +metapost.extensiondata = extensiondata + +storage.register("metapost/extensiondata",extensiondata,"metapost.extensiondata") + +function metapost.setextensions(instances,data) + if data and data ~= "" then + extensiondata[#extensiondata+1] = { + usedinall = not instances or instances == "", + instances = settings_to_hash(instances or ""), + extensions = data, + } + end +end + +function metapost.getextensions(instance,state) + if state and state == v_no then + return "" + else + local t = { } + for i=1,#extensiondata do + local e = extensiondata[i] + local status = e.instances[instance] + if (status ~= true) and (e.usedinall or status) then + t[#t+1] = e.extensions + e.instances[instance] = true + end + end + return concat(t," ") + end +end + function metapost.graphic(specification) setmpsformat(specification) metapost.graphic_base_pass(specification) diff --git a/tex/context/base/mlib-pdf.mkiv b/tex/context/base/mlib-pdf.mkiv index f000e9a10..f55888107 100644 --- a/tex/context/base/mlib-pdf.mkiv +++ b/tex/context/base/mlib-pdf.mkiv @@ -145,8 +145,8 @@ format = "\currentMPformat", data = \!!bs#2;\!!es, initializations = \!!bs\meta_flush_current_initializations\!!es, - extensions = \!!bs\meta_flush_current_extensions\!!es, - inclusions = \!!bs\meta_flush_current_userinclusions\!!es, + useextensions = "\MPinstanceparameter\s!extensions", + inclusions = \!!bs\meta_flush_current_inclusions\!!es, definitions = \!!bs\meta_flush_current_definitions\!!es, figure = "all", method = "\MPinstanceparameter\c!method", diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index 8e69066d0..c98bef8b8 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -539,7 +539,7 @@ function metapost.graphic_base_pass(specification) local mpx = specification.mpx -- mandate local data = specification.data or "" local definitions = specification.definitions or "" - local extensions = specification.extensions or "" + local extensions = metapost.getextensions(specification.instance,specification.useextensions) -- specification.extensions or "" local inclusions = specification.inclusions or "" local initializations = specification.initializations or "" local askedfig = specification.figure -- no default else no wrapper diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index 18abf5aae..35cbd40f5 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -302,7 +302,7 @@ else find_file = finder, math_mode = method, } -report_metapost("initializing number mode %q",method) + report_metapost("initializing number mode %q",method) local result if not mpx then result = { status = 99, error = "out of memory"} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 4bf36f0f7..ce0c19c1f 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 66c3581c1..a44b8d25e 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/util-sql-imp-client.lua b/tex/context/base/util-sql-imp-client.lua index b53bc2dda..d660a4a58 100644 --- a/tex/context/base/util-sql-imp-client.lua +++ b/tex/context/base/util-sql-imp-client.lua @@ -234,7 +234,7 @@ local booleanstring = string.booleanstring return function(data) for i=1,#data do local cells = data[i] - data[i] = { + data[%s] = { %s } end diff --git a/tex/context/base/util-sql-imp-library.lua b/tex/context/base/util-sql-imp-library.lua index 3167b95f5..a9983cbca 100644 --- a/tex/context/base/util-sql-imp-library.lua +++ b/tex/context/base/util-sql-imp-library.lua @@ -265,7 +265,7 @@ return function(result) local data = { } for i=1,nofrows do local cells = { result:fetch() } - data[i] = { + data[%s] = { %s } end diff --git a/tex/context/base/util-sql-imp-swiglib.lua b/tex/context/base/util-sql-imp-swiglib.lua index d923dec3d..d681ace13 100644 --- a/tex/context/base/util-sql-imp-swiglib.lua +++ b/tex/context/base/util-sql-imp-swiglib.lua @@ -406,7 +406,7 @@ return function(result) -- local len = mysql_fetch_lengths(result) -- local cells = util_unpackbytearray(row,noffields,len) local cells = util_mysql_fetch_fields_from_current_row(result) - data[i] = { + data[%s] = { %s } end diff --git a/tex/context/base/util-sql.lua b/tex/context/base/util-sql.lua index 5d57c22f5..42bf3dc88 100644 --- a/tex/context/base/util-sql.lua +++ b/tex/context/base/util-sql.lua @@ -125,6 +125,7 @@ sql.converters = converters local function makeconverter(entries,celltemplate,wraptemplate) local shortcuts = { } local assignments = { } + local key = false for i=1,#entries do local entry = entries[i] local name = entry.name @@ -146,11 +147,14 @@ local function makeconverter(entries,celltemplate,wraptemplate) assignments[i] = format("[%q] = tab_%s[%s],",name,#converters,value) elseif kind == "deserialize" then assignments[i] = format("[%q] = deserialize(%s),",name,value) + elseif kind == "key" then + key = value -- hashed instead of indexed else assignments[i] = format("[%q] = %s,",name,value) end end - local code = format(wraptemplate,concat(shortcuts,"\n"),concat(assignments,"\n ")) + local code = format(wraptemplate,concat(shortcuts,"\n"),key or "i",concat(assignments,"\n ")) + -- print(code) local func = load(code) return func and func() end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 6b4b8709a..61dea0c9b 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 02/13/13 18:06:17 +-- merge date : 02/18/13 15:46:30 do -- begin closure to overcome local limits and interference @@ -1852,6 +1852,9 @@ if not modules then modules={} end modules ['l-file']={ file=file or {} local file=file if not lfs then + lfs=optionalrequire("lfs") +end +if not lfs then lfs={ getcurrentdir=function() return "." |