summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context/data/scite/lexers/data/scite-context-data-metafun.lua2
-rw-r--r--context/data/scite/lexers/scite-context-lexer-tex.lua2
-rw-r--r--context/data/scite/scite-context-data-metafun.properties3
-rw-r--r--doc/context/scripts/mkii/mptopdf.html44
-rw-r--r--doc/context/scripts/mkii/mptopdf.man33
-rw-r--r--doc/context/scripts/mkii/mptopdf.xml17
-rw-r--r--metapost/context/base/mp-grap.mpiv413
-rw-r--r--metapost/context/base/mp-tool.mpiv15
-rw-r--r--scripts/context/lua/mtx-mk-help.lua29
-rw-r--r--scripts/context/lua/mtxrun.lua243
-rw-r--r--scripts/context/ruby/base/tex.rb3
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua243
-rw-r--r--scripts/context/stubs/unix/mtxrun243
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4136 -> 4135 bytes
-rw-r--r--tex/context/base/context-version.pngbin40045 -> 40352 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv3
-rw-r--r--tex/context/base/core-con.lua33
-rw-r--r--tex/context/base/data-lua.lua29
-rw-r--r--tex/context/base/data-res.lua20
-rw-r--r--tex/context/base/font-ctx.lua19
-rw-r--r--tex/context/base/font-def.lua20
-rw-r--r--tex/context/base/font-ext.lua4
-rw-r--r--tex/context/base/font-gds.lua16
-rw-r--r--tex/context/base/l-lua.lua16
-rw-r--r--tex/context/base/luat-lib.mkiv3
-rw-r--r--tex/context/base/m-graph.mkiv25
-rw-r--r--tex/context/base/math-act.lua86
-rw-r--r--tex/context/base/math-ali.mkiv68
-rw-r--r--tex/context/base/mult-aux.mkiv8
-rw-r--r--tex/context/base/mult-fun.lua1
-rw-r--r--tex/context/base/pack-pos.mkiv3
-rw-r--r--tex/context/base/page-imp.mkiv37
-rw-r--r--tex/context/base/page-inj.lua101
-rw-r--r--tex/context/base/page-inj.mkvi217
-rw-r--r--tex/context/base/s-abr-01.tex1
-rw-r--r--tex/context/base/status-files.pdfbin24731 -> 24790 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin211535 -> 211713 bytes
-rw-r--r--tex/context/base/strc-enu.mkvi28
-rw-r--r--tex/context/base/strc-flt.mkvi7
-rw-r--r--tex/context/base/strc-lab.mkiv27
-rw-r--r--tex/context/base/strc-mat.mkiv10
-rw-r--r--tex/context/base/strc-not.mkvi42
-rw-r--r--tex/context/base/strc-reg.mkiv2
-rw-r--r--tex/context/base/tabl-tab.mkiv66
-rw-r--r--tex/context/base/trac-deb.lua28
-rw-r--r--tex/context/base/trac-log.lua114
-rw-r--r--tex/context/base/trac-set.lua2
-rw-r--r--tex/context/base/trac-vis.lua39
-rw-r--r--tex/context/base/trac-vis.mkiv8
-rw-r--r--tex/context/base/type-imp-latinmodern.mkiv10
-rw-r--r--tex/context/base/typo-cap.lua1
-rw-r--r--tex/context/base/typo-itc.lua1
-rw-r--r--tex/context/base/typo-krn.lua1
-rw-r--r--tex/context/base/typo-spa.lua27
-rw-r--r--tex/context/base/typo-spa.mkiv2
-rw-r--r--tex/context/base/util-lib.lua169
-rw-r--r--tex/context/base/util-sql-imp-swiglib.lua84
-rw-r--r--tex/context/base/x-steps.mkiv102
-rw-r--r--tex/context/fonts/lm.lfg22
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua29
-rw-r--r--tex/generic/context/luatex/luatex-swiglib-test.lua25
-rw-r--r--tex/generic/context/luatex/luatex-swiglib-test.tex11
-rw-r--r--tex/generic/context/luatex/luatex-swiglib.lua62
-rw-r--r--tex/generic/context/luatex/luatex-swiglib.tex20
-rw-r--r--web2c/contextcnf.lua2
68 files changed, 2226 insertions, 721 deletions
diff --git a/context/data/scite/lexers/data/scite-context-data-metafun.lua b/context/data/scite/lexers/data/scite-context-data-metafun.lua
index faa5eee4b..524a1ca49 100644
--- a/context/data/scite/lexers/data/scite-context-data-metafun.lua
+++ b/context/data/scite/lexers/data/scite-context-data-metafun.lua
@@ -1,4 +1,4 @@
return {
["commands"]={ "sqr", "log", "ln", "exp", "inv", "pow", "pi", "radian", "tand", "cotd", "sin", "cos", "tan", "cot", "atan", "asin", "acos", "invsin", "invcos", "acosh", "asinh", "sinh", "cosh", "paired", "tripled", "unitcircle", "fulldiamond", "unitdiamond", "fullsquare", "llcircle", "lrcircle", "urcircle", "ulcircle", "tcircle", "bcircle", "lcircle", "rcircle", "lltriangle", "lrtriangle", "urtriangle", "ultriangle", "smoothed", "cornered", "superellipsed", "randomized", "squeezed", "enlonged", "shortened", "punked", "curved", "unspiked", "simplified", "blownup", "stretched", "enlarged", "leftenlarged", "topenlarged", "rightenlarged", "bottomenlarged", "crossed", "laddered", "randomshifted", "interpolated", "paralleled", "cutends", "peepholed", "llenlarged", "lrenlarged", "urenlarged", "ulenlarged", "llmoved", "lrmoved", "urmoved", "ulmoved", "rightarrow", "leftarrow", "centerarrow", "boundingbox", "innerboundingbox", "outerboundingbox", "pushboundingbox", "popboundingbox", "bottomboundary", "leftboundary", "topboundary", "rightboundary", "xsized", "ysized", "xysized", "sized", "xyscaled", "intersection_point", "intersection_found", "penpoint", "bbwidth", "bbheight", "withshade", "withlinearshading", "withcircularshading", "withfromshadecolor", "withtoshadecolor", "withshading", "shadedinto", "withcircularshade", "withlinearshade", "cmyk", "spotcolor", "multitonecolor", "namedcolor", "drawfill", "undrawfill", "inverted", "uncolored", "softened", "grayed", "greyed", "onlayer", "along", "graphictext", "loadfigure", "externalfigure", "withmask", "figure", "register", "bitmapimage", "colordecimals", "ddecimal", "dddecimal", "ddddecimal", "textext", "thetextext", "rawtextext", "textextoffset", "verbatim", "thelabel", "label", "autoalign", "transparent", "withtransparency", "property", "properties", "withproperties", "asgroup", "infont", "set_linear_vector", "linear_shade", "define_linear_shade", "define_circular_linear_shade", "define_sampled_linear_shade", "set_circular_vector", "circular_shade", "define_circular_shade", "define_circular_linear_shade", "define_sampled_circular_shade", "space", "CRLF", "grayscale", "greyscale", "withgray", "withgrey", "colorpart", "readfile", "clearxy", "unitvector", "center", "epsed", "anchored", "originpath", "infinite", "break", "xstretched", "ystretched", "snapped", "pathconnectors", "function", "constructedpath", "constructedpairs", "punkedfunction", "curvedfunction", "tightfunction", "punkedpath", "curvedpath", "tightpath", "punkedpairs", "curvedpairs", "tightpairs", "evenly", "oddly", "condition", "pushcurrentpicture", "popcurrentpicture", "arrowpath", "tensecircle", "roundedsquare", "colortype", "whitecolor", "blackcolor", "normalfill", "normaldraw", "visualizepaths", "naturalizepaths", "drawboundary", "drawwholepath", "visualizeddraw", "visualizedfill", "draworigin", "drawboundingbox", "drawpath", "drawpoint", "drawpoints", "drawcontrolpoints", "drawcontrollines", "drawpointlabels", "drawlineoptions", "drawpointoptions", "drawcontroloptions", "drawlabeloptions", "draworiginoptions", "drawboundoptions", "drawpathoptions", "resetdrawoptions", "decorated", "redecorated", "undecorated" },
- ["internals"]={ "nocolormodel", "greycolormodel", "graycolormodel", "rgbcolormodel", "cmykcolormodel", "shadefactor", "textextoffset", "normaltransparent", "multiplytransparent", "screentransparent", "overlaytransparent", "softlighttransparent", "hardlighttransparent", "colordodgetransparent", "colorburntransparent", "darkentransparent", "lightentransparent", "differencetransparent", "exclusiontransparent", "huetransparent", "saturationtransparent", "colortransparent", "luminositytransparent", "metapostversion" },
+ ["internals"]={ "nocolormodel", "greycolormodel", "graycolormodel", "rgbcolormodel", "cmykcolormodel", "shadefactor", "textextoffset", "normaltransparent", "multiplytransparent", "screentransparent", "overlaytransparent", "softlighttransparent", "hardlighttransparent", "colordodgetransparent", "colorburntransparent", "darkentransparent", "lightentransparent", "differencetransparent", "exclusiontransparent", "huetransparent", "saturationtransparent", "colortransparent", "luminositytransparent", "metapostversion", "maxdimensions" },
} \ No newline at end of file
diff --git a/context/data/scite/lexers/scite-context-lexer-tex.lua b/context/data/scite/lexers/scite-context-lexer-tex.lua
index c9dbc9f47..e39ca2baa 100644
--- a/context/data/scite/lexers/scite-context-lexer-tex.lua
+++ b/context/data/scite/lexers/scite-context-lexer-tex.lua
@@ -389,7 +389,7 @@ contextlexer._reset_parser = function()
lualevel = 0
end
-local luaenvironment = P("luacode") + P("lua")
+local luaenvironment = P("lua") * (P("setups") + P("code") + P(true))
local inlinelua = P("\\") * (
P("ctx") * ( P("lua") + P("command") + P("late") * (P("lua") + P("command")) )
diff --git a/context/data/scite/scite-context-data-metafun.properties b/context/data/scite/scite-context-data-metafun.properties
index 80cb13417..b20b3e856 100644
--- a/context/data/scite/scite-context-data-metafun.properties
+++ b/context/data/scite/scite-context-data-metafun.properties
@@ -50,5 +50,6 @@ nocolormodel greycolormodel graycolormodel rgbcolormodel \
cmykcolormodel shadefactor textextoffset normaltransparent multiplytransparent \
screentransparent overlaytransparent softlighttransparent hardlighttransparent colordodgetransparent \
colorburntransparent darkentransparent lightentransparent differencetransparent exclusiontransparent \
-huetransparent saturationtransparent colortransparent luminositytransparent metapostversion
+huetransparent saturationtransparent colortransparent luminositytransparent metapostversion \
+maxdimensions
diff --git a/doc/context/scripts/mkii/mptopdf.html b/doc/context/scripts/mkii/mptopdf.html
new file mode 100644
index 000000000..e80a3a342
--- /dev/null
+++ b/doc/context/scripts/mkii/mptopdf.html
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+
+
+
+
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+ <head>
+ <title>MPtoPDF 1.4.1</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <style type="text/css">
+ body { color: #FFFFFF; background-color: #808080; font-family: optima, verdana, futura, "lucida sans", arial, geneva, helvetica, sans; font-size: 12px; line-height: 18px; } a:link, a:active, a:visited { color: #FFFFFF; } a.dir-view:link, a.dir-view:active, a.dir-view:visited { color: #FFFFFF; text-decoration: underline; } .valid { color: #00FF00; } .invalid { color: #FF0000; } button, .commonlink, .smallbutton { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; border-color: #7F7F7F; border-style: solid; border-width: .125ex; background-color: #FFFFFF; padding: .5ex; } .smallbutton { width: 1em; } a.commonlink:link, a.commonlink:active, a.commonlink:visited, a.smalllink:link, a.smalllink:active, a.smalllink:visited { font-weight: bold; font-size: 12px; text-decoration: none; color: #000000; } h1, .title { font-style: normal; font-weight: normal; font-size: 18px; line-height: 18px; margin-bottom: 20px; } h2, .subtitle { font-style: normal; font-weight: normal; font-size: 12px; margin-top: 18px; margin-bottom: 18px; } table { line-height: 18px; font-size: 12px; margin: 0; } th { font-weight: bold; text-align: left; padding-bottom: 6px; } .tc { font-weight: bold; text-align: left; } p, li { max-width: 60em; } .empty-line { margin-top: 4px; } .more-room { margin-right: 1.5em; } .much-more-room { margin-right: 3em; } #main { position: absolute; left: 10%; top: 10%; right: 10%; bottom: 10%; z-index: 2; width: 80%; height: 80%; padding: 0%; margin: 0%; overflow: auto; border-style: none; border-width: 0; background-color: #3F3F3F; } #main-settings { margin: 12px; x_max-width: 60em; line-height: 18px; font-size: 12px; } #left { position: absolute; top : 10%; left: 0%; bottom: 0%; right: 90%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; } #right { position: absolute; top : 0%; left: 90%; bottom: 10%; right: 0%; z-index: 1; width: 10%; height: 90%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #4F6F6F; _margin-left: -15px; } #bottom { position: absolute; left: 10%; right: 0%; top: 90%; bottom: 0%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top { position: absolute; left: 0%; right: 10%; top: 0%; bottom: 90%; z-index: 1; width: 90%; height: 10%; padding: 0%; margin: 0%; font-size: 16px; border-style: none; border-width: 0; background-color: #6F6F8F; } #top-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #top-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: right; vertical-align: middle; } #bottom-one { position: absolute; bottom: 50%; width: 100%; buggedheight: 100%; } #bottom-two { position: relative; margin-bottom: -9px; margin-left: 12px; margin-right: 12px; line-height: 18px; text-align: left; vertical-align: middle; } #left-one { position: absolute; width: 100%; buggedheight: 100%; } #left-two { position: relative; margin-top: 12px; line-height: 18px; text-align: center; vertical-align: top; } #right-one { display: table; height: 100%; width: 100%; } #right-two { display: table-row; height: 100%; width: 100%; } #right-three { display: table-cell; width: 100%; vertical-align: bottom; _position: absolute; _top: 100%; } #right-four { text-align: center; margin-bottom: 2ex; _position: relative; _top: -100%; } #more-top { position: absolute; top: 0%; left: 90%; bottom: 90%; right: 0%; z-index: 3; width: 10%; height: 10%; padding: 0%; margin: 0%; border-style: none; border-width: 0; } #more-top-settings { text-align: center; } #more-right-settings { margin-right: 12px; margin-left: 12px; line-height: 18px; font-size: 10px; text-align: center; } #right-safari { _display: table; width: 100%; height: 100%; }
+ </style>
+ <style type="text/css">
+ </style>
+ </head>
+ <body>
+ <div id="top"> <div id="top-one">
+ <div id="top-two">MPtoPDF 1.4.1 </div>
+ </div>
+ </div>
+ <div id="bottom"> <div id="bottom-one">
+ <div id="bottom-two">wiki: http://contextgarden.net | mail: ntg-context@ntg.nl | website: http://www.pragma-ade.nl</div>
+ </div>
+ </div>
+ <div id="left"></div>
+ <div id="right"></div>
+ <div id="main">
+ <div id='main-settings'>
+ <h1>Command line options</h1>
+<table>
+ <tr><th style="width: 10em">flag</th><th style="width: 8em">value</th><th>description</th></tr>
+ <tr><th/><td/><td/></tr>
+ <tr><th>--metafun</th><td></td><td>use the metafun format to process the file (default is mpost)</td></tr>
+ <tr><th>--texexec</th><td></td><td>use texexec (context) to process text snippets</td></tr>
+ <tr><th>--latex</th><td></td><td>use latex to process text snippets</td></tr>
+ </table>
+<br/>
+ </div>
+ </div>
+ </body>
+ </html>
diff --git a/doc/context/scripts/mkii/mptopdf.man b/doc/context/scripts/mkii/mptopdf.man
new file mode 100644
index 000000000..06feece66
--- /dev/null
+++ b/doc/context/scripts/mkii/mptopdf.man
@@ -0,0 +1,33 @@
+.TH "mptopdf" "1" "01-01-2013" "version 1.4.1" "convert MetaPost to PDF"
+.SH NAME
+.B mptopdf
+.SH SYNOPSIS
+.B mptopdf [
+.I OPTIONS ...
+.B ] [
+.I FILENAMES
+.B ]
+.SH DESCRIPTION
+.B convert MetaPost to PDF
+.SH OPTIONS
+.TP
+.B --metafun
+use the metafun format to process the file (default is mpost)
+.TP
+.B --texexec
+use texexec (context) to process text snippets
+.TP
+.B --latex
+use latex to process text snippets
+.SH AUTHOR
+More information about ConTeXt and the tools that come with it can be found at:
+
+
+.B "maillist:"
+ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
+
+.B "webpage:"
+http://www.pragma-ade.nl / http://tex.aanhet.net
+
+.B "wiki:"
+http://contextgarden.net
diff --git a/doc/context/scripts/mkii/mptopdf.xml b/doc/context/scripts/mkii/mptopdf.xml
new file mode 100644
index 000000000..a3b06a231
--- /dev/null
+++ b/doc/context/scripts/mkii/mptopdf.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<application>
+ <metadata>
+ <entry name="name">mptopdf</entry>
+ <entry name="detail">convert MetaPost to PDF</entry>
+ <entry name="version">1.4.1</entry>
+ </metadata>
+ <flags>
+ <category name="basic">
+ <subcategory>
+ <flag name="metafun"><short>use the metafun format to process the file (default is mpost)</short></flag>
+ <flag name="texexec"><short>use texexec (context) to process text snippets</short></flag>
+ <flag name="latex"><short>use latex to process text snippets</short></flag>
+ </subcategory>
+ </category>
+ </flags>
+</application>
diff --git a/metapost/context/base/mp-grap.mpiv b/metapost/context/base/mp-grap.mpiv
index bc02e8610..cce63abe0 100644
--- a/metapost/context/base/mp-grap.mpiv
+++ b/metapost/context/base/mp-grap.mpiv
@@ -11,12 +11,13 @@
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.
-% maybe we should have another Gerr ... something grph_error_message
-
-if known context_grap : endinput ; fi ;
+if known context_grap : endinput ; fi
boolean context_grap ; context_grap := true ;
+% Instead we could include graph here and then clean it up as well as use private
+% variables in the grap_ namespace. After all, graph is frozen.
+
input graph.mp ;
vardef roundd(expr x, d) =
@@ -66,9 +67,23 @@ vardef dofmt_@#(expr f, x) =
% textext(mfun_format_number(escaped_format(f),x))
enddef ;
+% note that suffix @# is ignored above...
+
+vardef strfmt(expr f, x) =
+ "\MPgraphformat{" & escaped_format(f) & "}{" & (if string x : x else: decimal x fi) & "}"
+enddef ;
+
% We redefine autogrid from graph.mp adding the possibility of differing X and Y
% formats. Autoform is defined in graph.mp (by default "%g").
-%
+
+% graph.mp: string Autoform; Autoform = "%g";
+% graph.mp:
+% graph.mp: vardef autogrid(suffix tx, ty) text w =
+% graph.mp: Gneedgr_:=false;
+% graph.mp: if str tx<>"": for x=auto.x: tx(Autoform,x) w; endfor fi
+% graph.mp: if str ty<>"": for y=auto.y: ty(Autoform,y) w; endfor fi
+% graph.mp: enddef;
+
% string Autoform_X ; Autoform_X := "@.0e" ;
% string Autoform_Y ; Autoform_Y := "@.0e" ;
@@ -86,9 +101,10 @@ vardef autogrid(suffix tx, ty) text w =
else :
Autoform
fi,
- x) w ;
+ x
+ ) w ;
endfor
- fi ;
+ fi
if str ty <> "" :
for y=auto.y :
ty (
@@ -101,16 +117,17 @@ vardef autogrid(suffix tx, ty) text w =
else :
Autoform
fi,
- y) w ;
+ y
+ ) w ;
endfor
- fi ;
+ fi
enddef ;
% A couple of extensions:
-% Define a vector function sym returning a picture: 10 different shapes,
+% Define a function plotsymbol() returning a picture: 10 different shapes,
% unfilled outline, interior filled with different shades of the background.
-% Thus, overlapping points on a plot are more clearly distinguishable.
+% This allows overlapping points on a plot to be more distinguishable.
% grap_symsize := fontsize defaultfont ; % can be redefined
%
@@ -124,11 +141,11 @@ enddef ;
path grap_sym[] ; % (internal) symbol path
-grap_sym[0] := (0,0) ; % point
-grap_sym[1] := fullcircle ; % circle
-grap_sym[2] := (up -- down) scaled .5 ; % vertical bar
+grap_sym[0] := (0,0) ; % point
+grap_sym[1] := fullcircle ; % circle
+grap_sym[2] := (up -- down) scaled .5 ; % vertical bar
-for i = 3 upto 9 : % polygons
+for i = 3 upto 9 : % polygons
grap_sym[i] :=
for j = 0 upto i-1 :
(up scaled .5) rotated (360j/i) --
@@ -179,9 +196,9 @@ endfor cycle ;
grap_sym[34] := grap_sym[24] rotated 45 ;
- % usage: gdraw p plot plotsymbol(1,red,1) ; % a filled red circle
- % usage: gdraw p plot plotsymbol(4,blue,0) ; % a blue square
- % usage: gdraw p plot plotsymbol(14,green,0.5) ; % a 50% filled green diamond
+% usage: gdraw p plot plotsymbol(1,red,1) ; % a filled red circle
+% usage: gdraw p plot plotsymbol(4,blue,0) ; % a blue square
+% usage: gdraw p plot plotsymbol(14,green,0.5) ; % a 50% filled green diamond
def plotsymbol(expr n,c,f) = % (number,color,color|number)
if known grap_sym[n] :
@@ -206,171 +223,303 @@ def plotsymbol(expr n,c,f) = % (number,color,color|number)
fi
enddef ;
-% Here starts a section with some extensions that come in handy when drawing
-% polynomials. We assume that metapost is run in double number mode.
+% convert a polygon path to a smooth path (useful, e.g. as a guide to the eye)
+
+def smoothpath (suffix $) =
+ if path $ :
+ (for i=0 upto length $ :
+ if i>0 : .. fi
+ (point i of $)
+ endfor )
+ fi
+enddef ;
+
+% return a path of a function func(x) with abcissa running from f to t over n intervals
-% Least-squares "fit" to a polynomial
+def makefunctionpath (expr f, t, n) (text func) =
+ (for x=f step ((t-f)/n) until t :
+ if x<>f : .. fi
+ (x, func)
+ endfor )
+enddef ;
+
+% shift a path, point by point
%
-% Example of use:
+% example:
+%
+% p1 := addnoisetopath(p0,(.1normaldeviate,.1normaldeviate)) ;
+
+vardef addnoisetopath (suffix p) (text t) =
+ if path p :
+ hide(pair pi)
+ (for i=0 upto length p :
+ if i>0 : -- fi
+ hide(pi := point i of p; x := xpart pi; y := ypart pi)z shifted t
+ endfor)
+ fi
+enddef ;
+
+% return a new path of a function func(x) using the same abcissa as an existing path
+
+vardef functionpath (suffix p) (text t) =
+ (for i=0 upto length p :
+ if i>0 : .. fi
+ (hide(x := xpart(point i of p))x,t)
+ endfor )
+enddef ;
+
+% least-squares "fit" to a polynomial
+%
+% example:
%
% path p[] ;
% numeric a[] ; a0 := 1 ; a1 := .1 ; a2 := .01 ; a3 := .001 ; a4 := 0.0001 ;
-% for i=0 upto 10:
-% x1 := 5i/10 ;
-% y1 := poly.a(4,x1) ;
-% augment.p0(z1) ;
-% augment.p1((x1,y1+.005normaldeviate)) ;
-% endfor
+% p0 := makefunctionpath(0,5,10,poly(a,4,x)) ;
+% p1 := addnoisetopath(p0,(0,.001normaldeviate)) ;
% gdraw p0 ;
% gdraw p1 plot plotsymbol(1,black,.5) ;
%
-% numeric chisq, b[] ;
-% polyfit.p1(chisq, b, 4) ;
-% for i=0 upto length p1 :
-% x1 := xpart(point i of p1) ;
-% y1 := poly.b(4,x1) ;
-% augment.p2(z1) ;
-% endfor
-% gdraw p2 ;
+% numeric b[] ;
+% polyfit(p1, b, 4, 1) ;
+% gdraw functionpath(p1,poly(b,4,x)) ;
%
% numeric c[] ;
-% linefit.p1(chisq, c) ;
-% for i=0 upto length p1 :
-% x1 := xpart(point i of p1) ;
-% y1 := line.c(x1) ;
-% augment.p3(z1) ;
-% endfor
-% gdraw p3 dashed evenly ;
-
-vardef det@# (expr n) = % find the determinant of a (n+1)*(n+1) matrix
- % indices run from 0 to n.
- % first, we make a copy so as not to corrupt the matrix.
- save copy ; numeric copy[][] ;
- for k=0 upto n :
- for j=0 upto n :
- copy[k][j] := @#[k][j] ;
- endfor
- endfor
- numeric determinant, jj ; determinant := 1 ;
- boolean zero ; zero := false ;
- for k=0 upto n :
- if copy[k][k] = 0 :
- for 0 = k upto n :
- if copy[k][j]=0 :
- zero := true ;
- else :
- jj := j ;
+% linefit(p1, c, 1) ;
+% gdraw functionpath(p1,line(c,x)) dashed evenly ;
+
+% a polynomial function:
+%
+% y = a0 + a1 * x + a2 * x^2 + ... + a[n] * x^n
+
+vardef poly (suffix $) (expr n, x) =
+ (for j=0 upto n : + $[j]*(x**j) endfor) % no ;
+enddef ;
+
+% find the determinant of a (n+1)*(n+1) matrix; indices run from 0 to n
+
+vardef det (suffix $) (expr n) =
+ hide(
+ numeric determinant ; determinant := 1 ;
+ save jj ; numeric jj ;
+ for k=0 upto n :
+ if $[k][k]=0 :
+ jj := -1 ;
+ for j=0 upto n :
+ if $[k][j]<>0 :
+ jj := j ;
+ exitif true ;
+ fi
+ endfor
+ if jj<0 :
+ determinant := 0 ;
+ exitif true ;
fi
- exitunless zero ;
- endfor
- if zero :
- determinant := 0 ;
+ for j=k upto n : % interchange the columns
+ temp := $[j][jj] ;
+ $[j][jj] := $[j][k] ;
+ $[j][k] := temp ;
+ endfor
+ determinant = -determinant ;
fi
- exitif zero ;
- for j = k upto n : % interchange the columns
- temp := copy[j][jj] ;
- copy[j][jj] := copy[j][k] ;
- copy[j][k] := temp ;
- endfor
- determinant = -determinant ;
- fi
- exitif zero ;
- determinant := determinant * copy[k][k] ;
- if k < n : % subtract row k from lower rows to get a diagonal matrix
- for j = k + 1 upto n :
- for i = k + 1 upto n :
- copy[j][i] := copy[j][i] - copy[j][k] * copy[k][i] / copy[k][k] ;
+ exitif determinant=0 ;
+ determinant := determinant * $[k][k] ;
+ if k<n : % subtract row k from lower rows to get a diagonal matrix
+ for j=k+1 upto n:
+ for i=k+1 upto n:
+ $[j][i] := $[j][i]-$[j][k]*$[k][i]/$[k][k] ;
+ endfor
endfor
- endfor
- fi
- endfor ;
+ fi
+ endfor ;
+ )
determinant % no ;
enddef ;
-% least-squares fit of a polynomial $ of order n to a path @#
+numeric Gchisq_ ; % global - use graph.mp naming convention (until we clean things up).
+% why not grap_pf_temp? answer: because we want this to be available to the user.
-vardef polyfit@# (suffix chisq, $) (expr n) =
- if not path begingroup @# endgroup :
- Gerr(begingroup @# endgroup, "Cannot fit--not a path") ;
- elseif length @# < n :
- Gerr(begingroup @# endgroup, "Cannot fit--not enough points") ;
- else:
- chisq := 0 ;
+% least-squares fit of a polynomial $ of order n to a path p (unweighted)
+%
+% reference: P. R. Bevington, "Data Reduction and Error Analysis for the Physical
+% Sciences", McGraw-Hill, New York 1969.
+
+vardef polyfit (suffix p, $) (expr n) (text t) =
+ if not path p :
+ Gerr(p, "Cannot fit--not a path") ;
+ elseif length p < n :
+ Gerr(p, "Cannot fit--not enough points") ;
+ else :
+ Gchisq_ := 0 ;
% calculate sums of the data
save sumx, sumy ; numeric sumx[], sumy[] ;
- save nmax ; numeric nmax ; nmax := 2*n ;
- for i = 0 upto nmax :
+ save w ; numeric w ;
+ for i=0 upto 2n :
sumx[i] := 0 ;
endfor
- for i = 0 upto n :
+ for i=0 upto n :
sumy[i] := 0 ;
endfor
- save xp, yp ; numeric xp, yp ;
- save zi ; pair zi ;
- for i = 0 upto length @# :
- zi := point i of @# ;
- x0 := xpart zi ; y0 := ypart zi ;
- x1 := 1 ;
- for j = 0 upto nmax :
+ for i=0 upto length p :
+ clearxy; z = point i of p ;
+ w := if length(t) > 0 : t else : 1 fi ; % weight
+ x1 := w ;
+ for j=0 upto 2n :
sumx[j] := sumx[j] + x1 ;
- x1 := x1 * x0 ;
+ x1 := x1 * x ;
endfor
- y1 := y0 ;
- for j = 0 upto n :
+ y1 := y * w ;
+ for j=0 upto n :
sumy[j] := sumy[j] + y1 ;
- y1 := y1 * x0 ;
+ y1 := y1 * x ;
endfor
- chisq := chisq + y0*y0 ;
+ Gchisq_ := Gchisq_ + y*y*w ;
endfor
% construct matrices and calculate the polynomial coefficients
save m ; numeric m[][] ;
- for j = 0 upto n :
- for k = 0 upto n :
- i := j + k ;
- m[j][k] := sumx[i] ;
+ for j=0 upto n :
+ for k=0 upto n :
+ m[j][k] := sumx[j+k] ;
endfor
endfor
save delta ; numeric delta ;
- delta := det.m(n) ;
+ delta := det(m,n) ; % this destroys the matrix m[][], which is OK
if delta = 0 :
- chisq := 0 ;
+ Gchisq_ := 0 ;
for j=0 upto n :
$[j] := 0 ;
endfor
else :
- for l = 0 upto n :
- for j = 0 upto n :
- for k = 0 upto n :
- i := j + k ;
- m[j][k] := sumx[i] ;
+ for i=0 upto n :
+ for j=0 upto n :
+ for k=0 upto n :
+ m[j][k] := sumx[j+k] ;
endfor
- m[j][l] := sumy[j] ;
+ m[j][i] := sumy[j] ;
endfor
- $[l] := det.m(n) / delta ;
+ $[i] := det(m,n) / delta ; % matrix m[][] gets destroyed...
endfor
- for j = 0 upto n :
- chisq := chisq - 2*$[j]*sumy[j] ;
- for k = 0 upto n :
- i := j + k ;
- chisq := chisq + $[j]*$[k]*sumx[i] ;
+ for j=0 upto n :
+ Gchisq_ := Gchisq_ - 2sumy[j]*$[j] ;
+ for k=0 upto n :
+ Gchisq_ := Gchisq_ + $[j]*$[k]*sumx[j+k] ;
endfor
endfor
% normalize by the number of degrees of freedom
- chisq := chisq / (length(@#) - n) ;
+ Gchisq_ := Gchisq_ / (length(p) - n) ;
+ fi
+ fi
+enddef ;
+
+% y = a0 + a1 * x
+%
+% of course a line is just a polynomial of order 1
+
+vardef line (suffix $) (expr x) = poly($,1,x) enddef ; % beware: potential name clash
+vardef linefit (suffix p, $) (text t) = polyfit(p, $, 1, t) ; enddef ;
+
+% and a constant is polynomial of order 0
+
+vardef const (suffix $) (expr x) = poly($,0,x) enddef ;
+vardef constfit (suffix p, $) (text t) = polyfit(p, $, 0, t) ; enddef ;
+
+% y = a1 * exp(a0*x)
+%
+% exp and ln defined in metafun
+
+vardef exponential (suffix $) (expr x) = $1*exp($0*x) enddef ;
+
+% since we take a log, this only works for positive ordinates
+
+vardef exponentialfit (suffix p, $) (text t) =
+ save a ; numeric a[] ;
+ save q ; path q ; % fit to the log of the ordinate
+ for i=0 upto length p :
+ if ypart(point i of p)>0 :
+ augment.q(xpart(point i of p),ln(ypart(point i of p))) ;
+ fi
+ endfor
+ linefit(q,a,t) ;
+ $0 := a1 ;
+ $1 := exp(a0) ;
+enddef ;
+
+% y = a1 * x**a0
+
+vardef power (suffix $) (expr x) = $1*(x**$0) enddef ;
+
+% since we take logs, this only works for positive abcissae and ordinates
+
+vardef powerfit (suffix p, $) (text t) =
+ save a ; numeric a[] ;
+ save q ; path q ; % fit to the logs of the abcissae and ordinates
+ for i=0 upto length p :
+ if (xpart(point i of p)>0) and (ypart(point i of p)>0) :
+ augment.q(ln(xpart(point i of p)),ln(ypart(point i of p))) ;
fi
+ endfor
+ linefit(q,a,t) ;
+ $0 := a1 ;
+ $1 := exp(a0) ;
+enddef ;
+
+% gaussian: y = a2 * exp(-ln(2)*((x-a0)/a1)^2)
+%
+% a1 is the hwhm; sigma := a1/sqrt(2ln(2)) or a1/1.17741
+
+numeric lntwo ; lntwo := ln(2) ; % brrr, why not inline it
+
+vardef gaussian (suffix $) (expr x) =
+ if $1 = 0 :
+ if x = $0 : $2 else : 0 fi
+ else :
+ $2 * exp(-lntwo*(((x-$0)/$1)**2))
+ fi
+ if known $3 :
+ + $3
fi
enddef ;
-vardef poly@#(expr n, x) =
- for j = 0 upto n :
- + @#[j]*(x**j)
- endfor % no ;
+% since we take a log, this only works for positive ordinates
+
+vardef gaussianfit (suffix p, $) (text t) =
+ save a ; numeric a[] ;
+ save q ; path q ; % fit to the log of the ordinate
+ for i=0 upto length p :
+ if ypart(point i of p)>0 :
+ augment.q(xpart(point i of p), ln(ypart(point i of p))) ;
+ fi
+ endfor
+ polyfit(q,a,2,if t > 0 : ln(t) else : 0 fi) ;
+ $1 := sqrt(-lntwo/a2) ;
+ $0 := -.5a1/a2 ;
+ $2 := exp(a0-.25*a1*a1/a2) ;
+ $3 := 0 ; % polyfit will NOT work with a non-zero background!
enddef ;
-vardef line@#(expr x) =
- poly@# (1,x)
+% lorentzian: y = a2 / (1 + ((x - a0)/a1)^2)
+
+vardef lorentzian (suffix $) (expr x) =
+ if $1 = 0 :
+ if x = $0 : $2 else : 0 fi
+ else :
+ $2 / (1 + ((x - $0)/$1)**2)
+ fi
+ if known $3 :
+ + $3
+ fi
enddef ;
-vardef linefit@#(suffix chisq, $) =
- polyfit@#(chisq, $, 1) ;
+vardef lorentzianfit (suffix p, $) (text t) =
+ save a ; numeric a[] ;
+ save q ; path q ; % fit to the inverse of the ordinate
+ for i=0 upto length p :
+ if ypart(point i of p)<>0 :
+ augment.q(xpart(point i of p), 1/ypart(point i of p)) ;
+ fi
+ endfor
+ polyfit(q,a,2,if t <> 0 : 1/(t) else : 0 fi) ;
+ $0 := -.5a1/a2 ;
+ $2 := 1/(a0-.25a1*a1/a2) ;
+ $1 := sqrt((a0-.25a1*a1/a2)/a2) ;
+ $3 := 0 ; % polyfit will NOT work with a non-zero background!
enddef ;
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index a947143c4..5b53dcdef 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -2307,3 +2307,18 @@ enddef ;
% setbounds currentpicture to mfun_bleed_box ;
% )
% enddef ;
+
+%D Dimensions have bever been an issue as traditional MP can't make that large
+%D pictures, but with double mode we need a catch:
+
+newinternal maxdimensions ; maxdimensions := 14000 ;
+
+def mfun_apply_max_dimensions = % not a generic helper, we want to protect this one
+ if bbwidth currentpicture > maxdimensions :
+ currentpicture := currentpicture if bbheight currentpicture > bbwidth currentpicture : ysized else : xsized fi maxdimensions ;
+ elseif bbheight currentpicture > maxdimensions :
+ currentpicture := currentpicture ysized maxdimensions ;
+ fi ;
+enddef;
+
+extra_endfig := extra_endfig & "mfun_apply_max_dimensions ;" ;
diff --git a/scripts/context/lua/mtx-mk-help.lua b/scripts/context/lua/mtx-mk-help.lua
index 94a424f56..794bbca37 100644
--- a/scripts/context/lua/mtx-mk-help.lua
+++ b/scripts/context/lua/mtx-mk-help.lua
@@ -398,6 +398,32 @@ local imgtopdf = logs.application {
helpinfo = helpinfo,
}
+local helpinfo = [[
+<?xml version="1.0"?>
+<application>
+ <metadata>
+ <entry name="name">mptopdf</entry>
+ <entry name="detail">convert MetaPost to PDF</entry>
+ <entry name="version">1.4.1</entry>
+ </metadata>
+ <flags>
+ <category name="basic">
+ <subcategory>
+ <flag name="metafun"><short>use the metafun format to process the file (default is mpost)</short></flag>
+ <flag name="texexec"><short>use texexec (context) to process text snippets</short></flag>
+ <flag name="latex"><short>use latex to process text snippets</short></flag>
+ </subcategory>
+ </category>
+ </flags>
+</application>
+]]
+
+local mptopdf = logs.application {
+ name = "mptopdf",
+ banner = "MPtoPDF 1.4.1",
+ helpinfo = helpinfo,
+}
+
-- texmfstart.rb is normally replaced by mtxrun
-- runtools.rb is run from within context
-- concheck.rb is run from within editors
@@ -432,7 +458,8 @@ elseif filename == "tmftools" then mkapplication = tmftools
elseif filename == "xmltools" then mkapplication = xmltools
elseif filename == "pstopdf" then mkapplication = pstopdf
elseif filename == "rlxtools" then mkapplication = rlxtools
-elseif filename == "imgtopdf" then mkapplication = imgtopdf end
+elseif filename == "imgtopdf" then mkapplication = imgtopdf
+elseif filename == "mptopdf" then mkapplication = mptopdf end
if not mkapplication then
application.report("no valid mk script given")
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 4997d7458..00f63a579 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -56,7 +56,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-lua"] = package.loaded["l-lua"] or true
--- original size: 10064, stripped down to: 5696
+-- original size: 10048, stripped down to: 5684
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -177,7 +177,7 @@ local function addpath(what,paths,extras,hash,...)
local path=cleanpath(path)
if not hash[path] then
if trace then
- report("! extra %s path: %s",what,path)
+ report("extra %s path: %s",what,path)
end
paths [#paths+1]=path
extras[#extras+1]=path
@@ -211,13 +211,13 @@ searchers[3]=nil
local function loadedaslib(resolved,rawname)
local init="luaopen_"..gsub(rawname,"%.","_")
if helpers.trace then
- helpers.report("! calling loadlib with '%s' with init '%s'",resolved,init)
+ helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
end
return package.loadlib(resolved,init)
end
local function loadedbylua(name)
if helpers.trace then
- helpers.report("! locating '%s' using normal loader",name)
+ helpers.report("locating '%s' using normal loader",name)
end
return true,searchers[-2](name)
end
@@ -225,17 +225,17 @@ local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating '%s' as '%s' on '%s' paths",rawname,name,what)
+ report("locating '%s' as '%s' on '%s' paths",rawname,name,what)
end
for p=1,#paths do
local path=paths[p]
local resolved=filejoin(path,name)
if trace then
- report("! checking for '%s' using '%s' path '%s'",name,what,path)
+ report("checking for '%s' using '%s' path '%s'",name,what,path)
end
if isreadable(resolved) then
if trace then
- report("! lib '%s' located on '%s'",name,resolved)
+ report("lib '%s' located on '%s'",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -5814,7 +5814,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-set"] = package.loaded["trac-set"] or true
--- original size: 12360, stripped down to: 8799
+-- original size: 12365, stripped down to: 8799
if not modules then modules={} end modules ['trac-set']={
version=1.001,
@@ -6126,7 +6126,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 21607, stripped down to: 15212
+-- original size: 21795, stripped down to: 14194
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -6135,49 +6135,6 @@ if not modules then modules={} end modules ['trac-log']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
-if tex and (tex.jobname or tex.formatname) then
- local texio_write_nl=texio.write_nl
- local texio_write=texio.write
- local io_write=io.write
- local write_nl=function(target,...)
- if not io_write then
- io_write=io.write
- end
- if target=="term and log" then
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- elseif target=="log" then
- texio_write_nl("log",...)
- elseif target=="term" then
- texio_write_nl("term","")
- io_write(...)
- else
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- end
- end
- local write=function(target,...)
- if not io_write then
- io_write=io.write
- end
- if target=="term and log" then
- texio_write("log",...)
- io_write(...)
- elseif target=="log" then
- texio_write("log",...)
- elseif target=="term" then
- io_write(...)
- else
- texio_write("log",...)
- io_write(...)
- end
- end
- texio.write=write
- texio.write_nl=write_nl
-else
-end
local write_nl,write=texio and texio.write_nl or print,texio and texio.write or io.write
local format,gmatch,find=string.format,string.gmatch,string.find
local concat,insert,remove=table.concat,table.insert,table.remove
@@ -6510,8 +6467,9 @@ function logs.show()
end
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
-local delayed_reporters={} setmetatableindex(delayed_reporters,function(t,k)
- local v=logs.reporter(k)
+local delayed_reporters={}
+setmetatableindex(delayed_reporters,function(t,k)
+ local v=logs.reporter(k.name)
t[k]=v
return v
end)
@@ -12674,7 +12632,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 60509, stripped down to: 42429
+-- original size: 60821, stripped down to: 42503
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -12848,7 +12806,8 @@ end
local slash=P("/")
local pathexpressionpattern=Cs (
Cc("^")*(
- Cc("%")*S(".-")+slash^2*P(-1)/"/.*"+slash^2/"/.-/"+(1-slash)*P(-1)*Cc("/")+P(1)
+ Cc("%")*S(".-")+slash^2*P(-1)/"/.*"
++slash^2/"/[^/]*/*"+(1-slash)*P(-1)*Cc("/")+P(1)
)^1*Cc("$")
)
local cache={}
@@ -13583,6 +13542,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
if trace_detail then
report_resolving("checking filename %a",filename)
end
+ local resolve=resolvers.resolve
local result={}
for k=1,#pathlist do
local path=pathlist[k]
@@ -13601,8 +13561,8 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
local fl=filelist[k]
local f=fl[2]
local d=dirlist[k]
- if find(d,expression) then
- result[#result+1]=resolvers.resolve(fl[3])
+ if find(d,expression) or find(resolve(d),expression) then
+ result[#result+1]=resolve(fl[3])
done=true
if allresults then
if trace_detail then
@@ -13624,7 +13584,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
else
method="filesystem"
pathname=gsub(pathname,"/+$","")
- pathname=resolvers.resolve(pathname)
+ pathname=resolve(pathname)
local scheme=url.hasscheme(pathname)
if not scheme or scheme=="file" then
local pname=gsub(pathname,"%.%*$",'')
@@ -13834,7 +13794,9 @@ local function findgivenfiles(filename,allresults)
if found~="" then
noffound=noffound+1
result[noffound]=resolvers.resolve(found)
- if not allresults then break end
+ if not allresults then
+ break
+ end
end
else
for kk=1,#blist do
@@ -15109,7 +15071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lua"] = package.loaded["data-lua"] or true
--- original size: 4333, stripped down to: 3534
+-- original size: 4861, stripped down to: 3693
if not modules then modules={} end modules ['data-lua']={
version=1.001,
@@ -15122,7 +15084,7 @@ local resolvers,package=resolvers,package
local gsub=string.gsub
local concat=table.concat
local addsuffix=file.addsuffix
-local P,Cs,lpegmatch=lpeg.P,lpeg.Cs,lpeg.match
+local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
local libsuffixes={ 'tex','lua' }
local clibsuffixes={ 'lib' }
local libformats={ 'TEXINPUTS','LUAINPUTS' }
@@ -15174,17 +15136,17 @@ local function loadedbyformat(name,rawname,suffixes,islib)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating %a as %a using formats %a",rawname,name,suffixes)
+ report("locating %a as %a using formats %a",rawname,name,suffixes)
end
for i=1,#suffixes do
local format=suffixes[i]
local resolved=resolvers.findfile(name,format) or ""
if trace then
- report("! checking for %a using format %a",name,format)
+ report("checking %a using format %a",name,format)
end
if resolved~="" then
if trace then
- report("! lib %a located on %a",name,resolved)
+ report("lib %a located on %a",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -15195,8 +15157,13 @@ local function loadedbyformat(name,rawname,suffixes,islib)
end
end
helpers.loadedbyformat=loadedbyformat
+local pattern=Cs((((1-S("\\/"))^0*(S("\\/")^1/"/"))^0*(P(".")^1/"/"+P(1))^1)*-1)
+local function lualibfile(name)
+ return lpegmatch(pattern,name) or name
+end
+helpers.lualibfile=lualibfile
function helpers.loaded(name)
- local thename=gsub(name,"%.","/")
+ local thename=lualibfile(name)
local luaname=addsuffix(thename,"lua")
local libname=addsuffix(thename,os.libsuffix)
local libpaths=getlibpaths()
@@ -15227,7 +15194,6 @@ function helpers.loaded(name)
end
return notloaded(name)
end
-package.searchers[3]=nil
resolvers.loadlualib=require
@@ -15435,6 +15401,139 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-lib"] = package.loaded["util-lib"] or true
+
+-- original size: 8911, stripped down to: 4216
+
+if not modules then modules={} end modules ['util-lib']={
+ version=1.001,
+ comment="companion to luat-lib.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files",
+}
+local gsub,find=string.gsub,string.find
+local pathpart,nameonly,joinfile=file.pathpart,file.nameonly,file.join
+local findfile,findfiles=resolvers and resolvers.findfile,resolvers and resolvers.findfiles
+local loaded=package.loaded
+local report_swiglib=logs.reporter("swiglib")
+local trace_swiglib=false trackers.register("resolvers.swiglib",function(v) trace_swiglib=v end)
+local function requireswiglib(required,version)
+ local library=loaded[required]
+ if library==nil then
+ local required_full=gsub(required,"%.","/")
+ local required_path=pathpart(required_full)
+ local required_base=nameonly(required_full)
+ local required_name=required_base.."."..os.libsuffix
+ local version=type(version)=="string" and version~="" and version or false
+ local function check(locate,...)
+ local found_library=nil
+ if version then
+ local asked_library=joinfile(required_path,version,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","with version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ if not found_library or found_library==""then
+ asked_library=joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ end
+ else
+ local asked_library=joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ end
+ return found_library and found_library~="" and found_library or false
+ end
+ local found_library=findfile and check(findfile,"lib")
+ if findfiles and not found_library then
+ local asked_library=joinfile(required_path,".*",required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","latest version",asked_library)
+ end
+ local list=findfiles(asked_library,"lib",true)
+ if list and #list>0 then
+ table.sort(list)
+ found_library=list[#list]
+ end
+ end
+ if not found_library then
+ package.extraclibpath(environment.ownpath)
+ local paths=package.clibpaths()
+ for i=1,#paths do
+ local found_library=check(lfs.isfile)
+ if found_library then
+ break
+ end
+ end
+ end
+ if not found_library then
+ if trace_swiglib then
+ report_swiglib("not found: %a",asked_library)
+ end
+ library=false
+ else
+ local path=pathpart(found_library)
+ local base=nameonly(found_library)
+ dir.push(path)
+ if trace_swiglib then
+ report_swiglib("found: %a",found_library)
+ end
+ library=package.loadlib(found_library,"luaopen_"..required_base)
+ if type(library)=="function" then
+ library=library()
+ else
+ library=false
+ end
+ dir.pop()
+ end
+ if not library then
+ report_swiglib("unknown: %a",required)
+ elseif trace_swiglib then
+ report_swiglib("stored: %a",required)
+ end
+ loaded[required]=library
+ else
+ report_swiglib("reused: %a",required)
+ end
+ return library
+end
+local savedrequire=require
+function require(name,version)
+ if find(name,"^swiglib%.") then
+ return requireswiglib(name,version)
+ else
+ return savedrequire(name)
+ end
+end
+local swiglibs={}
+function swiglib(name,version)
+ local library=swiglibs[name]
+ if not library then
+ statistics.starttiming(swiglibs)
+ report_swiglib("loading %a",name)
+ library=requireswiglib("swiglib."..name,version)
+ swiglibs[name]=library
+ statistics.stoptiming(swiglibs)
+ end
+ return library
+end
+statistics.register("used swiglibs",function()
+ if next(swiglibs) then
+ return string.format("%s, initial load time %s seconds",table.concat(table.sortedkeys(swiglibs)," "),statistics.elapsedtime(swiglibs))
+ end
+end)
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["luat-sta"] = package.loaded["luat-sta"] or true
-- original size: 5703, stripped down to: 2507
@@ -15672,10 +15771,10 @@ end
end -- of closure
--- used libraries : l-lua.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua luat-sta.lua luat-fmt.lua
+-- used libraries : l-lua.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 648348
--- stripped bytes : 235055
+-- original bytes : 658276
+-- stripped bytes : 241564
-- end library merge
@@ -15765,6 +15864,8 @@ local ownlibs = { -- order can be made better
'data-tmf.lua',
'data-lst.lua',
+ 'util-lib.lua', -- swiglib
+
'luat-sta.lua',
'luat-fmt.lua',
@@ -16978,4 +17079,4 @@ end
if ok == false then ok = 1 elseif ok == true then ok = 0 end
-os.exit(ok)
+os.exit(ok,true) -- true forces a cleanup in 5.2+
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 8f5683985..9ba842501 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -362,7 +362,8 @@ class TEX
def mpsformats() @@mpsformats.keys.sort end
def defaulttexformats() ['en','nl','mptopdf'] end
- def defaultmpsformats() ['metafun'] end
+ # def defaultmpsformats() ['metafun'] end # no longer formats
+ def defaultmpsformats() [] end
def texmakeextras(format) @@texmakestr[format] || '' end
def mpsmakeextras(format) @@mpsmakestr[format] || '' end
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 4997d7458..00f63a579 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -56,7 +56,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-lua"] = package.loaded["l-lua"] or true
--- original size: 10064, stripped down to: 5696
+-- original size: 10048, stripped down to: 5684
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -177,7 +177,7 @@ local function addpath(what,paths,extras,hash,...)
local path=cleanpath(path)
if not hash[path] then
if trace then
- report("! extra %s path: %s",what,path)
+ report("extra %s path: %s",what,path)
end
paths [#paths+1]=path
extras[#extras+1]=path
@@ -211,13 +211,13 @@ searchers[3]=nil
local function loadedaslib(resolved,rawname)
local init="luaopen_"..gsub(rawname,"%.","_")
if helpers.trace then
- helpers.report("! calling loadlib with '%s' with init '%s'",resolved,init)
+ helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
end
return package.loadlib(resolved,init)
end
local function loadedbylua(name)
if helpers.trace then
- helpers.report("! locating '%s' using normal loader",name)
+ helpers.report("locating '%s' using normal loader",name)
end
return true,searchers[-2](name)
end
@@ -225,17 +225,17 @@ local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating '%s' as '%s' on '%s' paths",rawname,name,what)
+ report("locating '%s' as '%s' on '%s' paths",rawname,name,what)
end
for p=1,#paths do
local path=paths[p]
local resolved=filejoin(path,name)
if trace then
- report("! checking for '%s' using '%s' path '%s'",name,what,path)
+ report("checking for '%s' using '%s' path '%s'",name,what,path)
end
if isreadable(resolved) then
if trace then
- report("! lib '%s' located on '%s'",name,resolved)
+ report("lib '%s' located on '%s'",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -5814,7 +5814,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-set"] = package.loaded["trac-set"] or true
--- original size: 12360, stripped down to: 8799
+-- original size: 12365, stripped down to: 8799
if not modules then modules={} end modules ['trac-set']={
version=1.001,
@@ -6126,7 +6126,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 21607, stripped down to: 15212
+-- original size: 21795, stripped down to: 14194
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -6135,49 +6135,6 @@ if not modules then modules={} end modules ['trac-log']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
-if tex and (tex.jobname or tex.formatname) then
- local texio_write_nl=texio.write_nl
- local texio_write=texio.write
- local io_write=io.write
- local write_nl=function(target,...)
- if not io_write then
- io_write=io.write
- end
- if target=="term and log" then
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- elseif target=="log" then
- texio_write_nl("log",...)
- elseif target=="term" then
- texio_write_nl("term","")
- io_write(...)
- else
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- end
- end
- local write=function(target,...)
- if not io_write then
- io_write=io.write
- end
- if target=="term and log" then
- texio_write("log",...)
- io_write(...)
- elseif target=="log" then
- texio_write("log",...)
- elseif target=="term" then
- io_write(...)
- else
- texio_write("log",...)
- io_write(...)
- end
- end
- texio.write=write
- texio.write_nl=write_nl
-else
-end
local write_nl,write=texio and texio.write_nl or print,texio and texio.write or io.write
local format,gmatch,find=string.format,string.gmatch,string.find
local concat,insert,remove=table.concat,table.insert,table.remove
@@ -6510,8 +6467,9 @@ function logs.show()
end
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
-local delayed_reporters={} setmetatableindex(delayed_reporters,function(t,k)
- local v=logs.reporter(k)
+local delayed_reporters={}
+setmetatableindex(delayed_reporters,function(t,k)
+ local v=logs.reporter(k.name)
t[k]=v
return v
end)
@@ -12674,7 +12632,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 60509, stripped down to: 42429
+-- original size: 60821, stripped down to: 42503
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -12848,7 +12806,8 @@ end
local slash=P("/")
local pathexpressionpattern=Cs (
Cc("^")*(
- Cc("%")*S(".-")+slash^2*P(-1)/"/.*"+slash^2/"/.-/"+(1-slash)*P(-1)*Cc("/")+P(1)
+ Cc("%")*S(".-")+slash^2*P(-1)/"/.*"
++slash^2/"/[^/]*/*"+(1-slash)*P(-1)*Cc("/")+P(1)
)^1*Cc("$")
)
local cache={}
@@ -13583,6 +13542,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
if trace_detail then
report_resolving("checking filename %a",filename)
end
+ local resolve=resolvers.resolve
local result={}
for k=1,#pathlist do
local path=pathlist[k]
@@ -13601,8 +13561,8 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
local fl=filelist[k]
local f=fl[2]
local d=dirlist[k]
- if find(d,expression) then
- result[#result+1]=resolvers.resolve(fl[3])
+ if find(d,expression) or find(resolve(d),expression) then
+ result[#result+1]=resolve(fl[3])
done=true
if allresults then
if trace_detail then
@@ -13624,7 +13584,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
else
method="filesystem"
pathname=gsub(pathname,"/+$","")
- pathname=resolvers.resolve(pathname)
+ pathname=resolve(pathname)
local scheme=url.hasscheme(pathname)
if not scheme or scheme=="file" then
local pname=gsub(pathname,"%.%*$",'')
@@ -13834,7 +13794,9 @@ local function findgivenfiles(filename,allresults)
if found~="" then
noffound=noffound+1
result[noffound]=resolvers.resolve(found)
- if not allresults then break end
+ if not allresults then
+ break
+ end
end
else
for kk=1,#blist do
@@ -15109,7 +15071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lua"] = package.loaded["data-lua"] or true
--- original size: 4333, stripped down to: 3534
+-- original size: 4861, stripped down to: 3693
if not modules then modules={} end modules ['data-lua']={
version=1.001,
@@ -15122,7 +15084,7 @@ local resolvers,package=resolvers,package
local gsub=string.gsub
local concat=table.concat
local addsuffix=file.addsuffix
-local P,Cs,lpegmatch=lpeg.P,lpeg.Cs,lpeg.match
+local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
local libsuffixes={ 'tex','lua' }
local clibsuffixes={ 'lib' }
local libformats={ 'TEXINPUTS','LUAINPUTS' }
@@ -15174,17 +15136,17 @@ local function loadedbyformat(name,rawname,suffixes,islib)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating %a as %a using formats %a",rawname,name,suffixes)
+ report("locating %a as %a using formats %a",rawname,name,suffixes)
end
for i=1,#suffixes do
local format=suffixes[i]
local resolved=resolvers.findfile(name,format) or ""
if trace then
- report("! checking for %a using format %a",name,format)
+ report("checking %a using format %a",name,format)
end
if resolved~="" then
if trace then
- report("! lib %a located on %a",name,resolved)
+ report("lib %a located on %a",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -15195,8 +15157,13 @@ local function loadedbyformat(name,rawname,suffixes,islib)
end
end
helpers.loadedbyformat=loadedbyformat
+local pattern=Cs((((1-S("\\/"))^0*(S("\\/")^1/"/"))^0*(P(".")^1/"/"+P(1))^1)*-1)
+local function lualibfile(name)
+ return lpegmatch(pattern,name) or name
+end
+helpers.lualibfile=lualibfile
function helpers.loaded(name)
- local thename=gsub(name,"%.","/")
+ local thename=lualibfile(name)
local luaname=addsuffix(thename,"lua")
local libname=addsuffix(thename,os.libsuffix)
local libpaths=getlibpaths()
@@ -15227,7 +15194,6 @@ function helpers.loaded(name)
end
return notloaded(name)
end
-package.searchers[3]=nil
resolvers.loadlualib=require
@@ -15435,6 +15401,139 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-lib"] = package.loaded["util-lib"] or true
+
+-- original size: 8911, stripped down to: 4216
+
+if not modules then modules={} end modules ['util-lib']={
+ version=1.001,
+ comment="companion to luat-lib.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files",
+}
+local gsub,find=string.gsub,string.find
+local pathpart,nameonly,joinfile=file.pathpart,file.nameonly,file.join
+local findfile,findfiles=resolvers and resolvers.findfile,resolvers and resolvers.findfiles
+local loaded=package.loaded
+local report_swiglib=logs.reporter("swiglib")
+local trace_swiglib=false trackers.register("resolvers.swiglib",function(v) trace_swiglib=v end)
+local function requireswiglib(required,version)
+ local library=loaded[required]
+ if library==nil then
+ local required_full=gsub(required,"%.","/")
+ local required_path=pathpart(required_full)
+ local required_base=nameonly(required_full)
+ local required_name=required_base.."."..os.libsuffix
+ local version=type(version)=="string" and version~="" and version or false
+ local function check(locate,...)
+ local found_library=nil
+ if version then
+ local asked_library=joinfile(required_path,version,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","with version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ if not found_library or found_library==""then
+ asked_library=joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ end
+ else
+ local asked_library=joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ end
+ return found_library and found_library~="" and found_library or false
+ end
+ local found_library=findfile and check(findfile,"lib")
+ if findfiles and not found_library then
+ local asked_library=joinfile(required_path,".*",required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","latest version",asked_library)
+ end
+ local list=findfiles(asked_library,"lib",true)
+ if list and #list>0 then
+ table.sort(list)
+ found_library=list[#list]
+ end
+ end
+ if not found_library then
+ package.extraclibpath(environment.ownpath)
+ local paths=package.clibpaths()
+ for i=1,#paths do
+ local found_library=check(lfs.isfile)
+ if found_library then
+ break
+ end
+ end
+ end
+ if not found_library then
+ if trace_swiglib then
+ report_swiglib("not found: %a",asked_library)
+ end
+ library=false
+ else
+ local path=pathpart(found_library)
+ local base=nameonly(found_library)
+ dir.push(path)
+ if trace_swiglib then
+ report_swiglib("found: %a",found_library)
+ end
+ library=package.loadlib(found_library,"luaopen_"..required_base)
+ if type(library)=="function" then
+ library=library()
+ else
+ library=false
+ end
+ dir.pop()
+ end
+ if not library then
+ report_swiglib("unknown: %a",required)
+ elseif trace_swiglib then
+ report_swiglib("stored: %a",required)
+ end
+ loaded[required]=library
+ else
+ report_swiglib("reused: %a",required)
+ end
+ return library
+end
+local savedrequire=require
+function require(name,version)
+ if find(name,"^swiglib%.") then
+ return requireswiglib(name,version)
+ else
+ return savedrequire(name)
+ end
+end
+local swiglibs={}
+function swiglib(name,version)
+ local library=swiglibs[name]
+ if not library then
+ statistics.starttiming(swiglibs)
+ report_swiglib("loading %a",name)
+ library=requireswiglib("swiglib."..name,version)
+ swiglibs[name]=library
+ statistics.stoptiming(swiglibs)
+ end
+ return library
+end
+statistics.register("used swiglibs",function()
+ if next(swiglibs) then
+ return string.format("%s, initial load time %s seconds",table.concat(table.sortedkeys(swiglibs)," "),statistics.elapsedtime(swiglibs))
+ end
+end)
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["luat-sta"] = package.loaded["luat-sta"] or true
-- original size: 5703, stripped down to: 2507
@@ -15672,10 +15771,10 @@ end
end -- of closure
--- used libraries : l-lua.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua luat-sta.lua luat-fmt.lua
+-- used libraries : l-lua.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 648348
--- stripped bytes : 235055
+-- original bytes : 658276
+-- stripped bytes : 241564
-- end library merge
@@ -15765,6 +15864,8 @@ local ownlibs = { -- order can be made better
'data-tmf.lua',
'data-lst.lua',
+ 'util-lib.lua', -- swiglib
+
'luat-sta.lua',
'luat-fmt.lua',
@@ -16978,4 +17079,4 @@ end
if ok == false then ok = 1 elseif ok == true then ok = 0 end
-os.exit(ok)
+os.exit(ok,true) -- true forces a cleanup in 5.2+
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 4997d7458..00f63a579 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -56,7 +56,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-lua"] = package.loaded["l-lua"] or true
--- original size: 10064, stripped down to: 5696
+-- original size: 10048, stripped down to: 5684
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -177,7 +177,7 @@ local function addpath(what,paths,extras,hash,...)
local path=cleanpath(path)
if not hash[path] then
if trace then
- report("! extra %s path: %s",what,path)
+ report("extra %s path: %s",what,path)
end
paths [#paths+1]=path
extras[#extras+1]=path
@@ -211,13 +211,13 @@ searchers[3]=nil
local function loadedaslib(resolved,rawname)
local init="luaopen_"..gsub(rawname,"%.","_")
if helpers.trace then
- helpers.report("! calling loadlib with '%s' with init '%s'",resolved,init)
+ helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
end
return package.loadlib(resolved,init)
end
local function loadedbylua(name)
if helpers.trace then
- helpers.report("! locating '%s' using normal loader",name)
+ helpers.report("locating '%s' using normal loader",name)
end
return true,searchers[-2](name)
end
@@ -225,17 +225,17 @@ local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating '%s' as '%s' on '%s' paths",rawname,name,what)
+ report("locating '%s' as '%s' on '%s' paths",rawname,name,what)
end
for p=1,#paths do
local path=paths[p]
local resolved=filejoin(path,name)
if trace then
- report("! checking for '%s' using '%s' path '%s'",name,what,path)
+ report("checking for '%s' using '%s' path '%s'",name,what,path)
end
if isreadable(resolved) then
if trace then
- report("! lib '%s' located on '%s'",name,resolved)
+ report("lib '%s' located on '%s'",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -5814,7 +5814,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-set"] = package.loaded["trac-set"] or true
--- original size: 12360, stripped down to: 8799
+-- original size: 12365, stripped down to: 8799
if not modules then modules={} end modules ['trac-set']={
version=1.001,
@@ -6126,7 +6126,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 21607, stripped down to: 15212
+-- original size: 21795, stripped down to: 14194
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -6135,49 +6135,6 @@ if not modules then modules={} end modules ['trac-log']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
-if tex and (tex.jobname or tex.formatname) then
- local texio_write_nl=texio.write_nl
- local texio_write=texio.write
- local io_write=io.write
- local write_nl=function(target,...)
- if not io_write then
- io_write=io.write
- end
- if target=="term and log" then
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- elseif target=="log" then
- texio_write_nl("log",...)
- elseif target=="term" then
- texio_write_nl("term","")
- io_write(...)
- else
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- end
- end
- local write=function(target,...)
- if not io_write then
- io_write=io.write
- end
- if target=="term and log" then
- texio_write("log",...)
- io_write(...)
- elseif target=="log" then
- texio_write("log",...)
- elseif target=="term" then
- io_write(...)
- else
- texio_write("log",...)
- io_write(...)
- end
- end
- texio.write=write
- texio.write_nl=write_nl
-else
-end
local write_nl,write=texio and texio.write_nl or print,texio and texio.write or io.write
local format,gmatch,find=string.format,string.gmatch,string.find
local concat,insert,remove=table.concat,table.insert,table.remove
@@ -6510,8 +6467,9 @@ function logs.show()
end
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
-local delayed_reporters={} setmetatableindex(delayed_reporters,function(t,k)
- local v=logs.reporter(k)
+local delayed_reporters={}
+setmetatableindex(delayed_reporters,function(t,k)
+ local v=logs.reporter(k.name)
t[k]=v
return v
end)
@@ -12674,7 +12632,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 60509, stripped down to: 42429
+-- original size: 60821, stripped down to: 42503
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -12848,7 +12806,8 @@ end
local slash=P("/")
local pathexpressionpattern=Cs (
Cc("^")*(
- Cc("%")*S(".-")+slash^2*P(-1)/"/.*"+slash^2/"/.-/"+(1-slash)*P(-1)*Cc("/")+P(1)
+ Cc("%")*S(".-")+slash^2*P(-1)/"/.*"
++slash^2/"/[^/]*/*"+(1-slash)*P(-1)*Cc("/")+P(1)
)^1*Cc("$")
)
local cache={}
@@ -13583,6 +13542,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
if trace_detail then
report_resolving("checking filename %a",filename)
end
+ local resolve=resolvers.resolve
local result={}
for k=1,#pathlist do
local path=pathlist[k]
@@ -13601,8 +13561,8 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
local fl=filelist[k]
local f=fl[2]
local d=dirlist[k]
- if find(d,expression) then
- result[#result+1]=resolvers.resolve(fl[3])
+ if find(d,expression) or find(resolve(d),expression) then
+ result[#result+1]=resolve(fl[3])
done=true
if allresults then
if trace_detail then
@@ -13624,7 +13584,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
else
method="filesystem"
pathname=gsub(pathname,"/+$","")
- pathname=resolvers.resolve(pathname)
+ pathname=resolve(pathname)
local scheme=url.hasscheme(pathname)
if not scheme or scheme=="file" then
local pname=gsub(pathname,"%.%*$",'')
@@ -13834,7 +13794,9 @@ local function findgivenfiles(filename,allresults)
if found~="" then
noffound=noffound+1
result[noffound]=resolvers.resolve(found)
- if not allresults then break end
+ if not allresults then
+ break
+ end
end
else
for kk=1,#blist do
@@ -15109,7 +15071,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lua"] = package.loaded["data-lua"] or true
--- original size: 4333, stripped down to: 3534
+-- original size: 4861, stripped down to: 3693
if not modules then modules={} end modules ['data-lua']={
version=1.001,
@@ -15122,7 +15084,7 @@ local resolvers,package=resolvers,package
local gsub=string.gsub
local concat=table.concat
local addsuffix=file.addsuffix
-local P,Cs,lpegmatch=lpeg.P,lpeg.Cs,lpeg.match
+local P,S,Cs,lpegmatch=lpeg.P,lpeg.S,lpeg.Cs,lpeg.match
local libsuffixes={ 'tex','lua' }
local clibsuffixes={ 'lib' }
local libformats={ 'TEXINPUTS','LUAINPUTS' }
@@ -15174,17 +15136,17 @@ local function loadedbyformat(name,rawname,suffixes,islib)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating %a as %a using formats %a",rawname,name,suffixes)
+ report("locating %a as %a using formats %a",rawname,name,suffixes)
end
for i=1,#suffixes do
local format=suffixes[i]
local resolved=resolvers.findfile(name,format) or ""
if trace then
- report("! checking for %a using format %a",name,format)
+ report("checking %a using format %a",name,format)
end
if resolved~="" then
if trace then
- report("! lib %a located on %a",name,resolved)
+ report("lib %a located on %a",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -15195,8 +15157,13 @@ local function loadedbyformat(name,rawname,suffixes,islib)
end
end
helpers.loadedbyformat=loadedbyformat
+local pattern=Cs((((1-S("\\/"))^0*(S("\\/")^1/"/"))^0*(P(".")^1/"/"+P(1))^1)*-1)
+local function lualibfile(name)
+ return lpegmatch(pattern,name) or name
+end
+helpers.lualibfile=lualibfile
function helpers.loaded(name)
- local thename=gsub(name,"%.","/")
+ local thename=lualibfile(name)
local luaname=addsuffix(thename,"lua")
local libname=addsuffix(thename,os.libsuffix)
local libpaths=getlibpaths()
@@ -15227,7 +15194,6 @@ function helpers.loaded(name)
end
return notloaded(name)
end
-package.searchers[3]=nil
resolvers.loadlualib=require
@@ -15435,6 +15401,139 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-lib"] = package.loaded["util-lib"] or true
+
+-- original size: 8911, stripped down to: 4216
+
+if not modules then modules={} end modules ['util-lib']={
+ version=1.001,
+ comment="companion to luat-lib.mkiv",
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files",
+}
+local gsub,find=string.gsub,string.find
+local pathpart,nameonly,joinfile=file.pathpart,file.nameonly,file.join
+local findfile,findfiles=resolvers and resolvers.findfile,resolvers and resolvers.findfiles
+local loaded=package.loaded
+local report_swiglib=logs.reporter("swiglib")
+local trace_swiglib=false trackers.register("resolvers.swiglib",function(v) trace_swiglib=v end)
+local function requireswiglib(required,version)
+ local library=loaded[required]
+ if library==nil then
+ local required_full=gsub(required,"%.","/")
+ local required_path=pathpart(required_full)
+ local required_base=nameonly(required_full)
+ local required_name=required_base.."."..os.libsuffix
+ local version=type(version)=="string" and version~="" and version or false
+ local function check(locate,...)
+ local found_library=nil
+ if version then
+ local asked_library=joinfile(required_path,version,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","with version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ if not found_library or found_library==""then
+ asked_library=joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ end
+ else
+ local asked_library=joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library=locate(asked_library,...)
+ end
+ return found_library and found_library~="" and found_library or false
+ end
+ local found_library=findfile and check(findfile,"lib")
+ if findfiles and not found_library then
+ local asked_library=joinfile(required_path,".*",required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","latest version",asked_library)
+ end
+ local list=findfiles(asked_library,"lib",true)
+ if list and #list>0 then
+ table.sort(list)
+ found_library=list[#list]
+ end
+ end
+ if not found_library then
+ package.extraclibpath(environment.ownpath)
+ local paths=package.clibpaths()
+ for i=1,#paths do
+ local found_library=check(lfs.isfile)
+ if found_library then
+ break
+ end
+ end
+ end
+ if not found_library then
+ if trace_swiglib then
+ report_swiglib("not found: %a",asked_library)
+ end
+ library=false
+ else
+ local path=pathpart(found_library)
+ local base=nameonly(found_library)
+ dir.push(path)
+ if trace_swiglib then
+ report_swiglib("found: %a",found_library)
+ end
+ library=package.loadlib(found_library,"luaopen_"..required_base)
+ if type(library)=="function" then
+ library=library()
+ else
+ library=false
+ end
+ dir.pop()
+ end
+ if not library then
+ report_swiglib("unknown: %a",required)
+ elseif trace_swiglib then
+ report_swiglib("stored: %a",required)
+ end
+ loaded[required]=library
+ else
+ report_swiglib("reused: %a",required)
+ end
+ return library
+end
+local savedrequire=require
+function require(name,version)
+ if find(name,"^swiglib%.") then
+ return requireswiglib(name,version)
+ else
+ return savedrequire(name)
+ end
+end
+local swiglibs={}
+function swiglib(name,version)
+ local library=swiglibs[name]
+ if not library then
+ statistics.starttiming(swiglibs)
+ report_swiglib("loading %a",name)
+ library=requireswiglib("swiglib."..name,version)
+ swiglibs[name]=library
+ statistics.stoptiming(swiglibs)
+ end
+ return library
+end
+statistics.register("used swiglibs",function()
+ if next(swiglibs) then
+ return string.format("%s, initial load time %s seconds",table.concat(table.sortedkeys(swiglibs)," "),statistics.elapsedtime(swiglibs))
+ end
+end)
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["luat-sta"] = package.loaded["luat-sta"] or true
-- original size: 5703, stripped down to: 2507
@@ -15672,10 +15771,10 @@ end
end -- of closure
--- used libraries : l-lua.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua luat-sta.lua luat-fmt.lua
+-- used libraries : l-lua.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 648348
--- stripped bytes : 235055
+-- original bytes : 658276
+-- stripped bytes : 241564
-- end library merge
@@ -15765,6 +15864,8 @@ local ownlibs = { -- order can be made better
'data-tmf.lua',
'data-lst.lua',
+ 'util-lib.lua', -- swiglib
+
'luat-sta.lua',
'luat-fmt.lua',
@@ -16978,4 +17079,4 @@ end
if ok == false then ok = 1 elseif ok == true then ok = 0 end
-os.exit(ok)
+os.exit(ok,true) -- true forces a cleanup in 5.2+
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 21e24eb48..b2df7931a 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.03.27 13:27}
+\newcontextversion{2013.03.29 01:31}
%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 a877420d9..ec48d6bae 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.04.02 11:22}
+\newcontextversion{2013.04.05 22:00}
%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
index a654316df..bccf8fc16 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index c1c1e1e98..0a8bac0da 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 6fed3272e..1309ce1cb 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -1,4 +1,4 @@
-%D \module
+ %D \module
%D [ file=context,
%D version=2008.28.10, % 1995.10.10,
%D title=\CONTEXT,
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index e20dad34b..e4442fdcd 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.04.02 11:22}
+\edef\contextversion{2013.04.05 22:00}
\edef\contextkind {beta}
%D For those who want to use this:
@@ -314,6 +314,7 @@
\loadmarkfile{page-imp}
\loadmkvifile{page-sel} % optional
+\loadmkvifile{page-inj} % optional
\loadmkvifile{scrn-pag}
\loadmkvifile{scrn-wid}
diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua
index 06102188c..cb284b9a7 100644
--- a/tex/context/base/core-con.lua
+++ b/tex/context/base/core-con.lua
@@ -177,20 +177,17 @@ converters.maxchrs = maxchrs
local lowercharacter = characters.lcchars
local uppercharacter = characters.ucchars
-local function do_alphabetic(n,mapping,mapper,t)
+local function do_alphabetic(n,mapping,mapper,t) -- todo: make zero based variant (initial n + 1)
if not t then
t = { }
end
- local chr = mapping[n] or fallback
- if mapper then
- chr = mapper[chr]
- end
local max = #mapping
if n > max then
do_alphabetic(floor((n-1)/max),mapping,mapper,t)
n = (n-1) % max + 1
end
- t[#t+1] = chr
+ local chr = mapping[n] or fallback
+ t[#t+1] = mapper and mapper[chr] or chr
if n <= max then
return concat(t)
end
@@ -635,22 +632,22 @@ end
-- print(gregorian_to_jalali(2009,02,24))
-- print(jalali_to_gregorian(1387,12,06))
--- more efficient but needs testing
---
--- local escapes = utffilters.private.escapes
---
+-- -- more efficient but needs testing
+
+-- local escapes = characters.filters.utf.private.escapes
+
-- local function do_alphabetic(n,mapping,chr)
-- local max = #mapping
-- if n > max then
--- do_alphabetic(floor((n-1)/max),max,chr)
+-- do_alphabetic(floor((n-1)/max),mapping,chr)
-- n = (n-1)%max+1
-- end
-- n = chr(n,mapping)
-- context(escapes[n] or utfchar(n))
-- end
---
+
-- local lccodes, uccodes, safechar = characters.lccode, characters.uccode, commands.safechar
---
+
-- local function do_alphabetic(n,mapping,chr)
-- local max = #mapping
-- if n > max then
@@ -659,16 +656,16 @@ end
-- end
-- safechar(chr(n,mapping))
-- end
---
+
-- local function lowercased(n,mapping) return characters.lccode(mapping[n] or fallback) end
-- local function uppercased(n,mapping) return characters.uccode(mapping[n] or fallback) end
---
+
-- function converters.alphabetic(n,code)
--- do_alphabetic(n,counters[code] or counters['**'],lowercased) -- lccode catches wrong tables
+-- do_alphabetic(n,counters[code] or counters.default,lowercased) -- lccode catches wrong tables
-- end
---
+
-- function converters.Alphabetic(n,code)
--- do_alphabetic(n,counters[code] or counters['**'],uppercased)
+-- do_alphabetic(n,counters[code] or counters.default,uppercased)
-- end
local ordinals = {
diff --git a/tex/context/base/data-lua.lua b/tex/context/base/data-lua.lua
index fde79d464..7e3d92585 100644
--- a/tex/context/base/data-lua.lua
+++ b/tex/context/base/data-lua.lua
@@ -14,7 +14,7 @@ local gsub = string.gsub
local concat = table.concat
local addsuffix = file.addsuffix
-local P, Cs, lpegmatch = lpeg.P, lpeg.Cs, lpeg.match
+local P, S, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg.Cs, lpeg.match
local libsuffixes = { 'tex', 'lua' }
local clibsuffixes = { 'lib' }
@@ -77,17 +77,17 @@ local function loadedbyformat(name,rawname,suffixes,islib)
local trace = helpers.trace
local report = helpers.report
if trace then
- report("! locating %a as %a using formats %a",rawname,name,suffixes)
+ report("locating %a as %a using formats %a",rawname,name,suffixes)
end
for i=1,#suffixes do -- so we use findfile and not a lookup loop
local format = suffixes[i]
local resolved = resolvers.findfile(name,format) or ""
if trace then
- report("! checking for %a using format %a",name,format)
+ report("checking %a using format %a",name,format)
end
if resolved ~= "" then
if trace then
- report("! lib %a located on %a",name,resolved)
+ report("lib %a located on %a",name,resolved)
end
if islib then
return true, loadedaslib(resolved,rawname)
@@ -102,8 +102,25 @@ helpers.loadedbyformat = loadedbyformat
-- alternatively we could set the package.searchers
+local pattern = Cs((((1-S("\\/"))^0 * (S("\\/")^1/"/"))^0 * (P(".")^1/"/"+P(1))^1) * -1)
+
+local function lualibfile(name)
+ return lpegmatch(pattern,name) or name
+end
+
+helpers.lualibfile = lualibfile
+
+-- print(lualibfile("bar"))
+-- print(lualibfile("foo.bar"))
+-- print(lualibfile("crap/foo...bar"))
+-- print(lualibfile("crap//foo.bar"))
+-- print(lualibfile("crap/../foo.bar"))
+-- print(lualibfile("crap/.././foo.bar"))
+
+-- alternatively we could split in path and base and temporary set the libpath to path
+
function helpers.loaded(name)
- local thename = gsub(name,"%.","/")
+ local thename = lualibfile(name)
local luaname = addsuffix(thename,"lua")
local libname = addsuffix(thename,os.libsuffix)
local libpaths = getlibpaths()
@@ -135,7 +152,7 @@ function helpers.loaded(name)
return notloaded(name)
end
-package.searchers[3] = nil -- get rid of the built in one
+-- package.searchers[3] = nil -- get rid of the built in one (done in l-lua)
-- package.extraclibpath(environment.ownpath)
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua
index c69ee4ce3..f7e238a11 100644
--- a/tex/context/base/data-res.lua
+++ b/tex/context/base/data-res.lua
@@ -290,11 +290,12 @@ end
local slash = P("/")
-local pathexpressionpattern = Cs (
+local pathexpressionpattern = Cs ( -- create lpeg instead (2013/2014)
Cc("^") * (
Cc("%") * S(".-")
+ slash^2 * P(-1) / "/.*"
- + slash^2 / "/.-/"
+-- + slash^2 / "/.-/"
+ + slash^2 / "/[^/]*/*"
+ (1-slash) * P(-1) * Cc("/")
+ P(1)
)^1 * Cc("$") -- yes or no $
@@ -1138,7 +1139,11 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
if trace_detail then
report_resolving("checking filename %a",filename)
end
+ local resolve = resolvers.resolve
local result = { }
+ -- pathlist : resolved
+ -- dirlist : unresolved or resolved
+ -- filelist : unresolved
for k=1,#pathlist do
local path = pathlist[k]
local pathname = lpegmatch(inhibitstripper,path)
@@ -1158,9 +1163,10 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
local fl = filelist[k]
local f = fl[2]
local d = dirlist[k]
- if find(d,expression) then
+ -- resolve is new:
+ if find(d,expression) or find(resolve(d),expression) then
-- todo, test for readable
- result[#result+1] = resolvers.resolve(fl[3]) -- no shortcut
+ result[#result+1] = resolve(fl[3]) -- no shortcut
done = true
if allresults then
if trace_detail then
@@ -1182,7 +1188,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
else
method = "filesystem" -- bonus, even when !! is specified
pathname = gsub(pathname,"/+$","")
- pathname = resolvers.resolve(pathname)
+ pathname = resolve(pathname)
local scheme = url.hasscheme(pathname)
if not scheme or scheme == "file" then
local pname = gsub(pathname,"%.%*$",'')
@@ -1413,7 +1419,9 @@ local function findgivenfiles(filename,allresults)
if found ~= "" then
noffound = noffound + 1
result[noffound] = resolvers.resolve(found)
- if not allresults then break end
+ if not allresults then
+ break
+ end
end
else
for kk=1,#blist do
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index deba4e49d..cb640b892 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -402,6 +402,8 @@ local function presetcontext(name,parent,features) -- will go to con and shared
features[k] = v
end
end
+ else
+ -- just ignore an undefined one .. i.e. we can refer to not yet defined
end
end
end
@@ -659,8 +661,23 @@ end
-- we need a copy as we will add (fontclass) goodies to the features and
-- that is bad for a shared table
+-- local function splitcontext(features) -- presetcontext creates dummy here
+-- return fastcopy(setups[features] or (presetcontext(features,"","") and setups[features]))
+-- end
+
local function splitcontext(features) -- presetcontext creates dummy here
- return fastcopy(setups[features] or (presetcontext(features,"","") and setups[features]))
+ local sf = setups[features]
+ if not sf then
+ local n -- number
+ if find(features,",") then
+ -- let's assume a combination which is not yet defined but just specified (as in math)
+ n, sf = presetcontext(features,features,"")
+ else
+ -- we've run into an unknown feature and or a direct spec so we create a dummy
+ n, sf = presetcontext(features,"","")
+ end
+ end
+ return fastcopy(sf)
end
-- local splitter = lpeg.splitat("=")
diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua
index 74073227a..5074e49ed 100644
--- a/tex/context/base/font-def.lua
+++ b/tex/context/base/font-def.lua
@@ -328,9 +328,21 @@ function definers.loadfont(specification)
return tfmdata
end
---[[ldx--
-<p>For virtual fonts we need a slightly different approach:</p>
---ldx]]--
+local function checkvirtual(tfmdata)
+ -- begin of experiment: we can use { "slot", 0, number } in virtual fonts
+ local fonts = tfmdata.fonts
+ local selfid = font.nextid()
+ if fonts and #fonts > 0 then
+ for i=1,#fonts do
+ if fonts[i][2] == 0 then
+ fonts[i][2] = selfid
+ end
+ end
+ else
+ tfmdata.fonts = { "id", selfid }
+ end
+ -- end of experiment
+end
function constructors.readanddefine(name,size) -- no id -- maybe a dummy first
local specification = definers.analyze(name,size)
@@ -344,7 +356,7 @@ function constructors.readanddefine(name,size) -- no id -- maybe a dummy first
if not id then
local tfmdata = definers.loadfont(specification)
if tfmdata then
- tfmdata.properties.hash = hash
+ checkvirtual(tfmdata) -- experiment, will become obsolete when slots can selfreference
id = font.define(tfmdata)
definers.register(tfmdata,id)
else
diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua
index df8cbe160..89d5927d4 100644
--- a/tex/context/base/font-ext.lua
+++ b/tex/context/base/font-ext.lua
@@ -902,7 +902,9 @@ function fonts.helpers.addprivate(tfmdata,name,characterdata)
privates = { }
properties.privates = privates
end
- privates[name] = lastprivate
+ if name then
+ privates[name] = lastprivate
+ end
properties.lastprivate = lastprivate
tfmdata.characters[lastprivate] = characterdata
if properties.finalized then
diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua
index 810d49eea..91a5ea66c 100644
--- a/tex/context/base/font-gds.lua
+++ b/tex/context/base/font-gds.lua
@@ -719,3 +719,19 @@ end
commands.loadfontgoodies = fontgoodies.load
commands.enablefontcolorschemes = colorschemes.enable
+
+-- weird place ... depends on math
+
+local function finalize(tfmdata,feature,value)
+ mathematics.overloaddimensions(tfmdata,tfmdata,value)
+end
+
+registerotffeature {
+ name = "mathdimensions",
+ description = "manipulate math dimensions",
+ -- default = true,
+ manipulators = {
+ base = finalize,
+ node = finalize,
+ }
+}
diff --git a/tex/context/base/l-lua.lua b/tex/context/base/l-lua.lua
index 555d5d746..538c65d7e 100644
--- a/tex/context/base/l-lua.lua
+++ b/tex/context/base/l-lua.lua
@@ -214,7 +214,7 @@ local function addpath(what,paths,extras,hash,...)
local path = cleanpath(path)
if not hash[path] then
if trace then
- report("! extra %s path: %s",what,path)
+ report("extra %s path: %s",what,path)
end
paths [#paths +1] = path
extras[#extras+1] = path
@@ -253,7 +253,7 @@ end
-- local path = cleanpath(path)
-- if not libhash[path] then
-- if trace then
--- report("! extra lua path: %s",path)
+-- report("extra lua path: %s",path)
-- end
-- libextras[#libextras+1] = path
-- libpaths [#libpaths +1] = path
@@ -283,7 +283,7 @@ end
-- local path = cleanpath(path)
-- if not clibhash[path] then
-- if trace then
--- report("! extra lib path: %s",path)
+-- report("extra lib path: %s",path)
-- end
-- clibextras[#clibextras+1] = path
-- clibpaths [#clibpaths +1] = path
@@ -317,14 +317,14 @@ local function loadedaslib(resolved,rawname)
-- local init = "luaopen_" .. string.match(rawname,".-([^%.]+)$")
local init = "luaopen_"..gsub(rawname,"%.","_")
if helpers.trace then
- helpers.report("! calling loadlib with '%s' with init '%s'",resolved,init)
+ helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
end
return package.loadlib(resolved,init)
end
local function loadedbylua(name)
if helpers.trace then
- helpers.report("! locating '%s' using normal loader",name)
+ helpers.report("locating '%s' using normal loader",name)
end
return true, searchers[-2](name) -- the original
end
@@ -333,17 +333,17 @@ local function loadedbypath(name,rawname,paths,islib,what)
local trace = helpers.trace
local report = helpers.report
if trace then
- report("! locating '%s' as '%s' on '%s' paths",rawname,name,what)
+ report("locating '%s' as '%s' on '%s' paths",rawname,name,what)
end
for p=1,#paths do
local path = paths[p]
local resolved = filejoin(path,name)
if trace then -- mode detail
- report("! checking for '%s' using '%s' path '%s'",name,what,path)
+ report("checking for '%s' using '%s' path '%s'",name,what,path)
end
if isreadable(resolved) then
if trace then
- report("! lib '%s' located on '%s'",name,resolved)
+ report("lib '%s' located on '%s'",name,resolved)
end
if islib then
return true, loadedaslib(resolved,rawname)
diff --git a/tex/context/base/luat-lib.mkiv b/tex/context/base/luat-lib.mkiv
index a2ad4cac4..3f72e780e 100644
--- a/tex/context/base/luat-lib.mkiv
+++ b/tex/context/base/luat-lib.mkiv
@@ -30,7 +30,6 @@
\registerctxluafile{trac-inf}{1.001}
%registerctxluafile{trac-pro}{1.001}
\registerctxluafile{util-lua}{1.001}
-\registerctxluafile{util-lib}{1.001}
\registerctxluafile{util-deb}{1.001} % could also be done in trac-deb.mkiv
\registerctxluafile{util-tpl}{1.001} % needs tracker
@@ -61,6 +60,8 @@
\registerctxluafile{data-use}{1.001}
\registerctxluafile{data-aux}{1.001}
+\registerctxluafile{util-lib}{1.001}
+
\registerctxluafile{luat-cbk}{1.001}
\registerctxluafile{luat-run}{1.001}
\registerctxluafile{luat-fio}{1.001}
diff --git a/tex/context/base/m-graph.mkiv b/tex/context/base/m-graph.mkiv
index c80e4ad91..25933d9eb 100644
--- a/tex/context/base/m-graph.mkiv
+++ b/tex/context/base/m-graph.mkiv
@@ -67,11 +67,12 @@
if unknown context_grap: input "mp-grap.mpiv" ; fi ;
\stopMPdefinitions
-% gone:
-%
-% \startMPextensions
-% if unknown Fe_plus : picture Fe_plus ; Fe_plus := textext("+") ; fi ;
-% \stopMPextensions
+% For backwards compatibility (for the moment), also load the graph macros in
+% the standard MP instance (scaled integer):
+
+\startMPdefinitions
+ if unknown context_grap: input "mp-grap.mpiv" ; fi ;
+\stopMPdefinitions
\protect
@@ -79,7 +80,7 @@
\starttext
-\startMPpage
+\startMPpage[instance=graph]
label(format("@g","1e-8"), (0, 0)) ;
label(format("@g","1e+8"), (2cm, 0)) ;
label(format("@g","1e-10"), (0, -0.5cm)) ;
@@ -94,19 +95,19 @@
label(format("@g","1e+102"),(2cm,-2.5cm)) ;
\stopMPpage
-% \startMPpage
+% \startMPpage[instance=graph]
% draw begingraph(3in,2in);
% gdraw "t:/metapost/grphdata/agepop91.d";
% endgraph;
% \stopMPpage
-% \startMPpage
+% \startMPpage[instance=graph]
% draw begingraph(3in,2in);
% gdraw "agepop91.d" plot btex $\bullet$ etex;
% endgraph;
% \stopMPpage
-% \startMPpage
+% \startMPpage[instance=graph]
% draw begingraph(3in,2in);
% glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
% glabel.bot(btex Age in years etex, OUT);
@@ -114,7 +115,7 @@
% endgraph;
% \stopMPpage
-% \startMPpage
+% \startMPpage[instance=graph]
% draw begingraph(3in,2in);
% glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
% glabel.bot(btex Age in years etex, OUT);
@@ -123,7 +124,7 @@
% endgraph;
% \stopMPpage
-% \startMPpage
+% \startMPpage[instance=graph]
% draw begingraph(2.3in,2in);
% setcoords(log,log);
% glabel.lft(btex Seconds etex,OUT);
@@ -136,7 +137,7 @@
% endgraph;
% \stopMPpage
-% \startMPpage
+% \startMPpage[instance=graph]
% draw begingraph(6.5cm,4.5cm);
% setrange(80,0, 90,whatever);
% glabel.bot(btex Year etex, OUT);
diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua
index bfc229a92..8aeb0a97f 100644
--- a/tex/context/base/math-act.lua
+++ b/tex/context/base/math-act.lua
@@ -8,6 +8,9 @@ if not modules then modules = { } end modules ['math-act'] = {
-- Here we tweak some font properties (if needed).
+local type, next = type, next
+local fastcopy = table.fastcopy
+
local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
local report_math = logs.reporter("mathematics","initializing")
@@ -193,6 +196,89 @@ end
sequencers.appendaction("beforecopyingcharacters","system","mathematics.tweakbeforecopyingfont")
sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweakaftercopyingfont")
+function mathematics.overloaddimensions(target,original,set)
+ local goodies = target.goodies
+ if goodies then
+ for i=1,#goodies do
+ local goodie = goodies[i]
+ local mathematics = goodie.mathematics
+ local dimensions = mathematics and mathematics.dimensions
+ if dimensions then
+ if trace_defining then
+ report_math("overloading dimensions in %a @ %p",target.properties.fullname,target.parameters.size)
+ end
+ local characters = target.characters
+ local parameters = target.parameters
+ local factor = parameters.factor
+ local hfactor = parameters.hfactor
+ local vfactor = parameters.vfactor
+ local addprivate = fonts.helpers.addprivate
+ local function overload(dimensions)
+ for unicode, data in next, dimensions do
+ local character = characters[unicode]
+ if character then
+ --
+ local width = data.width
+ local height = data.height
+ local depth = data.depth
+ if trace_defining and (width or height or depth) then
+ report_math("overloading dimensions of %C, width %a, height %a, depth %a",unicode,width,height,depth)
+ end
+ if width then character.width = width * hfactor end
+ if height then character.height = height * vfactor end
+ if depth then character.depth = depth * vfactor end
+ --
+ local xoffset = data.xoffset
+ local yoffset = data.yoffset
+ if xoffset then
+ xoffset = { "right", xoffset * hfactor }
+ end
+ if yoffset then
+ yoffset = { "down", -yoffset * vfactor }
+ end
+ if xoffset or yoffset then
+ local slot = { "slot", 1, addprivate(target,nil,fastcopy(character)) }
+ if xoffset and yoffset then
+ character.commands = { xoffset, yoffset, slot }
+ elseif xoffset then
+ character.commands = { xoffset, slot }
+ else
+ character.commands = { yoffset, slot }
+ end
+ character.index = nil
+ end
+ elseif trace_defining then
+ report_math("no overloading dimensions of %C, not in font",unicode)
+ end
+ end
+ end
+ if set == nil then
+ set = { "default" }
+ end
+ if set == "all" or set == true then
+ for name, set in next, dimensions do
+ overload(set)
+ end
+ else
+ if type(set) == "string" then
+ set = utilities.parsers.settings_to_array(set)
+ end
+ if type(set) == "table" then
+ for i=1,#set do
+ local d = dimensions[set[i]]
+ if d then
+ overload(d)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
+
+sequencers.appendaction("aftercopyingcharacters", "system","mathematics.overloaddimensions")
+
-- a couple of predefined tewaks:
local tweaks = { }
diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv
index 0e08c70bb..a172dc8ae 100644
--- a/tex/context/base/math-ali.mkiv
+++ b/tex/context/base/math-ali.mkiv
@@ -424,6 +424,7 @@
\setupmathcases
[\c!distance=\emwidth,
+ \c!strut=\v!yes, % new
\c!numberdistance=2.5\emwidth,
\c!left={\left\{\mskip\thinmuskip},
\c!right={\right.}]
@@ -438,30 +439,72 @@
\edef\currentmathcases{#1}%
\dosingleempty\math_cases_start_indeed}
+\def\math_cases_NC_zero
+ {\math_cases_NC}
+
+\def\math_cases_MC_zero
+ {\math_cases_NC
+ \ifmmode\else
+ \startimath
+ \let\math_cases_end_math\stopimath
+ \fi}
+
+\let\math_cases_end_math\relax
+
+\def\math_cases_NR_zero
+ {\unskip
+ \math_cases_end_math
+ \aligntab
+ \global\let\math_cases_NC\math_cases_NC_first
+ \dodirectdoubleempty\math_cases_NR}
+
+\def\math_cases_NC_first
+ {\global\let\math_cases_NC\math_cases_NC_second}
+
+\def\math_cases_NC_second
+ {\math_cases_end_math\aligntab}
+
+\let\math_cases_NR\math_align_NR_generic
+
\unexpanded\def\math_cases_start_indeed[#1]%
{\iffirstargument
\setupcurrentmathcases[#1]%
\fi
+ \edef\p_strut{\mathcasesparameter\c!strut}%
+ \ifx\p_strut\v!yes
+ \let\math_cases_strut\strut
+ \else
+ \let\math_cases_strut\relax
+ \fi
\mathcasesparameter\c!left
\vcenter\bgroup
\pushmacro\math_cases_NC
\let\endmath\relax
- \def\NC{\math_cases_NC}%
- \def\MC{\math_cases_NC\ifmmode\else$\def\endmath{$}\fi}%
- \global\let\math_cases_NC\math_cases_NC_indeed
- \def\NR{\unskip\endmath&\global\let\math_cases_NC\math_cases_NC_indeed\dodirectdoubleempty\math_cases_NR}%
+ \let\NC\math_cases_NC_zero
+ \let\MC\math_cases_MC_zero
+ \let\NR\math_cases_NR_zero
+ \global\let\math_cases_NC\math_cases_NC_first
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
\tabskip\zeropoint
\global\c_math_eqalign_column\plusone
\halign\bgroup
- $\mathcasesparameter\c!style##$\hfil
- &\hskip\mathcasesparameter\c!distance\relax
- \popmacro\math_cases_NC##\hfil
- &\hskip\mathcasesparameter\c!numberdistance\relax
- \let\formuladistance\!!zeropoint
- \span\math_text_in_eqalign{##}%
+ \startimath
+ \mathcasesparameter\c!style
+ \alignmark\alignmark
+ \stopimath
+ \hfil
+ \aligntab
+ \hskip\mathcasesparameter\c!distance\relax
+ \popmacro\math_cases_NC
+ \math_cases_strut % looks better
+ \alignmark\alignmark
+ \hfil
+ \aligntab
+ \hskip\mathcasesparameter\c!numberdistance\relax
+ \let\formuladistance\!!zeropoint
+ \span\math_text_in_eqalign{\alignmark\alignmark}%
\crcr} % todo: number
\def\math_cases_stop
@@ -472,11 +515,6 @@
\mathcasesparameter\c!right
\endgroup}
-\def\math_cases_NC_indeed
- {\gdef\math_cases_NC{\endmath&}}
-
-\let\math_cases_NR\math_align_NR_generic
-
\definemathcases[cases]
\definemathcases[\v!mathcases]
diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv
index 62111a642..97b330248 100644
--- a/tex/context/base/mult-aux.mkiv
+++ b/tex/context/base/mult-aux.mkiv
@@ -266,6 +266,12 @@
\let\definehandlerparent\empty
+\def\mult_check_for_parent#1#2#3#4%
+ {\ifcsname#1#4:\s!parent\endcsname \else \ifx#4\empty \else
+ \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}%
+ \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}%
+ \fi \fi}
+
\unexpanded\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9% why is \expanded still needed in clones
{\ifx#4\relax\let#4\empty\fi % see \defineregister
\unexpanded\def#2{\dotripleempty#5}%
@@ -277,6 +283,7 @@
\ifthirdargument
\the#6% predefine
\edef#8{##2}%
+ \mult_check_for_parent{#1}{#3}#4#8%
\expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}%
\mult_interfaces_get_parameters{#1#4:}[##3]%
\else\ifsecondargument
@@ -288,6 +295,7 @@
\mult_interfaces_get_parameters{#1#4:}[##2]%
\else
\edef#8{##2}%
+ \mult_check_for_parent{#1}{#3}#4#8%
\expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}%
\fi
\else
diff --git a/tex/context/base/mult-fun.lua b/tex/context/base/mult-fun.lua
index f7a7792e5..a661c53bb 100644
--- a/tex/context/base/mult-fun.lua
+++ b/tex/context/base/mult-fun.lua
@@ -11,6 +11,7 @@ return {
-- "autoarrows", "ahfactor",
-- "angleoffset", anglelength", anglemethod",
"metapostversion",
+ "maxdimensions",
},
commands = {
--
diff --git a/tex/context/base/pack-pos.mkiv b/tex/context/base/pack-pos.mkiv
index ff8244f0a..f92ceb78a 100644
--- a/tex/context/base/pack-pos.mkiv
+++ b/tex/context/base/pack-pos.mkiv
@@ -146,7 +146,8 @@
\c!yscale
\c!yfactor
\vbox to \zeropoint
- {\vskip\d_pack_positioning_y_position
+ {\offinterlineskip % else we get an empty line
+ \vskip\d_pack_positioning_y_position
\hbox to \zeropoint
{\hskip\d_pack_positioning_x_position
\box\nextbox
diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv
index db7986c28..213f8be1a 100644
--- a/tex/context/base/page-imp.mkiv
+++ b/tex/context/base/page-imp.mkiv
@@ -90,18 +90,33 @@
\installshipoutmethod \v!none
{\page_shipouts_ignore}
+% extension mechanism
+
+\newcount\c_page_boxes_flush_n % set at the lua end
+
+\let\page_boxes_flush_before\relax
+\let\page_boxes_flush_after \relax
+
+% used here:
+
\def\page_boxes_shipout#1% or: \page_shipouts_apply
- {\dontcomplain % redundant
- \the\everybeforeshipout
- \ifcase\shipoutfinalizemethod
- \page_shipouts_handle{#1}%
- \else
- \setbox\shipoutscratchbox\hbox{#1}% just in case there are objects there, hook for testing (will go away)
- \finalizeshipoutbox\shipoutscratchbox
- \page_shipouts_handle{\box\shipoutscratchbox}%
- \fi
- \setnextrealpageno % so this comes before \everyaftershipout so in fact:
- \the\everyaftershipout} % at this point we're already on the next realpage
+ {\dontcomplain % redundant
+ \ifcase\c_page_boxes_flush_n\else
+ \page_boxes_flush_before
+ \fi
+ \the\everybeforeshipout
+ \ifcase\shipoutfinalizemethod
+ \page_shipouts_handle{#1}%
+ \else
+ \setbox\shipoutscratchbox\hbox{#1}% just in case there are objects there, hook for testing (will go away)
+ \finalizeshipoutbox\shipoutscratchbox
+ \page_shipouts_handle{\box\shipoutscratchbox}%
+ \fi
+ \setnextrealpageno % so this comes before \everyaftershipout so in fact:
+ \the\everyaftershipout % at this point we're already on the next realpage
+ \ifcase\c_page_boxes_flush_n\else
+ \page_boxes_flush_after
+ \fi}
\def\page_shipouts_ignore#1%
{\begingroup
diff --git a/tex/context/base/page-inj.lua b/tex/context/base/page-inj.lua
new file mode 100644
index 000000000..5b450d60e
--- /dev/null
+++ b/tex/context/base/page-inj.lua
@@ -0,0 +1,101 @@
+if not modules then modules = { } end modules ["page-inj"] = {
+ version = 1.000,
+ comment = "Page injections",
+ author = "Wolfgang Schuster & Hans Hagen",
+ copyright = "Wolfgang Schuster & Hans Hagen",
+ license = "see context related readme files",
+}
+
+-- Adapted a bit by HH: numbered states, tracking, delayed, order, etc.
+
+local injections = pagebuilders.injections or { }
+pagebuilders.injections = injections
+
+local report = logs.reporter("pagebuilder","injections")
+local trace = false trackers.register("pagebuilder.injections",function(v) trace = v end)
+
+local variables = interfaces.variables
+
+local v_yes = variables.yes
+local v_previous = variables.previous
+local v_next = variables.next
+
+local order = 0
+local cache = { }
+
+function injections.save(specification) -- maybe not public, just commands.*
+ order = order + 1
+ cache[#cache+1] = {
+ order = order,
+ name = specification.name,
+ state = tonumber(specification.state) or specification.state,
+ parameters = specification.userdata,
+ }
+ tex.setcount("global","c_page_boxes_flush_n",#cache)
+end
+
+function injections.flushbefore() -- maybe not public, just commands.*
+ if #cache > 0 then
+ local delayed = { }
+ context.unprotect()
+ for i=1,#cache do
+ local c = cache[i]
+ local oldstate = c.state
+ if oldstate == v_previous then
+ if trace then
+ report("entry %a, order %a, flushing due to state %a",i,c.order,oldstate)
+ end
+ context.page_injections_flush_saved(c.name,c.parameters)
+ elseif type(oldstate) == "number" and oldstate < 0 then
+ local newstate = oldstate + 1
+ if newstate >= 0 then
+ newstate = v_previous
+ end
+ if trace then
+ report("entry %a, order %a, changing state from %a to %a",i,c.order,oldstate,newstate)
+ end
+ c.state = newstate
+ delayed[#delayed+1] = c
+ else
+ delayed[#delayed+1] = c
+ end
+ end
+ context.unprotect()
+ cache = delayed
+ tex.setcount("global","c_page_boxes_flush_n",#cache)
+ end
+end
+
+function injections.flushafter() -- maybe not public, just commands.*
+ if #cache > 0 then
+ local delayed = { }
+ context.unprotect()
+ for i=1,#cache do
+ local c = cache[i]
+ local oldstate = c.state
+ if oldstate == v_next then
+ if trace then
+ report("entry %a, order %a, flushing due to state %a",i,c.order,oldstate)
+ end
+ context.page_injections_flush_saved(c.name,c.parameters)
+ elseif type(oldstate) == "number" and oldstate> 0 then
+ local newstate = oldstate- 1
+ if newstate <= 0 then
+ newstate = v_next
+ end
+ if trace then
+ report("entry %a, order %a, changing state from %a to %a",i,c.order,oldstate,newstate)
+ end
+ c.state = newstate
+ delayed[#delayed+1] = c
+ end
+ end
+ context.protect()
+ cache = delayed
+ tex.setcount("global","c_page_boxes_flush_n",#cache)
+ end
+end
+
+commands.page_injections_save = injections.save
+commands.page_injections_flush_after = injections.flushafter
+commands.page_injections_flush_before = injections.flushbefore
diff --git a/tex/context/base/page-inj.mkvi b/tex/context/base/page-inj.mkvi
new file mode 100644
index 000000000..bee564683
--- /dev/null
+++ b/tex/context/base/page-inj.mkvi
@@ -0,0 +1,217 @@
+%D \module
+%D [ file=page-inj,
+%D version=2013.02.10,
+%D title=\CONTEXT\ Page Module,
+%D subtitle=Injections,
+%D author=Wolfgang Schuster \& Hans Hagen,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster \& Hans Hagen,
+%D license=see context related readme files (gpl)]
+
+%D This module is based on an idea and prototype by Wolfgang but instead of
+%D injectioning into a page constructor we injection it into the regular shipout
+%D handler because that way we get page numbering. It's a sort of variation
+%D on postponing but the content does not end up in the regular page flow, so
+%D it's closer to page figures but without the usual page builder.
+%D
+%D This module is following the mkvi way of rendering setups and configuration
+%D and is somewhat experimental. Probably more alternatives will be added. This
+%D could become a delayed loaded module at some point (no real consequences).
+
+\unprotect
+
+\registerctxluafile{page-inj}{1.001}
+
+\installcorenamespace {pageinjection}
+\installcorenamespace {pageinjectionalternative}
+\installcorenamespace {pageinjectionrenderings}
+
+\installframedcommandhandler \??pageinjection {pageinjection} \??pageinjection
+\installcommandhandler \??pageinjectionalternative {pageinjectionalternative} \??pageinjectionalternative
+
+\def\page_boxes_flush_before{\ctxcommand{page_injections_flush_before()}}
+\def\page_boxes_flush_after {\ctxcommand{page_injections_flush_after ()}}
+
+\def\page_injections_flush_saved#name#parameters%
+ {\begingroup
+ \edef\currentpageinjection{#name}%
+ \getdummyparameters[#parameters]%
+ \edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }%
+ \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}%
+ \page_injections_nextpage
+ \invokepagehandler\v!normal{\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}%
+ \endgroup}
+
+\unexpanded\def\pageinjection
+ {\begingroup
+ \dodoubleempty\page_injections_direct}
+
+\def\page_injections_direct[#1][#2]% name parameters | settings parameters | name | parameters
+ {\doifassignmentelse{#1}
+ {\doifassignmentelse{#2}
+ {\page_injections_direct_settings_parameters{#1}{#2}}
+ {\page_injections_direct_parameters {#1}}}
+ {\doifassignmentelse{#2}
+ {\page_injections_direct_name_parameters {#1}{#2}}
+ {\page_injections_direct_name {#1}}}}
+
+\def\page_injections_direct_settings_parameters#settings% #parameters%
+ {\let\currentpageinjection\empty
+ \checkpageinjectionparent
+ \setupcurrentpageinjection[#settings]%
+ \page_injections_direct_indeed}
+
+\def\page_injections_direct_parameters% #parameters%
+ {\let\currentpageinjection\empty
+ \checkpageinjectionparent
+ \page_injections_direct_indeed}
+
+\def\page_injections_direct_name_parameters#name% #parameters%
+ {\edef\currentpageinjection{#name}%
+ \checkpageinjectionparent
+ \page_injections_direct_indeed}
+
+\def\page_injections_direct_name#name%
+ {\edef\currentpageinjection{#name}%
+ \checkpageinjectionparent
+ \page_injections_direct_indeed{}}
+
+\def\page_injections_direct_indeed% #parameters%
+ {\edef\p_page_injections_state{\pageinjectionparameter\c!state}%
+ \edef\p_page_injections_delay{\pageinjectionparameter\c!delay}%
+ \edef\p_page_injections_page {\pageinjectionparameter\c!page }%
+ \ifx\p_page_injections_delay\v!yes
+ \expandafter\page_injections_direct_indeed_yes
+ \else
+ \expandafter\page_injections_direct_indeed_nop
+ \fi}
+
+\def\page_injections_direct_indeed_yes#parameters%
+ {\ctxcommand{page_injections_save{
+ name = "\currentpageinjection",
+ state = "\p_page_injections_state",
+ userdata = \!!bs\normalunexpanded{#parameters}\!!es
+ }}%
+ \endgroup}
+
+\def\page_injections_direct_indeed_nop#parameters%
+ {\ifx\p_page_injections_page\empty
+ \page
+ \else
+ \page[\p_page_injections_page]%
+ \fi
+ \getdummyparameters[#parameters]%
+ \page_injections_place
+ \endgroup}
+
+\def\page_injections_place
+ {\edef\currentpageinjectionalternative {\pageinjectionparameter \c!alternative }%
+ \edef\p_page_injectionalternative_rederingsetup{\pageinjectionalternativeparameter\c!renderingsetup}%
+ \page_injections_nextpage
+ \ifx\currentpageinjectionalternative\v!none \else % increment counter but don’t generate output
+ \invokepagehandler\v!normal{\inheritedpageinjectionframed{\texsetup\p_page_injectionalternative_rederingsetup}}%
+ \fi}
+
+\def\page_injections_nextpage
+ {\edef\p_page_injections_pagestate{\pageinjectionparameter\c!pagestate}%
+ \ifx\p_page_injections_pagestate\v!stop \else
+ \edef\p_page_injections_n{\pageinjectionparameter\c!n}%
+ \ifx\p_page_injections_n\empty
+ \let\p_page_injections_n\plusone
+ \fi
+ \dorecurse\p_page_injections_n
+ {\incrementcounter[\s!realpage]%
+ \incrementcounter[\s!userpage]}%
+ \fi}
+
+\definepageinjectionalternative[\v!figure][\c!renderingsetup=\??pageinjectionrenderings:\v!figure]
+\definepageinjectionalternative[\v!buffer][\c!renderingsetup=\??pageinjectionrenderings:\v!buffer]
+\definepageinjectionalternative[\v!setups][\c!renderingsetup=\??pageinjectionrenderings:\s!setup ]
+
+\startsetups[\??pageinjectionrenderings:\v!figure]
+ \dontleavehmode\externalfigure[\dummyparameter\c!name][\c!factor=\v!max]
+\stopsetups
+
+\startsetups[\??pageinjectionrenderings:\s!setup]
+ \setups[\dummyparameter\c!setup]% kind of redundant but fits in
+\stopsetups
+
+\startsetups[\??pageinjectionrenderings:\v!buffer]
+ \getbuffer[\dummyparameter\c!name]%
+\stopsetups
+
+% \setuppaper
+% [\c!method=\v!pageinjection]
+
+\setuppageinjection
+ [ \c!width=\paperwidth,
+ \c!height=\paperheight,
+ \c!frame=\v!off,
+ \c!offset=\v!overlay,
+ \c!delay=\v!no,
+ \c!state=\v!next,
+ \c!alternative=\v!figure]
+
+\definepageinjection[\v!previouspage][\c!delay=\v!yes,\c!state=\v!previous]
+\definepageinjection[\v!nextpage] [\c!delay=\v!yes,\c!state=\v!next]
+\definepageinjection[\v!here] % direct
+\definepageinjection[\v!empty] [\c!alternative=\v!none]
+
+%definepageinjection[\v!chapter] [\v!previouspage][\c!pagestate=\v!stop]
+
+\protect \endinput
+
+% \enabletrackers[pagebuilder.injections]
+%
+% \setuppageinjection[offset=2em]
+%
+% \definepageinjection[chapter][previouspage][pagestate=stop]
+% \definepageinjection[later] [delay=yes,state=+2]
+%
+% \useMPlibrary[dum]
+%
+% \starttext
+%
+% \startchapter[title={Insert pages before/after the current page}]
+%
+% \dorecurse{10}{one: \input ward\par}
+%
+% \pageinjection[previouspage][name=dummy-1]
+%
+% \dorecurse{20}{two: \input ward\par} \page
+%
+% \pageinjection[nextpage][name=dummy-2]
+% \pageinjection[later] [name=dummy-4]
+% \pageinjection[delay=yes,state=+2][name=dummy-5]
+%
+% \dorecurse{100}{three: \input ward\par}
+%
+% \stopchapter
+%
+% \startbuffer[whatever]
+% \dorecurse{10}{whatever #1 }
+% \stopbuffer
+%
+% \startchapter[title={Insert pages at the current location}]
+%
+% \dorecurse{10}{\input ward\par}
+%
+% \pageinjection[direct][name=dummy-3]
+% \pageinjection[direct][alternative=buffer,name=whatever]
+%
+% \dorecurse{10}{\input ward\par}
+%
+% \stopchapter
+%
+% \setuphead
+% [chapter]
+% [beforesection={\pageinjection[empty]},
+% insidesection={\pageinjection[chapter][name=\structureuservariable{image}]}]
+%
+% \startchapter[title={Combine both mechanism}][name=dummy-4]
+%
+% \dorecurse{10}{\input ward\par}
+%
+% \stopchapter
+%
+% \stoptext
diff --git a/tex/context/base/s-abr-01.tex b/tex/context/base/s-abr-01.tex
index bbaa1e941..026f2ea09 100644
--- a/tex/context/base/s-abr-01.tex
+++ b/tex/context/base/s-abr-01.tex
@@ -233,6 +233,7 @@
\logo [SSD] {ssd}
\logo [SVG] {svg}
\logo [SWIG] {swig}
+\logo [SWIGLIB] {SwigLib}
\logo [TABLE] {\TaBlE}
\logo [TCPIP] {tcp/ip}
\logo [TDS] {tds} % no sc te
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 0647c17dc..28cb15781 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index c758864d9..8cc75d46c 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-enu.mkvi b/tex/context/base/strc-enu.mkvi
index 62b54dbe0..185b4177e 100644
--- a/tex/context/base/strc-enu.mkvi
+++ b/tex/context/base/strc-enu.mkvi
@@ -229,30 +229,6 @@
% Maybe we should move counters to the construction level as more derived mechanisms
% use it \unknown\ so don't depend on names here!
-% \newtoks\everysetupenumerationcounter
-%
-% \let\v_strc_enumerations_counter_name\empty % or just p_counter
-%
-% \def\strc_enumerations_setup_counter#tag%
-% {\edef\v_strc_enumerations_counter_name{#tag}% only used in the token list
-% \the\everysetupenumerationcounter}
-%
-% \def\strc_enumerations_define_counter#tag% todo: fast inheritance (was mainparameter)
-% {\definecounter[#tag]%
-% \strc_enumerations_setup_counter{#tag}}
-%
-% \appendtoks
-% \strc_counter_setup_using_parameter\v_strc_enumerations_counter_name\enumerationparameter
-% \to \everysetupenumerationcounter
-%
-% \appendtoks
-% \ifx\currentenumeration\empty
-% \synchronizeenumerationcounters % this one can also do the rest .... but we need an extra arg then
-% \else
-% \strc_enumerations_setup_counter\currentenumeration
-% \fi
-% \to \everysetupenumeration
-
\def\strc_enumerations_define_counter#tag% todo: move inline
{\definecounter[#tag]%
\registerenumerationcounter{#tag}}
@@ -261,6 +237,10 @@
\synchronizeenumerationcounters
\to \everysetupenumeration
+\appendtoks
+ \synchronizeenumerationcounters
+\to \everydefineenumeration
+
%D Initializer:
%D The handlers.
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index 696a03e99..dbf70f9c3 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -143,10 +143,15 @@
\installcounterassociation{floatcaption}
\appendtoks
- \let\currentfloat\currentfloatcaption
+ \let\currentfloat\currentfloatcaption % ?
\synchronizefloatcaptioncounters
\to \everysetupfloatcaption
+\appendtoks
+ \let\currentfloat\currentfloatcaption % ?
+ \synchronizefloatcaptioncounters
+\to \everydefinefloatcaption
+
%D Definitions:
\let\strc_floats_define_saved\definefloat
diff --git a/tex/context/base/strc-lab.mkiv b/tex/context/base/strc-lab.mkiv
index 28a5020ed..772a9cc19 100644
--- a/tex/context/base/strc-lab.mkiv
+++ b/tex/context/base/strc-lab.mkiv
@@ -92,7 +92,6 @@
\fi
\doifcounterelse\p_counter\donothing{\strc_labels_define_counter\p_counter}%
\letlabelparameter\s!counter\p_counter
- %\strc_labels_setup_counter\currentlabel
\to \everydefinelabel
\let\p_strc_constructions_title \empty
@@ -139,28 +138,6 @@
% similar to enumerations
-% \newtoks\everysetuplabelcounter
-%
-% \let\v_strc_labels_counter_name\empty
-%
-% \def\strc_labels_setup_counter#1%
-% {\edef\v_strc_labels_counter_name{#1}%
-% \the\everysetuplabelcounter}
-%
-% \def\strc_labels_define_counter#1%
-% {\definecounter[#1]%
-% \strc_labels_setup_counter{#1}}
-%
-% \appendtoks
-% \strc_counter_setup_using_parameter\v_strc_labels_counter_name\labelparameter
-% \to \everysetuplabelcounter
-%
-% \appendtoks
-% \ifx\currentlabel\empty \else
-% \strc_labels_setup_counter\currentlabel
-% \fi
-% \to \everysetuplabel
-
\def\strc_labels_define_counter#1%
{\definecounter[#1]%
\registerlabelcounter{#1}}
@@ -169,6 +146,10 @@
\synchronizelabelcounters
\to \everysetuplabel
+\appendtoks
+ \synchronizelabelcounters
+\to \everydefinelabel
+
% no start stop here
\expandafter\let\csname\??constructionmainhandler\v!label\expandafter\endcsname\csname\??constructionmainhandler\v!description\endcsname
diff --git a/tex/context/base/strc-mat.mkiv b/tex/context/base/strc-mat.mkiv
index 933dce48a..20fa078a2 100644
--- a/tex/context/base/strc-mat.mkiv
+++ b/tex/context/base/strc-mat.mkiv
@@ -57,18 +57,16 @@
[\v!formula]
[numbers,characters] % no \v! ?
-% \strc_counter_preset_using_parameter\setupformulas\rootcounterparameter
-%
-% \appendtoks
-% \strc_counter_setup_using_parameter\v!formula\formulaparameter
-% \to \everysetupformula
-
\installcounterassociation{formula} \registerformulacounter\v!formula % currently we only have one
\appendtoks
\synchronizeformulacounters
\to \everysetupformula
+% \appendtoks
+% \synchronizeformulacounters
+% \to \everydefineformula
+
\setupformulas
[\c!numberconversionset=\v!formula] % why forgotten
diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi
index 324499b4e..09ea41bc4 100644
--- a/tex/context/base/strc-not.mkvi
+++ b/tex/context/base/strc-not.mkvi
@@ -382,20 +382,6 @@
\def\currentnoteinsertion {\noteparameter\s!insert}
\def\currentnoteinsertionnumber{\namedinsertionnumber{\noteparameter\s!insert}}
-% \appendtoks
-% \doifinsertionelse\currentnote
-% \donothing
-% {\defineinsertion[\currentnote]% could be an option
-% \normalexpanded{\t_strc_notes{\the\t_strc_notes\noexpand\strc_notes_process_list{\currentnote}}}}%
-% \letnoteparameter\s!insert\currentnote
-% \ctxcommand{definenote("\currentnote","insert",\number\currentnoteinsertionnumber)}%
-% \ifx\currentnoteparent\empty
-% \definenotation[\currentnote][\c!type=\v!note]%
-% \else
-% \definenotation[\currentnote][\currentnoteparent][\c!type=\v!note]%
-% \fi
-% \to \everydefinenote
-
\appendtoks
\ifx\currentnoteparent\empty
\doifinsertionelse\currentnote
@@ -413,30 +399,6 @@
% maybe we will share this at some point:
-% \newtoks\everysetupnotecounter
-%
-% \let\v_strc_note_counter_name\empty
-%
-% \def\strc_notes_setup_counter#tag%
-% {\edef\v_strc_note_counter_name{#tag}% only used in the token list
-% \the\everysetupnotecounter}
-%
-% \def\strc_notes_define_counter#tag% todo: fast inheritance (was mainparameter
-% {\definecounter[#tag]%
-% \strc_notes_setup_counter{#tag}}
-%
-% \appendtoks
-% \strc_counter_setup_using_parameter\v_strc_note_counter_name\notationparameter
-% \to \everysetupnotecounter
-%
-% \appendtoks
-% \ifx\currentnotation\empty
-% \synchronizeenumerationcounters
-% \else
-% \strc_notes_setup_counter\currentnotation
-% \fi
-% \to \everysetupnotation
-
\def\strc_notes_define_counter#tag% todo: move inline
{\definecounter[#tag]%
\registerenumerationcounter{#tag}}
@@ -445,6 +407,10 @@
\synchronizenotationcounters
\to \everysetupnotation
+\appendtoks
+ \synchronizenotationcounters
+\to \everydefinenotation
+
% so far
%expandafter\let\csname\??constructionstarthandler \v!notation\expandafter\endcsname\csname\??constructionstarthandler \v!enumeration\endcsname
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index de9ebf6b4..b0d73f28c 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -133,7 +133,7 @@
\setuevalue{\e!setup\currentregister\e!endsetup}{\setupregister[\currentregister]}%
\dorecurse\plusthree {% weird, expanded should not be needed
\normalexpanded{\defineregister[\currentregister:\recurselevel][\currentregister]}%
-% \defineregister[\currentregister:\recurselevel][\currentregister]%
+ %\defineregister[\currentregister:\recurselevel][\currentregister]%
\letregisterparameter{\c!entries:\recurselevel}\empty % needed as we use detokenize (ok, we can
\letregisterparameter{\c!keys :\recurselevel}\empty % avoid it, but it's faster too)
}%
diff --git a/tex/context/base/tabl-tab.mkiv b/tex/context/base/tabl-tab.mkiv
index b9b519620..dbea3efe9 100644
--- a/tex/context/base/tabl-tab.mkiv
+++ b/tex/context/base/tabl-tab.mkiv
@@ -14,19 +14,17 @@
% Todo: consistent namespace and get rid of not used code
-% In \MKIV\ the old table macros are sort of obsolete. The
-% color extensions have been removed and some code is stripped.
-% For practical reasons the \TABLE\ macros that are used are
-% embedded in this file.
+% In \MKIV\ the old table macros are sort of obsolete. The color extensions
+% have been removed and some code is stripped. For practical reasons the
+% \TABLE\ macros that are used are embedded in this file.
%
-% The following code is based on TABLE 1.0 by Michael J. Wichura
-% (August 1988. We used a patched version with many overloads
-% and extensions. The documented (and larger) source can be found
-% in \type {thrd-tab.tex}.
+% The following code is based on TABLE 1.0 by Michael J. Wichura (August 1988.
+% We used a patched version with many overloads and extensions. The documented
+% (and larger) source can be found in \type {thrd-tab.tex}.
%
-% Some code has been stripped. Some color has been added. Some macros
-% have been renamed. Registers have been replaces. And probably much
-% more can be cleaned up.
+% Some code has been stripped. Some color has been added. Some macros have
+% been renamed. Registers have been replaces. And probably much more can be
+% cleaned up. We also need to use \tabl_tab_ prefixes here.
\unprotect
@@ -1370,8 +1368,8 @@
{\dochucktableautorow % before the tail, else noalign problem
\doinserttabletail
\starttablenoalign
- \globalletempty\dotablehead
- \globalletempty\dotabletail
+ \global\let\dotablehead\empty
+ \global\let\dotabletail\empty
\stoptablenoalign
\dofinishtable
\ifx\p_tabl_table_frame\empty
@@ -1598,6 +1596,8 @@
\egroup
\dontcomplain
\dosplittablebox\tablecontentbox
+ \global\let\dotablehead\empty % new here
+ \global\let\dotabletail\empty % new here
\flushnotes
\egroup}
@@ -1651,18 +1651,10 @@
\let\dotablehead\empty % needs checking
\let\dotabletail\empty % needs checking
-\letbeundefined{\e!start\v!tablehead}
-\letbeundefined{\e!stop \v!tablehead}
-\letbeundefined{\e!start\v!tabletail}
-\letbeundefined{\e!stop \v!tabletail}
-
-\expanded
- {\long\def\csname\e!start\v!tablehead\endcsname##1\csname\e!stop\v!tablehead\endcsname%
- {\noexpand\settablehead##1\noexpand\end}}
-
-\expanded
- {\long\def\csname\e!start\v!tabletail\endcsname##1\csname\e!stop\v!tabletail\endcsname%
- {\noexpand\settabletail##1\noexpand\end}}
+\letvalue{\e!start\v!tablehead}\relax
+\letvalue{\e!stop \v!tablehead}\relax
+\letvalue{\e!start\v!tabletail}\relax
+\letvalue{\e!stop \v!tabletail}\relax
%D The second argument is a dummy one, by scanning for it, we
%D get rid of interfering spaces.
@@ -1671,11 +1663,27 @@
\newconditional\hassometablehead
\newconditional\hassometabletail
-\def\settablehead{\dodoubleempty\dosettablehead}
-\def\settabletail{\dodoubleempty\dosettabletail}
+\unexpanded\def\settablehead{\dodoubleempty\dosettablehead}
+\unexpanded\def\settabletail{\dodoubleempty\dosettabletail}
+
+% \def\dosettablehead[#1][#2]#3\end{\setvalue{\??tablehead#1}{\tablenoalign{\global\settrue\hassometablehead}#3}}
+% \def\dosettabletail[#1][#2]#3\end{\setvalue{\??tabletail#1}{\tablenoalign{\global\settrue\hassometabletail}#3}}
+
+\def\dosettablehead[#1][#2]#3\end
+ {\gdef\dotablehead{\executeifdefined{\??tablehead#1}\empty}% new
+ \setvalue{\??tablehead#1}{\tablenoalign{\global\settrue\hassometablehead}#3}}
+
+\def\dosettabletail[#1][#2]#3\end
+ {\gdef\dotabletail{\executeifdefined{\??tabletail#1}\empty}% new
+ \setvalue{\??tabletail#1}{\tablenoalign{\global\settrue\hassometabletail}#3}}
+
+\normalexpanded
+ {\def\csname\e!start\v!tablehead\endcsname#1\csname\e!stop\v!tablehead\endcsname%
+ {\settablehead#1\noexpand\end}}
-\long\def\dosettablehead[#1][#2]#3\end{\setvalue{\??tablehead#1}{\tablenoalign{\global\settrue\hassometablehead}#3}}
-\long\def\dosettabletail[#1][#2]#3\end{\setvalue{\??tabletail#1}{\tablenoalign{\global\settrue\hassometabletail}#3}}
+\normalexpanded
+ {\def\csname\e!start\v!tabletail\endcsname#1\csname\e!stop\v!tabletail\endcsname%
+ {\settabletail#1\noexpand\end}}
%D Redundant \type{\HL}'s are removed automatically, so
%D mid||lines can be used without problems.
diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua
index ba37447a6..fe167c343 100644
--- a/tex/context/base/trac-deb.lua
+++ b/tex/context/base/trac-deb.lua
@@ -106,18 +106,31 @@ function tracers.showlines(filename,linenumber,offset,errorstr)
end
local lines = data and string.splitlines(data)
if lines and #lines > 0 then
- -- this does not work yet as we cannot access the last lua error
- -- table.print(status.list())
- -- this will be a plugin sequence
- local what, where = match(errorstr,"LuaTeX error <main (%a+) instance>:(%d+)")
- if what and where then
+ -- This does not work completely as we cannot access the last Lua error using
+ -- table.print(status.list()). This is on the agenda. Eventually we will
+ -- have a sequence of checks here (tex, lua, mp) at this end.
+ --
+ -- Actually, in 0.75+ the lua error message is even weirder as you can
+ -- get:
+ --
+ -- LuaTeX error [string "\directlua "]:3: unexpected symbol near '1' ...
+ --
+ -- <inserted text> \endgroup \directlua {
+ --
+ -- So there is some work to be done in the LuaTeX engine.
+ --
+ local what, where = match(errorstr,[[LuaTeX error <main (%a+) instance>:(%d+)]])
+ or match(errorstr,[[LuaTeX error %[string "\\(.-lua) "%]:(%d+)]]) -- buglet
+ if where then
-- lua error: linenumber points to last line
- local start, stop = "\\start" .. what .. "code", "\\stop" .. what .. "code"
+ local start = "\\startluacode"
+ local stop = "\\stopluacode"
+ local where = tonumber(where)
if lines[linenumber] == start then
local n = linenumber
for i=n,1,-1 do
if lines[i] == start then
- local n = i + tonumber(where)
+ local n = i + where
if n <= linenumber then
linenumber = n
end
@@ -156,6 +169,7 @@ function tracers.printerror(offset)
-- add a bit of spacing around our variant
texio.write_nl("\n")
local errorstr = status.lasterrorstring or "?"
+ -- inspect(status.list())
report_system("error on line %s in file %s: %s ...\n",linenumber,filename,errorstr) -- lua error?
texio.write_nl(tracers.showlines(filename,linenumber,offset,errorstr),"\n")
end
diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua
index 1ea257bc3..0dadb855e 100644
--- a/tex/context/base/trac-log.lua
+++ b/tex/context/base/trac-log.lua
@@ -6,60 +6,60 @@ if not modules then modules = { } end modules ['trac-log'] = {
license = "see context related readme files"
}
-if tex and (tex.jobname or tex.formatname) then
-
- -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2)
- -- still needed for luajittex
-
- local texio_write_nl = texio.write_nl
- local texio_write = texio.write
- local io_write = io.write
-
- local write_nl = function(target,...)
- if not io_write then
- io_write = io.write
- end
- if target == "term and log" then
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- elseif target == "log" then
- texio_write_nl("log",...)
- elseif target == "term" then
- texio_write_nl("term","")
- io_write(...)
- else
- texio_write_nl("log",...)
- texio_write_nl("term","")
- io_write(...)
- end
- end
-
- local write = function(target,...)
- if not io_write then
- io_write = io.write
- end
- if target == "term and log" then
- texio_write("log",...)
- io_write(...)
- elseif target == "log" then
- texio_write("log",...)
- elseif target == "term" then
- io_write(...)
- else
- texio_write("log",...)
- io_write(...)
- end
- end
-
- texio.write = write
- texio.write_nl = write_nl
-
-else
-
- -- texlua or just lua
-
-end
+-- if tex and (tex.jobname or tex.formatname) then
+--
+-- -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2)
+-- -- still needed for luajittex
+--
+-- local texio_write_nl = texio.write_nl
+-- local texio_write = texio.write
+-- local io_write = io.write
+--
+-- local write_nl = function(target,...)
+-- if not io_write then
+-- io_write = io.write
+-- end
+-- if target == "term and log" then
+-- texio_write_nl("log",...)
+-- texio_write_nl("term","")
+-- io_write(...)
+-- elseif target == "log" then
+-- texio_write_nl("log",...)
+-- elseif target == "term" then
+-- texio_write_nl("term","")
+-- io_write(...)
+-- else
+-- texio_write_nl("log",target,...)
+-- texio_write_nl("term","")
+-- io_write(target,...)
+-- end
+-- end
+--
+-- local write = function(target,...)
+-- if not io_write then
+-- io_write = io.write
+-- end
+-- if target == "term and log" then
+-- texio_write("log",...)
+-- io_write(...)
+-- elseif target == "log" then
+-- texio_write("log",...)
+-- elseif target == "term" then
+-- io_write(...)
+-- else
+-- texio_write("log",target,...)
+-- io_write(target,...)
+-- end
+-- end
+--
+-- texio.write = write
+-- texio.write_nl = write_nl
+--
+-- else
+--
+-- -- texlua or just lua
+--
+-- end
-- todo: less categories, more subcategories (e.g. nodes)
-- todo: split into basics and ctx specific
@@ -502,8 +502,10 @@ function logs.show()
report("logging","categories: %s, max category: %s, max subcategory: %s, max combined: %s",n,c,s,max)
end
-local delayed_reporters = { } setmetatableindex(delayed_reporters,function(t,k)
- local v = logs.reporter(k)
+local delayed_reporters = { }
+
+setmetatableindex(delayed_reporters,function(t,k)
+ local v = logs.reporter(k.name)
t[k] = v
return v
end)
diff --git a/tex/context/base/trac-set.lua b/tex/context/base/trac-set.lua
index 6f91e25f7..95fdc43b3 100644
--- a/tex/context/base/trac-set.lua
+++ b/tex/context/base/trac-set.lua
@@ -33,7 +33,7 @@ function setters.initialize(filename,name,values) -- filename only for diagnosti
local setter = data[name]
if setter then
frozen = true -- don't permitoverload
--- trace_initialize = true
+ -- trace_initialize = true
local data = setter.data
if data then
for key, newvalue in next, values do
diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua
index 1727bddca..88d2c886e 100644
--- a/tex/context/base/trac-vis.lua
+++ b/tex/context/base/trac-vis.lua
@@ -196,13 +196,10 @@ local function enable()
end
local function setvisual(n,a,what) -- this will become more efficient when we have the bit lib linked in
- if not a then
- a = 0
- end
if not n or n == "reset" then
return unsetvalue
elseif n == "makeup" then
- if a == 0 then
+ if not a or a == 0 or a == unsetvalue then
a = preset_makeup
else
a = setbit(a,preset_makeup)
@@ -211,7 +208,7 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha
-- end
end
elseif n == "boxes" then
- if a == 0 then
+ if not a or a == 0 or a == unsetvalue then
a = preset_boxes
else
a = setbit(a,preset_boxes)
@@ -222,7 +219,7 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha
elseif n == "all" then
if what == false then
return unsetvalue
- elseif a == 0 then
+ elseif not a or a == 0 or a == unsetvalue then
a = preset_all
else
a = setbit(a,preset_all)
@@ -232,26 +229,24 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha
end
else
local m = modes[n]
- if m then
- if a == unsetvalue then
- if what == false then
- return unsetvalue
- else
- -- a = setbit(0,m)
- a = m
- end
- elseif what == false then
- a = clearbit(a,m)
- elseif a == 0 then
- a = m
+ if not m then
+ -- go on
+ elseif a == unsetvalue then
+ if what == false then
+ return unsetvalue
else
- a = setbit(a,m)
+ -- a = setbit(0,m)
+ a = m
end
- elseif not a then
- return unsetvalue
+ elseif what == false then
+ a = clearbit(a,m)
+ elseif not a or a == 0 then
+ a = m
+ else
+ a = setbit(a,m)
end
end
- if a == unsetvalue or a == 0 then
+ if not a or a == 0 or a == unsetvalue then
return unsetvalue
elseif not enabled then -- must happen at runtime (as we don't store layers yet)
enable()
diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv
index 4990913d7..fbc6ad6c4 100644
--- a/tex/context/base/trac-vis.mkiv
+++ b/tex/context/base/trac-vis.mkiv
@@ -39,7 +39,13 @@
\newconstant\c_syst_visualizers_state
\newtoks \t_syst_visualizers_optimize
-\definesystemattribute[visual][public,global]
+\definesystemattribute[visual][public,global] % global ?
+
+% no, but can become an option:
+%
+% \appendtoks
+% \attribute\visualattribute\attributeunsetvalue
+% \to \everybeforepagebody
%D We only provide box visualizers as they can come in handy for testing
%D macros. In due time we will move some of the m-visual code here too.
diff --git a/tex/context/base/type-imp-latinmodern.mkiv b/tex/context/base/type-imp-latinmodern.mkiv
index f17f46e7d..b0e25e82c 100644
--- a/tex/context/base/type-imp-latinmodern.mkiv
+++ b/tex/context/base/type-imp-latinmodern.mkiv
@@ -168,10 +168,16 @@
\definefontsynonym [LMTypewriterVarWd-DarkOblique] [\s!file:lmmonoproplt10-boldoblique] [\s!features=\s!default]
\stoptypescript
+% \starttypescript [\s!math] [modern,latin-modern]
+% \loadfontgoodies[lm]
+% \definefontsynonym [LMMathRoman-Regular] [\v!file:latinmodern-math-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm]
+% \definefontsynonym [LMMathRoman-Bold] [\v!file:latinmodern-math-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm]
+% \stoptypescript
+
\starttypescript [\s!math] [modern,latin-modern]
\loadfontgoodies[lm]
- \definefontsynonym [LMMathRoman-Regular] [\v!file:latinmodern-math-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm]
- \definefontsynonym [LMMathRoman-Bold] [\v!file:latinmodern-math-regular.otf] [\s!features=\s!math\mathsizesuffix,\s!goodies=lm]
+ \definefontsynonym [LMMathRoman-Regular] [\v!file:latinmodern-math-regular.otf] [\s!features={\s!math\mathsizesuffix,lm-math},\s!goodies=lm]
+ \definefontsynonym [LMMathRoman-Bold] [\v!file:latinmodern-math-regular.otf] [\s!features={\s!math\mathsizesuffix,lm-math},\s!goodies=lm]
\stoptypescript
\starttypescript [modern-designsize-virtual]
diff --git a/tex/context/base/typo-cap.lua b/tex/context/base/typo-cap.lua
index 8f49580a4..fdbf2e353 100644
--- a/tex/context/base/typo-cap.lua
+++ b/tex/context/base/typo-cap.lua
@@ -29,6 +29,7 @@ local kerncodes = nodes.kerncodes
local glyph_code = nodecodes.glyph
local kern_code = nodecodes.kern
+local math_code = nodecodes.math
local kerning_code = kerncodes.kerning
local userskip_code = skipcodes.userskip
diff --git a/tex/context/base/typo-itc.lua b/tex/context/base/typo-itc.lua
index 73d841aa3..b39ea2f23 100644
--- a/tex/context/base/typo-itc.lua
+++ b/tex/context/base/typo-itc.lua
@@ -20,6 +20,7 @@ local glyph_code = nodecodes.glyph
local kern_code = nodecodes.kern
local glue_code = nodecodes.glue
local disc_code = nodecodes.disc
+local math_code = nodecodes.math
local tasks = nodes.tasks
diff --git a/tex/context/base/typo-krn.lua b/tex/context/base/typo-krn.lua
index cd50c205e..52c4c6521 100644
--- a/tex/context/base/typo-krn.lua
+++ b/tex/context/base/typo-krn.lua
@@ -40,6 +40,7 @@ local disc_code = nodecodes.disc
local glue_code = nodecodes.glue
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
+local math_code = nodecodes.math
local kerning_code = kerncodes.kerning
local userkern_code = kerncodes.userkern
diff --git a/tex/context/base/typo-spa.lua b/tex/context/base/typo-spa.lua
index 619b3eddd..5eba22889 100644
--- a/tex/context/base/typo-spa.lua
+++ b/tex/context/base/typo-spa.lua
@@ -31,6 +31,7 @@ local v_reset = interfaces.variables.reset
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
+local math_code = nodecodes.math
local somespace = nodes.somespace
local somepenalty = nodes.somepenalty
@@ -71,12 +72,14 @@ local function process(namespace,attribute,head)
-- head is always begin of par (whatsit), so we have at least two prev nodes
-- penalty followed by glue
while start do
- if start.id == glyph_code then
+ local id = start.id
+ if id == glyph_code then
local attr = start[attribute]
if attr and attr > 0 then
local data = mapping[attr]
if data then
- local map = data.characters[start.char]
+ local char = start.char
+ local map = data.characters[char]
start[attribute] = unsetvalue -- needed?
if map then
local left = map.left
@@ -86,31 +89,31 @@ local function process(namespace,attribute,head)
local prev = start.prev
if left and left ~= 0 and prev then
local ok = false
+ local prevprev = prev.prev
if alternative == 1 then
local somespace = somespace(prev,true)
if somespace then
- local prevprev = prev.prev
local somepenalty = somepenalty(prevprev,10000)
if somepenalty then
if trace_spacing then
- report_spacing("removing penalty and space before %C (left)",start.char)
+ report_spacing("removing penalty and space before %C (left)",char)
end
head = remove_node(head,prev,true)
head = remove_node(head,prevprev,true)
else
if trace_spacing then
- report_spacing("removing space before %C (left)",start.char)
+ report_spacing("removing space before %C (left)",char)
end
head = remove_node(head,prev,true)
end
end
ok = true
else
- ok = not (somespace(prev,true) and somepenalty(prev.prev,true)) or somespace(prev,true)
+ ok = not (somespace(prev,true) and somepenalty(prevprev,true)) or somespace(prev,true)
end
if ok then
if trace_spacing then
- report_spacing("inserting penalty and space before %C (left)",start.char)
+ report_spacing("inserting penalty and space before %C (left)",char)
end
insert_node_before(head,start,new_penalty(10000))
insert_node_before(head,start,new_glue(left*quad))
@@ -120,14 +123,14 @@ local function process(namespace,attribute,head)
local next = start.next
if right and right ~= 0 and next then
local ok = false
+ local nextnext = next.next
if alternative == 1 then
local somepenalty = somepenalty(next,10000)
if somepenalty then
- local nextnext = next.next
local somespace = somespace(nextnext,true)
if somespace then
if trace_spacing then
- report_spacing("removing penalty and space after %C right",start.char)
+ report_spacing("removing penalty and space after %C right",char)
end
head = remove_node(head,next,true)
head = remove_node(head,nextnext,true)
@@ -136,18 +139,18 @@ local function process(namespace,attribute,head)
local somespace = somespace(next,true)
if somespace then
if trace_spacing then
- report_spacing("removing space after %C (right)", start.char)
+ report_spacing("removing space after %C (right)", char)
end
head = remove_node(head,next,true)
end
end
ok = true
else
- ok = not (somepenalty(next,10000) and somespace(next.next,true)) or somespace(next,true)
+ ok = not (somepenalty(next,10000) and somespace(nextnext,true)) or somespace(next,true)
end
if ok then
if trace_spacing then
- report_spacing("inserting penalty and space after %C (right)",start.char)
+ report_spacing("inserting penalty and space after %C (right)",char)
end
insert_node_after(head,start,new_glue(right*quad))
insert_node_after(head,start,new_penalty(10000))
diff --git a/tex/context/base/typo-spa.mkiv b/tex/context/base/typo-spa.mkiv
index df2dab47c..d783353d6 100644
--- a/tex/context/base/typo-spa.mkiv
+++ b/tex/context/base/typo-spa.mkiv
@@ -22,6 +22,8 @@
% experimental spacing
%
% test: oeps {\setcharacterspacing[frenchpunctuation]x: xx \bfd x: xx} oeps: test
+%
+% todo: page | text => pagebody or text only
\installcorenamespace{characterspacing}
diff --git a/tex/context/base/util-lib.lua b/tex/context/base/util-lib.lua
index c987bdde3..fde1f987e 100644
--- a/tex/context/base/util-lib.lua
+++ b/tex/context/base/util-lib.lua
@@ -37,15 +37,15 @@ In swiglib we have chosen for a clear organization and although one can use
variants normally in the tex directory structure predictability is more or
less the standard. For instance:
-..../tex/texmf-mswin/bin/swiglib/gmwand
+.../tex/texmf-mswin/bin/lib/luatex/lua/swiglib/mysql/core.dll
+.../tex/texmf-mswin/bin/lib/luajittex/lua/swiglib/mysql/core.dll
+.../tex/texmf-mswin/bin/lib/luatex/context/lua/swiglib/mysql/core.dll
+.../tex/texmf-mswin/bin/lib/swiglib/lua/mysql/core.dll
+.../tex/texmf-mswin/bin/lib/swiglib/lua/mysql/5.6/core.dll
-]]--
-
-local savedrequire = require
-local loaded = package.loaded
-local gsub, find = string.gsub, string.find
+The lookups are determined via an entry in texmfcnf.lua:
---[[
+CLUAINPUTS = ".;$SELFAUTOLOC/lib/{$engine,luatex}/lua//",
A request for t.e.x is converted to t/e/x.dll or t/e/x.so depending on the
platform. Then we use the regular finder to locate the file in the tex
@@ -53,38 +53,123 @@ directory structure. Once located we goto the path where it sits, load the
file and return to the original path. We register as t.e.x in order to
prevent reloading and also because the base name is seldom unique.
+The main function is a big one and evolved out of experiments that Luigi
+Scarso and I conducted when playing with variants of SwigLib. The function
+locates the library using the context mkiv resolver that operates on the
+tds tree and if that doesn't work out well, the normal clib path is used.
+
+The lookups is somewhat clever in the sense that it can deal with (optional)
+versions and can fall back on non versioned alternatives if needed, either
+or not using a wildcard lookup.
+
+This code is experimental and by providing a special abstract loader (called
+swiglib) we can start using the libraries.
+
]]--
-local function requireswiglib(required)
+-- seems to be clua in recent texlive
+
+local gsub, find = string.gsub, string.find
+local pathpart, nameonly, joinfile = file.pathpart, file.nameonly, file.join
+local findfile, findfiles = resolvers and resolvers.findfile, resolvers and resolvers.findfiles
+
+local loaded = package.loaded
+
+local report_swiglib = logs.reporter("swiglib")
+local trace_swiglib = false trackers.register("resolvers.swiglib", function(v) trace_swiglib = v end)
+
+-- We can check if there are more that one component, and if not, we can
+-- append 'core'.
+
+local function requireswiglib(required,version)
local library = loaded[required]
- if not library then
- local name = gsub(required,"%.","/") .. "." .. os.libsuffix
- local full = resolvers.findfile(name,"lib")
- -- local full = resolvers.findfile(name)
- if not full or full == "" then
- -- We can consider alternatives but we cannot load yet ... I
- -- need to extent l-lua with a helper if we really want that.
- --
- -- package.helpers.trace = true
- -- package.extraclibpath(environment.ownpath)
+ if library == nil then
+ -- initialize a few variables
+ local required_full = gsub(required,"%.","/")
+ local required_path = pathpart(required_full)
+ local required_base = nameonly(required_full)
+ local required_name = required_base .. "." .. os.libsuffix
+ local version = type(version) == "string" and version ~= "" and version or false
+ -- helper
+ local function check(locate,...)
+ local found_library = nil
+ if version then
+ local asked_library = joinfile(required_path,version,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","with version",asked_library)
+ end
+ found_library = locate(asked_library,...)
+ if not found_library or found_library == ""then
+ asked_library = joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library = locate(asked_library,...)
+ end
+ else
+ local asked_library = joinfile(required_path,required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","without version",asked_library)
+ end
+ found_library = locate(asked_library,...)
+ end
+ return found_library and found_library ~= "" and found_library or false
+ end
+ -- check cnf spec using name and version
+ local found_library = findfile and check(findfile,"lib")
+ -- check cnf spec using wildcard
+ if findfiles and not found_library then
+ local asked_library = joinfile(required_path,".*",required_name)
+ if trace_swiglib then
+ report_swiglib("checking %s: %a","latest version",asked_library)
+ end
+ local list = findfiles(asked_library,"lib",true)
+ if list and #list > 0 then
+ table.sort(list)
+ found_library = list[#list]
+ end
+ end
+ -- check clib paths using name and version
+ if not found_library then
+ package.extraclibpath(environment.ownpath)
+ local paths = package.clibpaths()
+ for i=1,#paths do
+ local found_library = check(lfs.isfile)
+ if found_library then
+ break
+ end
+ end
end
- local path = file.pathpart(full)
- local base = file.nameonly(full)
- dir.push(path)
- -- if false then
- -- local savedlibrary = loaded[base]
- -- library = savedrequire(base)
- -- loaded[base] = savedlibrary
- -- else
- library = package.loadlib(full,"luaopen_" .. base)
+ -- load and initialize when found
+ if not found_library then
+ if trace_swiglib then
+ report_swiglib("not found: %a",asked_library)
+ end
+ library = false
+ else
+ local path = pathpart(found_library)
+ local base = nameonly(found_library)
+ dir.push(path)
+ if trace_swiglib then
+ report_swiglib("found: %a",found_library)
+ end
+ library = package.loadlib(found_library,"luaopen_" .. required_base)
if type(library) == "function" then
library = library()
else
- -- some error
+ library = false
end
- -- end
- dir.pop()
+ dir.pop()
+ end
+ -- cache result
+ if not library then
+ report_swiglib("unknown: %a",required)
+ elseif trace_swiglib then
+ report_swiglib("stored: %a",required)
+ end
loaded[required] = library
+ else
+ report_swiglib("reused: %a",required)
end
return library
end
@@ -96,31 +181,32 @@ we could put the specific loader in the global namespace.
]]--
-function require(name,...) -- this might disappear or change
+local savedrequire = require
+
+function require(name,version)
if find(name,"^swiglib%.") then
- return requireswiglib(name,...)
+ return requireswiglib(name,version)
else
- return savedrequire(name,...)
+ return savedrequire(name)
end
end
--[[
At the cost of some overhead we provide a specific loader so that we can keep
-track of swiglib usage which is handy for development.
+track of swiglib usage which is handy for development. In context this is the
+recommended loader.
]]--
-local report_swiglib = logs.reporter("swiglib")
-
local swiglibs = { }
-function swiglib(name)
+function swiglib(name,version)
local library = swiglibs[name]
if not library then
statistics.starttiming(swiglibs)
report_swiglib("loading %a",name)
- library = requireswiglib("swiglib." .. name)
+ library = requireswiglib("swiglib." .. name,version)
swiglibs[name] = library
statistics.stoptiming(swiglibs)
end
@@ -137,9 +223,10 @@ end)
So, we now have:
------ gm = requireswiglib("swiglib.gmwand.core") -- most bare method (not public in context)
-local gm = require("swiglib.gmwand.core") -- nicer integrated (maybe not in context)
-local gm = swiglib("gmwand.core") -- the context way
+local gm = require("swiglib.gmwand.core")
+local gm = swiglib("gmwand.core")
+local sq = swiglib("mysql.core")
+local sq = swiglib("mysql.core","5.6")
Watch out, the last one is less explicit and lacks the swiglib prefix.
diff --git a/tex/context/base/util-sql-imp-swiglib.lua b/tex/context/base/util-sql-imp-swiglib.lua
index 15fbe2487..9a22477a9 100644
--- a/tex/context/base/util-sql-imp-swiglib.lua
+++ b/tex/context/base/util-sql-imp-swiglib.lua
@@ -15,13 +15,20 @@ local concat = table.concat
local format = string.format
local lpegmatch = lpeg.match
local setmetatable, type = setmetatable, type
+local sleep = os.sleep
local trace_sql = false trackers.register("sql.trace", function(v) trace_sql = v end)
local trace_queries = false trackers.register("sql.queries",function(v) trace_queries = v end)
local report_state = logs.reporter("sql","swiglib")
local sql = utilities.sql
-local mysql = require("swigluamysql")
+local mysql = require("swiglib.mysql.core") -- "5.6"
+
+-- inspect(table.sortedkeys(mysql))
+
+local nofretries = 5
+local retrydelay = 1
+
local cache = { }
local helpers = sql.helpers
local methods = sql.methods
@@ -53,15 +60,28 @@ local mysql_options_argument = mysql.mysql_options_argument
local instance = mysql.MYSQL()
-local mysql_constant_false = mysql_options_argument(false) -- 0 "\0"
-local mysql_constant_true = mysql_options_argument(true) -- 1 "\1"
-
--- print(swig_type(mysql_constant_false))
--- print(swig_type(mysql_constant_true))
-
-mysql.mysql_options(instance,mysql.MYSQL_OPT_RECONNECT,mysql_constant_true);
+local mysql_constant_false = false
+local mysql_constant_true = true
+
+-- if mysql_options_argument then
+--
+-- mysql_constant_false = mysql_options_argument(false) -- 0 "\0"
+-- mysql_constant_true = mysql_options_argument(true) -- 1 "\1"
+--
+-- -- print(swig_type(mysql_constant_false))
+-- -- print(swig_type(mysql_constant_true))
+--
+-- mysql.mysql_options(instance,mysql.MYSQL_OPT_RECONNECT,mysql_constant_true);
+--
+-- else
+--
+-- print("")
+-- print("incomplete swiglib.mysql interface")
+-- print("")
+--
+-- end
-local typemap = {
+local typemap = mysql.MYSQL_TYPE_VAR_STRING and {
[mysql.MYSQL_TYPE_VAR_STRING ] = "string",
[mysql.MYSQL_TYPE_STRING ] = "string",
[mysql.MYSQL_TYPE_DECIMAL ] = "number",
@@ -272,6 +292,16 @@ local function connect(session,specification)
)
end
+local function error_in_connection(specification,action)
+ report_state("error in connection: [%s] %s@%s to %s:%s",
+ action or "unknown",
+ specification.database or "no database",
+ specification.username or "no username",
+ specification.host or "no host",
+ specification.port or "no port"
+ )
+end
+
local function datafetched(specification,query,converter)
if not query or query == "" then
report_state("no valid query")
@@ -288,11 +318,45 @@ local function datafetched(specification,query,converter)
if not connection then
session = initialize()
connection = connect(session,specification)
- cache[id] = { session = session, connection = connection }
+ if not connection then
+ for i=1,nofretries do
+ sleep(retrydelay)
+ report_state("retrying to connect: [%s.%s] %s@%s to %s:%s",
+ id,i,
+ specification.database or "no database",
+ specification.username or "no username",
+ specification.host or "no host",
+ specification.port or "no port"
+ )
+ connection = connect(session,specification)
+ if connection then
+ break
+ end
+ end
+ end
+ if connection then
+ cache[id] = { session = session, connection = connection }
+ end
end
else
session = initialize()
connection = connect(session,specification)
+ if not connection then
+ for i=1,nofretries do
+ sleep(retrydelay)
+ report_state("retrying to connect: [%s] %s@%s to %s:%s",
+ i,
+ specification.database or "no database",
+ specification.username or "no username",
+ specification.host or "no host",
+ specification.port or "no port"
+ )
+ connection = connect(session,specification)
+ if connection then
+ break
+ end
+ end
+ end
end
if not connection then
report_state("error in connection: %s@%s to %s:%s",
diff --git a/tex/context/base/x-steps.mkiv b/tex/context/base/x-steps.mkiv
new file mode 100644
index 000000000..29b3f7eaa
--- /dev/null
+++ b/tex/context/base/x-steps.mkiv
@@ -0,0 +1,102 @@
+%D \module
+%D [ file=m-steps,
+%D version=2001.05.28,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Step Charts \& Tables,
+%D author=Hans Hagen,
+%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.
+
+%D The \XML\ interface. This module can be made way more efficient
+%D in \MKIV\ using textext but it makes only sense to do this when
+%D I really need it in a demanding application. Probably half of the
+%D code in m-steps.tex can go.
+
+\usemodule[m][steps]
+
+\unprotect
+
+\installcorenamespace {xmlstepchart}
+\installcorenamespace {xmlsteptable}
+
+\def\xmlstepchartdirective#1{\executeifdefined{\??xmlstepchart#1}\gobbletwoarguments} % {#2}{#3}
+\def\xmlsteptabledirective#1{\executeifdefined{\??xmlsteptable#1}\gobbletwoarguments} % {#2}{#3}
+
+\setvalue{\??xmlstepchart charts}{\setsomevalue\@@STPC}
+\setvalue{\??xmlstepchart cells}{\setsomevalue\@@STEC}
+\setvalue{\??xmlstepchart texts}{\setsomevalue\@@STET}
+\setvalue{\??xmlstepchart lines}{\setsomevalue\@@STEL}
+
+\setvalue{\??xmlsteptable tables}{\setsomevalue\@@STPT}
+\setvalue{\??xmlsteptable cells}{\setsomevalue\@@STEC}
+\setvalue{\??xmlsteptable texts}{\setsomevalue\@@STET}
+\setvalue{\??xmlsteptable lines}{\setsomevalue\@@STEL}
+
+\startxmlsetups xml:ct:define
+ \xmlsetsetup {#1} {ct:*} {xml:ct:*}
+ % \xmlsetsetup {#1} {ct:stepaligntable/cells} {xml:ct:stepaligntable:cells}
+ % \xmlsetsetup {#1} {ct:stepaligntable/lines} {xml:ct:stepaligntable:lines}
+\stopxmlsetups
+
+\xmlregisterns{ct}{stepcharts}
+
+\xmlregistersetup{xml:ct:define}
+
+\startxmlsetups xml:ct:prep
+ \expanded{\prep[\xmltoparameters{#1}]}{\xmlflush{#1}}
+\stopxmlsetups
+
+\startxmlsetups xml:ct:text
+ \expanded{\text[\xmltoparameters{#1}]}{\xmlflush{#1}}
+\stopxmlsetups
+
+\startxmlsetups xml:ct:texts
+ \expanded{\texts[\xmltoparameters{#1}]}{\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
+\stopxmlsetups
+
+\startxmlsetups xml:ct:cell
+ \expanded{\cell[\xmltoparameters{#1}]}{\xmlflush{#1}}
+\stopxmlsetups
+
+\startxmlsetups xml:ct:cells
+ \expanded{\cells[\xmltoparameters{#1}]}{\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
+\stopxmlsetups
+
+\startxmlsetups xml:ct:lines
+ \expanded{\startlines[\xmltoparameters{#1}]}
+ \xmlflush{#1}
+ \stoplines
+\stopxmlsetups
+
+\startxmlsetups xml:ct:steptable
+ \expanded{\startSTEPtable[\xmltoparameters{#1}]}
+ \xmlflush{#1}
+ \stopSTEPtable
+\stopxmlsetups
+
+\startxmlsetups xml:ct:stepchart
+ \expanded{\startSTEPchart[\xmltoparameters{#1}]}
+ \xmlflush{#1}
+ \stopSTEPchart
+\stopxmlsetups
+
+% \startxmlsetups xml:ct:stepaligntable
+% \expanded{\startSTEPaligntable[\xmltoparameters{#1}]}
+% \xmlflush{#1}
+% \stopSTEPaligntable
+% \stopxmlsetups
+%
+% \startxmlsetups xml:ct:stepaligntable:cells
+% \expanded{\cells[\xmltoparameters{#1}]} {\xmltext{#1}{/ct:c1}} {\xmltext{#1}{/ct:c2}} {\xmltext{#1}{/ct:c3}}
+% \stopxmlsetups
+%
+% \startxmlsetups xml:ct:stepaligntable:lines
+% \expanded{\setupSTEPlines[\xmltoparameters{#1}]}
+% \xmlflush{#1}
+% \stopxmlsetups
+
+\protect \endinput
diff --git a/tex/context/fonts/lm.lfg b/tex/context/fonts/lm.lfg
index 5f78eddfd..792e723e8 100644
--- a/tex/context/fonts/lm.lfg
+++ b/tex/context/fonts/lm.lfg
@@ -13,6 +13,28 @@ return {
mathematics.tweaks.fixbadprime, -- prime is too low
},
},
+ dimensions = {
+ -- always applied
+-- default = {
+-- },
+ -- driven by 'mathdimensions' feature
+ signs = {
+ -- set dimensions
+ -- [0x00B1] = { -- ±
+ -- height = 500, depth = 0,
+ -- },
+ -- [0x2213] = { -- ∓
+ -- height = 500, depth = 0,
+ -- },
+ -- move in boundingbox
+ [0x00B1] = { -- ±
+ yoffset = 100,
+ },
+ [0x2213] = { -- ∓
+ yoffset = -100,
+ },
+ }
+ }
},
filenames = {
["latinmodern-math-regular.otf"] = {
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 820ea3852..d1b4bcda9 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 : 04/02/13 11:22:33
+-- merge date : 04/05/13 22:00:23
do -- begin closure to overcome local limits and interference
@@ -123,7 +123,7 @@ local function addpath(what,paths,extras,hash,...)
local path=cleanpath(path)
if not hash[path] then
if trace then
- report("! extra %s path: %s",what,path)
+ report("extra %s path: %s",what,path)
end
paths [#paths+1]=path
extras[#extras+1]=path
@@ -157,13 +157,13 @@ searchers[3]=nil
local function loadedaslib(resolved,rawname)
local init="luaopen_"..gsub(rawname,"%.","_")
if helpers.trace then
- helpers.report("! calling loadlib with '%s' with init '%s'",resolved,init)
+ helpers.report("calling loadlib with '%s' with init '%s'",resolved,init)
end
return package.loadlib(resolved,init)
end
local function loadedbylua(name)
if helpers.trace then
- helpers.report("! locating '%s' using normal loader",name)
+ helpers.report("locating '%s' using normal loader",name)
end
return true,searchers[-2](name)
end
@@ -171,17 +171,17 @@ local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
local report=helpers.report
if trace then
- report("! locating '%s' as '%s' on '%s' paths",rawname,name,what)
+ report("locating '%s' as '%s' on '%s' paths",rawname,name,what)
end
for p=1,#paths do
local path=paths[p]
local resolved=filejoin(path,name)
if trace then
- report("! checking for '%s' using '%s' path '%s'",name,what,path)
+ report("checking for '%s' using '%s' path '%s'",name,what,path)
end
if isreadable(resolved) then
if trace then
- report("! lib '%s' located on '%s'",name,resolved)
+ report("lib '%s' located on '%s'",name,resolved)
end
if islib then
return true,loadedaslib(resolved,rawname)
@@ -10704,6 +10704,19 @@ function definers.loadfont(specification)
end
return tfmdata
end
+local function checkvirtual(tfmdata)
+ local fonts=tfmdata.fonts
+ local selfid=font.nextid()
+ if fonts and #fonts>0 then
+ for i=1,#fonts do
+ if fonts[i][2]==0 then
+ fonts[i][2]=selfid
+ end
+ end
+ else
+ tfmdata.fonts={ "id",selfid }
+ end
+end
function constructors.readanddefine(name,size)
local specification=definers.analyze(name,size)
local method=specification.method
@@ -10716,7 +10729,7 @@ function constructors.readanddefine(name,size)
if not id then
local tfmdata=definers.loadfont(specification)
if tfmdata then
- tfmdata.properties.hash=hash
+ checkvirtual(tfmdata)
id=font.define(tfmdata)
definers.register(tfmdata,id)
else
diff --git a/tex/generic/context/luatex/luatex-swiglib-test.lua b/tex/generic/context/luatex/luatex-swiglib-test.lua
new file mode 100644
index 000000000..db6a72909
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib-test.lua
@@ -0,0 +1,25 @@
+local gm = swiglib("gmwand.core")
+
+gm.InitializeMagick(".")
+
+local magick_wand = gm.NewMagickWand()
+local drawing_wand = gm.NewDrawingWand()
+
+gm.MagickSetSize(magick_wand,800,600)
+gm.MagickReadImage(magick_wand,"xc:red")
+
+gm.DrawPushGraphicContext(drawing_wand)
+
+gm.DrawSetFillColor(drawing_wand,gm.NewPixelWand())
+
+-- gm.DrawSetFont(drawing_wand, kpse.findfile("DejaVuSerifBold.ttf"))
+-- gm.DrawSetFontSize(drawing_wand, 96)
+-- gm.DrawAnnotation(drawing_wand,300,200, "LuaTeX")
+
+gm.DrawPopGraphicContext(drawing_wand)
+gm.MagickDrawImage(magick_wand,drawing_wand)
+
+gm.MagickWriteImages(magick_wand,"./luatex-swiglib-test.jpg",1)
+
+gm.DestroyDrawingWand(drawing_wand)
+gm.DestroyMagickWand(magick_wand)
diff --git a/tex/generic/context/luatex/luatex-swiglib-test.tex b/tex/generic/context/luatex/luatex-swiglib-test.tex
new file mode 100644
index 000000000..d26bb6ffb
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib-test.tex
@@ -0,0 +1,11 @@
+% luatex --fmt=luatex=plain luatex-swiglib-test.tex
+
+\input luatex-swiglib.tex
+
+\directlua {
+ dofile("luatex-swiglib-test.lua")
+}
+
+\pdfximage {luatex-swiglib-test.jpg} \pdfrefximage\pdflastximage
+
+\end
diff --git a/tex/generic/context/luatex/luatex-swiglib.lua b/tex/generic/context/luatex/luatex-swiglib.lua
new file mode 100644
index 000000000..7ffcdc375
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib.lua
@@ -0,0 +1,62 @@
+if not modules then modules = { } end modules ['luatex-swiglib'] = {
+ version = 1.001,
+ comment = "companion to luatex-swiglib.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local savedrequire = require
+
+local libsuffix = os.type == "windows" and ".dll" or ".so"
+
+function requireswiglib(required,version)
+ local library = package.loaded[required]
+ if library then
+ return library
+ else
+ local name = string.gsub(required,"%.","/") .. libsuffix
+ local list = kpse.show_path("clua")
+ for root in string.gmatch(list,"([^;]+)") do
+ local full = false
+ if type(version) == "string" and version ~= "" then
+ full = root .. "/" .. version .. "/" .. name
+ full = lfs.isfile(full) and full
+ end
+ if not full then
+ full = root .. "/" .. name
+ full = lfs.isfile(full) and full
+ end
+ if full then
+ local path, base = string.match(full,"^(.-)([^\\/]+)" .. libsuffix .."$")
+ local savedlibrary = package.loaded[base]
+ package.loaded[base] = nil
+ local savedpath = lfs.currentdir()
+ lfs.chdir(path)
+ library = package.loadlib(full,"luaopen_" .. base)
+ if type(library) == "function" then
+ library = library()
+ texio.write("<swiglib: '",required,"' is loaded>")
+ end
+ lfs.chdir(savedpath)
+ package.loaded[base] = savedlibrary
+ package.loaded[required] = library
+ return library
+ end
+ end
+ texio.write("<swiglib: '",name,"'is not found on '",list,"'")
+ end
+ texio.write("<swiglib: '",required,"' is not found>")
+end
+
+function require(name)
+ if string.find(name,"^swiglib%.") then
+ return requireswiglib(name)
+ else
+ return savedrequire(name)
+ end
+end
+
+function swiglib(name,version)
+ return requireswiglib("swiglib." .. name,version)
+end
diff --git a/tex/generic/context/luatex/luatex-swiglib.tex b/tex/generic/context/luatex/luatex-swiglib.tex
new file mode 100644
index 000000000..7c4377515
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-swiglib.tex
@@ -0,0 +1,20 @@
+%D \module
+%D [ file=luatex-swiglib,
+%D version=2013.03.30,
+%D title=\LUATEX\ Support Macros,
+%D subtitle=Generic \SWIGLIB\ Font Handler,
+%D author=Hans Hagen,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+
+%D This is an experimental setup. Usage:
+%D
+%D \starttyping
+%D local gm = swiglib("gmwand.core")
+%D local gm = require("swiglib.gmwand.core")
+%D local sq = swiglib("mysql.core")
+%D local sq = swiglib("mysql.core","5.6")
+%D \stoptyping
+
+\directlua {
+ dofile(kpse.find_file("luatex-swiglib.lua","tex"))
+}
diff --git a/web2c/contextcnf.lua b/web2c/contextcnf.lua
index d08ecee1d..553d3a4ee 100644
--- a/web2c/contextcnf.lua
+++ b/web2c/contextcnf.lua
@@ -101,7 +101,7 @@ return {
PYTHONINPUTS = ".;$TEXMF/scripts/context/python",
RUBYINPUTS = ".;$TEXMF/scripts/context/ruby",
LUAINPUTS = ".;$TEXINPUTS;$TEXMF/scripts/context/lua//",
- CLUAINPUTS = ".;$SELFAUTOLOC/lib/{context,luatex,}/lua//",
+ CLUAINPUTS = ".;$SELFAUTOLOC/lib/{$engine,luatex}/lua//",
-- Not really used by MkIV so they might go away.