summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/char-ini.mkiv9
-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.pdfbin4126 -> 4123 bytes
-rw-r--r--tex/context/base/context-version.pngbin40103 -> 40213 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/data-lua.lua19
-rw-r--r--tex/context/base/l-lua.lua6
-rw-r--r--tex/context/base/l-table.lua15
-rw-r--r--tex/context/base/lang-ini.mkiv33
-rw-r--r--tex/context/base/mult-prm.lua1
-rw-r--r--tex/context/base/spac-ali.mkiv30
-rw-r--r--tex/context/base/status-files.pdfbin24746 -> 24788 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin208809 -> 208938 bytes
-rw-r--r--tex/context/base/trac-lmx.lua79
-rw-r--r--tex/context/base/util-prs.lua7
-rw-r--r--tex/context/base/util-sql-imp-client.lua13
-rw-r--r--tex/context/base/util-sql-imp-library.lua9
-rw-r--r--tex/context/base/util-sql-imp-swiglib.lua6
-rw-r--r--tex/context/base/util-sql.lua42
-rw-r--r--tex/context/base/util-tab.lua22
-rw-r--r--tex/context/base/util-tpl.lua5
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua16
24 files changed, 220 insertions, 100 deletions
diff --git a/tex/context/base/char-ini.mkiv b/tex/context/base/char-ini.mkiv
index d1d7574c9..a93a25f78 100644
--- a/tex/context/base/char-ini.mkiv
+++ b/tex/context/base/char-ini.mkiv
@@ -40,7 +40,14 @@
%
% impossible in math mode so there always fallback (till we have gyre):
-\def\utfchar #1{\ctxcommand{utfchar(\number#1)}}
+% When this primitive is on everyones system I will inline \Uchar a couple of times.
+
+\ifdefined\Uchar
+ \def\utfchar#1{\Uchar\numexpr#1\relax} % make sure that following spaces are kept
+\else
+ \def\utfchar#1{\ctxcommand{utfchar(\number#1)}}
+\fi
+
\def\checkedchar {\relax\ifmmode\expandafter\checkedmathchar\else\expandafter\checkedtextchar\fi} % #1#2
\def\checkedmathchar#1#2{#2}
\def\checkedtextchar #1{\iffontchar\font#1 \expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi{\char#1}}
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index beedc13a9..595673889 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2013.02.26 00:17}
+\newcontextversion{2013.03.04 18:28}
%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 c228612d4..d57ae6a48 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2013.02.26 00:17}
+\newcontextversion{2013.03.04 18:28}
%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 a35b04918..b1f6dc675 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 7749d44b5..d0dbca3ea 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 ae4d20491..d99c0fea8 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.02.26 00:17}
+\edef\contextversion{2013.03.04 18:28}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index a7a24eb0a..1be6780bf 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -25,7 +25,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.02.26 00:17}
+\edef\contextversion{2013.03.04 18:28}
%D For those who want to use this:
diff --git a/tex/context/base/data-lua.lua b/tex/context/base/data-lua.lua
index ab083d446..9e7e7b657 100644
--- a/tex/context/base/data-lua.lua
+++ b/tex/context/base/data-lua.lua
@@ -35,6 +35,14 @@ end
helpers.cleanpath = cleanpath
+local loadedaslib = helpers.loadedaslib
+local loadedbylua = helpers.loadedbylua
+local loadedbypath = helpers.loadedbypath
+local notloaded = helpers.notloaded
+
+local getlibpaths = package.libpaths
+local getclibpaths = package.clibpaths
+
function helpers.libpaths(libhash)
local libpaths = { }
for i=1,#libformats do
@@ -65,7 +73,7 @@ function helpers.clibpaths(clibhash)
return clibpaths
end
-function helpers.loadedbyformat(name,rawname,suffixes,islib)
+local function loadedbyformat(name,rawname,suffixes,islib)
local trace = helpers.trace
local report = helpers.report
if trace then
@@ -90,14 +98,7 @@ function helpers.loadedbyformat(name,rawname,suffixes,islib)
end
end
-local loadedaslib = helpers.loadedaslib
-local loadedbylua = helpers.loadedbylua
-local loadedbyformat = helpers.loadedbyformat
-local loadedbypath = helpers.loadedbypath
-local notloaded = helpers.notloaded
-
-local getlibpaths = package.libpaths
-local getclibpaths = package.clibpaths
+helpers.loadedbyformat = loadedbyformat
function helpers.loaded(name)
local thename = gsub(name,"%.","/")
diff --git a/tex/context/base/l-lua.lua b/tex/context/base/l-lua.lua
index 837f03d2a..5863960b3 100644
--- a/tex/context/base/l-lua.lua
+++ b/tex/context/base/l-lua.lua
@@ -203,7 +203,7 @@ package.libpaths = getlibpaths
package.clibpaths = getclibpaths
function package.extralibpath(...)
- local libpaths = getlibpaths()
+ libpaths = getlibpaths()
local pathlist = { ... }
local cleanpath = helpers.cleanpath
local trace = helpers.trace
@@ -214,7 +214,7 @@ function package.extralibpath(...)
local path = cleanpath(paths[i])
if not libhash[path] then
if trace then
- libraries("! extra lua path '%s'",path)
+ report("! extra lua path '%s'",path)
end
libextras[#libextras+1] = path
libpaths [#libpaths +1] = path
@@ -224,7 +224,7 @@ function package.extralibpath(...)
end
function package.extraclibpath(...)
- local clibpaths = getclibpaths()
+ clibpaths = getclibpaths()
local pathlist = { ... }
local cleanpath = helpers.cleanpath
local trace = helpers.trace
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index 8b09518cb..92ef02503 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -85,7 +85,7 @@ local function sortedkeys(tab)
end
end
-local function sortedhashkeys(tab) -- fast one
+local function sortedhashkeys(tab,cmp) -- fast one
if tab then
local srt, s = { }, 0
for key,_ in next, tab do
@@ -94,7 +94,7 @@ local function sortedhashkeys(tab) -- fast one
srt[s] = key
end
end
- sort(srt)
+ sort(srt,cmp)
return srt
else
return { }
@@ -116,9 +116,16 @@ table.sortedhashkeys = sortedhashkeys
local function nothing() end
-local function sortedhash(t)
+local function sortedhash(t,cmp)
if t then
- local n, s = 0, sortedkeys(t) -- the robust one
+ local s
+ if cmp then
+ -- it would be nice if teh sort function would accept a third argument (or nicer, an optional first)
+ s = sortedhashkeys(t,function(a,b) return cmp(t,a,b) end)
+ else
+ s = sortedkeys(t) -- the robust one
+ end
+ local n = 0
local function kv(s)
n = n + 1
local k = s[n]
diff --git a/tex/context/base/lang-ini.mkiv b/tex/context/base/lang-ini.mkiv
index 0b155cc74..3bd7072e6 100644
--- a/tex/context/base/lang-ini.mkiv
+++ b/tex/context/base/lang-ini.mkiv
@@ -361,13 +361,40 @@
)}\relax
\the\everylanguage\relax}
-\appendtoks
- % these values are stored along with glyph nodes
+\newcount\hyphenminoffset
+
+\unexpanded\def\lesshyphens
+ {\advance\hyphenminoffset\plusone
+ \lang_basics_synchronize_min_max}
+
+\unexpanded\def\morehyphens
+ {\ifcase\hyphenminoffset \else
+ \advance\hyphenminoffset\minusone
+ \fi
+ \lang_basics_synchronize_min_max}
+
+\unexpanded\def\nohyphens % % % % % not clever, we still hyphenate but supress application
+ {\ifx\dohyphens\relax
+ \unexpanded\edef\dohyphens
+ {\hyphenpenalty \the\hyphenpenalty
+ \exhyphenpenalty\the\exhyphenpenalty
+ \relax}%
+ \fi
+ \hyphenpenalty \plustenthousand
+ \exhyphenpenalty\plustenthousand}
+
+\let\dohyphens\relax
+
+\unexpanded\def\lang_basics_synchronize_min_max
+ { % these values are stored along with glyph nodes
\lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin +\hyphenminoffset\relax
\righthyphenmin\numexpr0\languageparameter\s!righthyphenmin+\hyphenminoffset\relax
% these values are stored with the language (global!)
\prehyphenchar \languageparameter\s!righthyphenchar\relax
- \posthyphenchar\languageparameter\s!lefthyphenchar \relax
+ \posthyphenchar\languageparameter\s!lefthyphenchar \relax}
+
+\appendtoks
+ \lang_basics_synchronize_min_max
\to \everylanguage
% \appendtoks
diff --git a/tex/context/base/mult-prm.lua b/tex/context/base/mult-prm.lua
index e1ff6803f..e6fa4abcc 100644
--- a/tex/context/base/mult-prm.lua
+++ b/tex/context/base/mult-prm.lua
@@ -78,6 +78,7 @@ return {
"widowpenalties",
},
["luatex"]={
+ "Uchar",
"Udelcode",
"Udelcodenum",
"Udelimiter",
diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv
index 84f941657..376916fa5 100644
--- a/tex/context/base/spac-ali.mkiv
+++ b/tex/context/base/spac-ali.mkiv
@@ -151,32 +151,10 @@
% Tolerance and hyphenation
-\newcount\hyphenminoffset
-
-\ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi
-
-\unexpanded\def\lesshyphens
- {\advance\hyphenminoffset\plusone
- \sethyphenationvariables}
-
-\unexpanded\def\morehyphens
- {\ifcase\hyphenminoffset \else
- \advance\hyphenminoffset\minusone
- \fi
- \sethyphenationvariables}
-
-
-\unexpanded\def\nohyphens % % % % % not clever, we still hyphenate but supress application
- {\ifx\dohyphens\relax
- \edef\dohyphens
- {\hyphenpenalty \the\hyphenpenalty
- \exhyphenpenalty\the\exhyphenpenalty
- \relax}%
- \fi
- \hyphenpenalty\plustenthousand
- \exhyphenpenalty\plustenthousand}
-
-\let\dohyphens\relax
+\ifdefined\lesshyphens \else \let\lesshyphens\relax \fi
+\ifdefined\morehyphens \else \let\morehyphens\relax \fi
+\ifdefined\nohyphens \else \let\nohyphens \relax \fi
+\ifdefined\dohyphens \else \let\dohyphens \relax \fi
\newconstant\c_spac_tolerance_default \c_spac_tolerance_default 1500 % shouldn't that be 200
\newconstant\c_spac_tolerance_minimum \c_spac_tolerance_minimum 1500
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 64a2f340a..414724f9e 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 096e0d6c0..4eeba1cd7 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/trac-lmx.lua b/tex/context/base/trac-lmx.lua
index 501e7ec42..ea0ac6c53 100644
--- a/tex/context/base/trac-lmx.lua
+++ b/tex/context/base/trac-lmx.lua
@@ -11,6 +11,7 @@ if not modules then modules = { } end modules ['trac-lmx'] = {
local type, tostring, rawget, loadstring, pcall = type, tostring, rawget, loadstring, pcall
local format, sub, gsub = string.format, string.sub, string.gsub
local concat = table.concat
+local collapsespaces = string.collapsespaces
local P, Cc, Cs, C, Carg, lpegmatch = lpeg.P, lpeg.Cc, lpeg.Cs, lpeg.C, lpeg.Carg, lpeg.match
local joinpath, replacesuffix, pathpart = file.join, file.replacesuffix, file.pathpart
@@ -170,9 +171,9 @@ local function do_variable(str)
-- nothing
elseif type(value) == "string" then
if #value > 80 then
- report_lmx("variable %q => %s ...",str,string.collapsespaces(sub(value,1,80)))
+ report_lmx("variable %q => %s ...",str,collapsespaces(sub(value,1,80)))
else
- report_lmx("variable %q => %s",str,string.collapsespaces(value))
+ report_lmx("variable %q => %s",str,collapsespaces(value))
end
elseif type(value) == "nil" then
report_lmx("variable %q => <!-- unset -->",str)
@@ -198,6 +199,12 @@ local function do_fprint(str,...)
end
end
+local function do_eprint(str,...)
+ if str and str ~= "" then
+ result[#result+1] = lpegmatch(pattern,format(str,...))
+ end
+end
+
local function do_print_variable(str)
local str = do_variable(str) -- variables[str]
if str and str ~= "" then
@@ -242,6 +249,7 @@ lmx.include = do_include
lmx.inject = do_print
lmx.finject = do_fprint
+lmx.einject = do_eprint
lmx.pv = do_print_variable
lmx.tv = do_type_variable
@@ -311,20 +319,54 @@ end
-- Creation: (todo: strip <!-- -->)
-local template = [[
-return function(defaults,variables)
-
--- initialize
-
-lmx.initialize(defaults,variables)
+-- local template = [[
+-- return function(defaults,variables)
+--
+-- -- initialize
+--
+-- lmx.initialize(defaults,variables)
+--
+-- -- interface
+--
+-- local definitions = { }
+-- local variables = lmx.getvariables()
+-- local html = lmx.html
+-- local inject = lmx.print
+-- local finject = lmx.fprint
+-- local einject = lmx.eprint
+-- local escape = lmx.escape
+-- local verbose = lmx.type
+--
+-- -- shortcuts (sort of obsolete as there is no gain)
+--
+-- local p = lmx.print
+-- local f = lmx.fprint
+-- local v = lmx.variable
+-- local e = lmx.escape
+-- local t = lmx.type
+-- local pv = lmx.pv
+-- local tv = lmx.tv
+--
+-- -- generator
+--
+-- %s
+--
+-- -- finalize
+--
+-- return lmx.finalized()
+--
+-- end
+-- ]]
+local template = [[
-- interface
-local definitions = { }
-local variables = lmx.getvariables()
local html = lmx.html
local inject = lmx.print
-local finject = lmx.fprint
+local finject = lmx.fprint -- better use the following
+local einject = lmx.eprint -- better use the following
+local injectf = lmx.fprint
+local injecte = lmx.eprint
local escape = lmx.escape
local verbose = lmx.type
@@ -338,13 +380,22 @@ local t = lmx.type
local pv = lmx.pv
local tv = lmx.tv
+local lmx_initialize = lmx.initialize
+local lmx_finalized = lmx.finalized
+local lmx_getvariables = lmx.getvariables
+
-- generator
-%s
+return function(defaults,variables)
+
+ lmx_initialize(defaults,variables)
+
+ local definitions = { }
+ local variables = lmx_getvariables()
--- finalize
+ %s -- the action: appends to result
-return lmx.finalized()
+ return lmx_finalized()
end
]]
diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua
index ab766d75a..41b1cb316 100644
--- a/tex/context/base/util-prs.lua
+++ b/tex/context/base/util-prs.lua
@@ -467,12 +467,13 @@ end
--
-local pattern = Cs((P("%")/"\\percent " + P("^") * Cc("{") * lpegpatterns.integer * Cc("}") + P(1))^0)
+local pattern_math = Cs((P("%")/"\\percent " + P("^") * Cc("{") * lpegpatterns.integer * Cc("}") + P(1))^0)
+local pattern_text = Cs((P("%")/"\\percent " + (P("^")/"\\high") * Cc("{") * lpegpatterns.integer * Cc("}") + P(1))^0)
patterns.unittotex = pattern
-function parsers.unittotex(str)
- return lpegmatch(pattern,str)
+function parsers.unittotex(str,textmode)
+ return lpegmatch(textmode and pattern_text or pattern_math,str)
end
local pattern = Cs((P("^") / "<sup>" * lpegpatterns.integer * Cc("</sup>") + P(1))^0)
diff --git a/tex/context/base/util-sql-imp-client.lua b/tex/context/base/util-sql-imp-client.lua
index d660a4a58..8a25c405d 100644
--- a/tex/context/base/util-sql-imp-client.lua
+++ b/tex/context/base/util-sql-imp-client.lua
@@ -166,12 +166,12 @@ local function dataconverted(data,converter)
if converter then
local data = getdata(data)
if data then
- converter.client(data)
+ data = converter.client(data)
end
return data
elseif trace_sql then
local t = osclock()
- local data, keys = splitdata(data)
+ local data, keys = splitdata(data,target)
report_state("converttime: %.3f",osclock()-t)
report_state("keys: %s ",#keys)
report_state("entries: %s ",#data)
@@ -206,7 +206,7 @@ local function execute(specification)
end
local data, keys = dataconverted(data,specification.converter)
if not data then
- report_state("error in converting")
+ report_state("error in converting or no data")
return
end
local one = data[1]
@@ -220,6 +220,8 @@ end
-- the lib anyway. Of course we could make a dedicated converter and/or
-- hook into the splitter code but ... it makes not much sense because then
-- we can as well move the builder to the library modules.
+--
+-- Here we reuse data as the indexes are the same, unless we hash.
local wraptemplate = [[
local converters = utilities.sql.converters
@@ -232,13 +234,14 @@ local booleanstring = string.booleanstring
%s
return function(data)
+ local target = %s -- data or { }
for i=1,#data do
local cells = data[i]
- data[%s] = {
+ target[%s] = {
%s
}
end
- return data
+ return target
end
]]
diff --git a/tex/context/base/util-sql-imp-library.lua b/tex/context/base/util-sql-imp-library.lua
index a9983cbca..5de3670e5 100644
--- a/tex/context/base/util-sql-imp-library.lua
+++ b/tex/context/base/util-sql-imp-library.lua
@@ -244,6 +244,9 @@ local function execute(specification)
return data, keys
end
+-- Here we build the dataset stepwise so we don't use the data hack that
+-- is used in the client variant.
+
local wraptemplate = [[
local converters = utilities.sql.converters
local deserialize = utilities.sql.deserialize
@@ -262,14 +265,14 @@ return function(result)
if nofrows == 0 then
return { }
end
- local data = { }
+ local target = { } -- no %s needed here
for i=1,nofrows do
local cells = { result:fetch() }
- data[%s] = {
+ target[%s] = {
%s
}
end
- return data
+ return target
end
]]
diff --git a/tex/context/base/util-sql-imp-swiglib.lua b/tex/context/base/util-sql-imp-swiglib.lua
index d681ace13..15fbe2487 100644
--- a/tex/context/base/util-sql-imp-swiglib.lua
+++ b/tex/context/base/util-sql-imp-swiglib.lua
@@ -399,18 +399,18 @@ return function(result)
return { }
end
local noffields = result.noffields or 0
- local data = { }
+ local target = { } -- no %s needed here
result = result._result_
for i=1,nofrows do
-- local row = mysql_fetch_row(result)
-- local len = mysql_fetch_lengths(result)
-- local cells = util_unpackbytearray(row,noffields,len)
local cells = util_mysql_fetch_fields_from_current_row(result)
- data[%s] = {
+ target[%s] = {
%s
}
end
- return data
+ return target
end
]]
diff --git a/tex/context/base/util-sql.lua b/tex/context/base/util-sql.lua
index 42bf3dc88..b793a3ae3 100644
--- a/tex/context/base/util-sql.lua
+++ b/tex/context/base/util-sql.lua
@@ -64,13 +64,14 @@ local rawset, setmetatable, getmetatable, load, type = rawset, setmetatable, get
local P, S, V, C, Cs, Ct, Cc, Cg, Cf, patterns, lpegmatch = lpeg.P, lpeg.S, lpeg.V, lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.Cc, lpeg.Cg, lpeg.Cf, lpeg.patterns, lpeg.match
local concat = table.concat
-local osuuid = os.uuid
-local osclock = os.clock or os.time
-local ostime = os.time
+local osuuid = os.uuid
+local osclock = os.clock or os.time
+local ostime = os.time
+local setmetatableindex = table.setmetatableindex
-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")
+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")
-- trace_sql = true
-- trace_queries = true
@@ -110,7 +111,7 @@ local defaults = { __index =
},
}
-table.setmetatableindex(sql.methods,function(t,k)
+setmetatableindex(sql.methods,function(t,k)
report_state("start loading method %q",k)
require("util-sql-imp-"..k)
report_state("loading method %q done",k)
@@ -132,28 +133,37 @@ local function makeconverter(entries,celltemplate,wraptemplate)
local kind = entry.type or entry.kind
local value = format(celltemplate,i,i)
if kind == "boolean" then
- assignments[i] = format("[%q] = booleanstring(%s),",name,value)
+ assignments[#assignments+1] = format("[%q] = booleanstring(%s),",name,value)
elseif kind == "number" then
- assignments[i] = format("[%q] = tonumber(%s),",name,value)
+ assignments[#assignments+1] = format("[%q] = tonumber(%s),",name,value)
elseif type(kind) == "function" then
local c = #converters + 1
converters[c] = kind
shortcuts[#shortcuts+1] = format("local fun_%s = converters[%s]",c,c)
- assignments[i] = format("[%q] = fun_%s(%s),",name,c,value)
+ assignments[#assignments+1] = format("[%q] = fun_%s(%s),",name,c,value)
elseif type(kind) == "table" then
local c = #converters + 1
converters[c] = kind
shortcuts[#shortcuts+1] = format("local tab_%s = converters[%s]",c,c)
- assignments[i] = format("[%q] = tab_%s[%s],",name,#converters,value)
+ assignments[#assignments+1] = format("[%q] = tab_%s[%s],",name,#converters,value)
elseif kind == "deserialize" then
- assignments[i] = format("[%q] = deserialize(%s),",name,value)
+ assignments[#assignments+1] = format("[%q] = deserialize(%s),",name,value)
elseif kind == "key" then
- key = value -- hashed instead of indexed
+ -- hashed instead of indexed
+ key = value
+ elseif kind == "entry" then
+ -- so we can (efficiently) extend the hashed table
+ local default = entry.default or ""
+ if type(default) == "string" then
+ assignments[#assignments+1] = format("[%q] = %q,",name,default)
+ else
+ assignments[#assignments+1] = format("[%q] = %s,",name,tostring(default))
+ end
else
- assignments[i] = format("[%q] = %s,",name,value)
+ assignments[#assignments+1] = format("[%q] = %s,",name,value)
end
end
- local code = format(wraptemplate,concat(shortcuts,"\n"),key or "i",concat(assignments,"\n "))
+ local code = format(wraptemplate,concat(shortcuts,"\n"),key and "{ }" or "data",key or "i",concat(assignments,"\n "))
-- print(code)
local func = load(code)
return func and func()
@@ -168,7 +178,7 @@ function sql.makeconverter(entries)
local converter = {
fields = fields
}
- table.setmetatableindex(converter, function(t,k)
+ setmetatableindex(converter, function(t,k)
local sqlmethod = methods[k]
local v = makeconverter(entries,sqlmethod.celltemplate,sqlmethod.wraptemplate)
t[k] = v
diff --git a/tex/context/base/util-tab.lua b/tex/context/base/util-tab.lua
index 47e533fa4..539d70d1b 100644
--- a/tex/context/base/util-tab.lua
+++ b/tex/context/base/util-tab.lua
@@ -372,3 +372,25 @@ function table.autokey(t,k)
t[k] = v
return v
end
+
+local selfmapper = { __index = function(t,k) t[k] = k return k end }
+
+function table.twowaymapper(t)
+ if not t then
+ t = { }
+ else
+ for i=0,#t do
+ local ti = t[i] -- t[1] = "one"
+ if ti then
+ local i = tostring(i)
+ t[i] = ti -- t["1"] = "one"
+ t[ti] = i -- t["one"] = "1"
+ end
+ end
+ t[""] = t[0] or ""
+ end
+ -- setmetatableindex(t,"key")
+ setmetatable(t,selfmapper)
+ return t
+end
+
diff --git a/tex/context/base/util-tpl.lua b/tex/context/base/util-tpl.lua
index 5775a4e92..31b2ae1f1 100644
--- a/tex/context/base/util-tpl.lua
+++ b/tex/context/base/util-tpl.lua
@@ -16,6 +16,7 @@ local templates = utilities.templates
local trace_template = false trackers.register("templates.trace",function(v) trace_template = v end)
local report_template = logs.reporter("template")
+local tostring = tostring
local format = string.format
local P, C, Cs, Carg, lpegmatch = lpeg.P, lpeg.C, lpeg.Cs, lpeg.Carg, lpeg.match
@@ -31,6 +32,7 @@ local function replacekey(k,t,recursive)
end
return ""
else
+ v = tostring(v)
if trace_template then
report_template("setting key %q to value %q",k,v)
end
@@ -84,7 +86,7 @@ local any = P(1)
replacer = Cs((unquoted + escape + key + any)^0)
local function replace(str,mapping,how,recurse)
- if mapping then
+ if mapping and str then
return lpegmatch(replacer,str,1,mapping,how or "lua",recurse or false) or str
else
return str
@@ -92,6 +94,7 @@ local function replace(str,mapping,how,recurse)
end
-- print(replace("test '%[x]%' test",{ x = [[a 'x'  a]] }))
+-- print(replace("test '%[x]%' test",{ x = true }))
-- print(replace("test '%[x]%' test",{ x = [[a 'x'  a]] },'sql'))
templates.replace = replace
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 4d843bd44..fe68795ec 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 02/26/13 00:17:03
+-- merge date : 03/04/13 18:28:23
do -- begin closure to overcome local limits and interference
@@ -755,7 +755,7 @@ local function sortedkeys(tab)
return {}
end
end
-local function sortedhashkeys(tab)
+local function sortedhashkeys(tab,cmp)
if tab then
local srt,s={},0
for key,_ in next,tab do
@@ -764,7 +764,7 @@ local function sortedhashkeys(tab)
srt[s]=key
end
end
- sort(srt)
+ sort(srt,cmp)
return srt
else
return {}
@@ -782,9 +782,15 @@ end
table.sortedkeys=sortedkeys
table.sortedhashkeys=sortedhashkeys
local function nothing() end
-local function sortedhash(t)
+local function sortedhash(t,cmp)
if t then
- local n,s=0,sortedkeys(t)
+ local s
+ if cmp then
+ s=sortedhashkeys(t,function(a,b) return cmp(t,a,b) end)
+ else
+ s=sortedkeys(t)
+ end
+ local n=0
local function kv(s)
n=n+1
local k=s[n]