summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context/data/scite/lexers/scite-context-lexer-tex.lua1
-rw-r--r--metapost/context/base/mp-chem.mpiv71
-rw-r--r--scripts/context/lua/mtx-context.lua62
-rw-r--r--scripts/context/lua/mtxrun.lua181
-rw-r--r--scripts/context/stubs/mswin/mtxrun.dllbin9216 -> 38400 bytes
-rw-r--r--scripts/context/stubs/mswin/mtxrun.exebin6144 -> 34816 bytes
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua181
-rw-r--r--scripts/context/stubs/unix/mtxrun181
-rw-r--r--tex/context/base/chem-str.lua185
-rw-r--r--tex/context/base/chem-str.mkiv20
-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.pdfbin4130 -> 4136 bytes
-rw-r--r--tex/context/base/context-version.pngbin39550 -> 39897 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv14
-rw-r--r--tex/context/base/data-lua.lua42
-rw-r--r--tex/context/base/data-res.lua15
-rw-r--r--tex/context/base/font-def.lua4
-rw-r--r--tex/context/base/font-hsh.lua4
-rw-r--r--tex/context/base/l-dir.lua14
-rw-r--r--tex/context/base/l-lua.lua156
-rw-r--r--tex/context/base/luat-env.lua8
-rw-r--r--tex/context/base/luat-lib.mkiv1
-rw-r--r--tex/context/base/math-map.lua4
-rw-r--r--tex/context/base/mult-ini.mkiv2
-rw-r--r--tex/context/base/s-inf-01.mkvi15
-rw-r--r--tex/context/base/status-files.pdfbin24772 -> 24738 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin211357 -> 211513 bytes
-rw-r--r--tex/context/base/status-mkiv.lua6
-rw-r--r--tex/context/base/strc-con.mkvi16
-rw-r--r--tex/context/base/strc-not.mkvi2
-rw-r--r--tex/context/base/trac-deb.lua3
-rw-r--r--tex/context/base/trac-tex.lua1
-rw-r--r--tex/context/base/util-lib.lua146
-rw-r--r--tex/context/base/util-sto.lua11
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua90
-rw-r--r--tex/generic/context/luatex/luatex-languages.lua2
38 files changed, 954 insertions, 490 deletions
diff --git a/context/data/scite/lexers/scite-context-lexer-tex.lua b/context/data/scite/lexers/scite-context-lexer-tex.lua
index 89ca4917a..c9dbc9f47 100644
--- a/context/data/scite/lexers/scite-context-lexer-tex.lua
+++ b/context/data/scite/lexers/scite-context-lexer-tex.lua
@@ -395,6 +395,7 @@ local inlinelua = P("\\") * (
P("ctx") * ( P("lua") + P("command") + P("late") * (P("lua") + P("command")) )
+ P("cld") * ( P("command") + P("context") )
+ P("luaexpr")
+ + (P("direct") + P("late")) * P("lua")
)
local startlua = P("\\start") * Cmt(luaenvironment,startdisplaylua)
diff --git a/metapost/context/base/mp-chem.mpiv b/metapost/context/base/mp-chem.mpiv
index c3dd3e3eb..a8f7d9381 100644
--- a/metapost/context/base/mp-chem.mpiv
+++ b/metapost/context/base/mp-chem.mpiv
@@ -302,30 +302,29 @@ chem_init_all ; % WHY does this not work unless defined and then called?
% unless of course the error be too harmful...
% \startchemical
-def chem_start_structure(expr i, l, r, t, b, scale, rotation, %fitwidth, fitheight,
- emwidth, offset, axis, rulethickness, axiscolor) =
- chem_emwidth := emwidth ; % EmWidth or \the\emwidth does not work...
- chem_b_length := if scale<>0: scale* fi 3chem_emwidth ;
+def chem_start_structure(expr i, l, r, t, b, rotation, unit, factor, offset, axis, rulethickness, axiscolor) =
save chem_setting_l, chem_setting_r, chem_setting_t, chem_setting_b ;
+
+ chem_emwidth := unit ;
+ chem_b_length := factor * unit ;
if numeric l :
- chem_setting_l := -l * chem_b_length ;
+ chem_setting_l := -l ;
fi
if numeric r :
- chem_setting_r := r * chem_b_length ;
+ chem_setting_r := r ;
fi
if numeric t :
- chem_setting_t := t * chem_b_length ;
+ chem_setting_t := t ;
fi
if numeric b :
- chem_setting_b := -b * chem_b_length ;
+ chem_setting_b := -b ;
fi
chem_setting_rotation := rotation ;
chem_setting_offset := offset ;
chem_setting_axis := if boolean axis : axis else : (axis<>0) fi ;
chem_axis_rulethickness := .75*(rulethickness) ; % axis 50% thinner than frame and bonds.
- % We store the following as a picture in order to allow ALL color models...
- chem_axis_color := image(draw origin withcolor axiscolor) ; % \MPcolor{axiscolor}) ;
+ chem_axis_color := image(draw origin withcolor axiscolor) ; % so we handle all color models
chem_reset ;
enddef ;
@@ -341,60 +340,46 @@ vardef chem_stop_structure =
currentpicture := (currentpicture shifted -chem_origin) rotated chem_setting_rotation ;
-% if not known chem_setting_l :
-% chem_setting_l := min(xpart ulcorner currentpicture, xpart llcorner currentpicture) ;
-% fi
-% if not known chem_setting_r :
-% chem_setting_r := max(xpart urcorner currentpicture, xpart lrcorner currentpicture) ;
-% fi
-% if not known chem_setting_b :
-% chem_setting_b := min(ypart llcorner currentpicture, ypart lrcorner currentpicture) ;
-% fi
-% if not known chem_setting_t :
-% chem_setting_t := max(ypart ulcorner currentpicture, ypart urcorner currentpicture) ;
-% fi
-
- if not known chem_setting_l :
- chem_setting_l := min(xpart llcorner currentpicture, xpart lrcorner currentpicture) ;
- fi
- if not known chem_setting_r :
- chem_setting_r := max(xpart llcorner currentpicture, xpart lrcorner currentpicture) ;
- fi
- if not known chem_setting_b :
- chem_setting_b := min(ypart llcorner currentpicture, ypart ulcorner currentpicture) ;
- fi
- if not known chem_setting_t :
- chem_setting_t := max(ypart llcorner currentpicture, ypart ulcorner currentpicture) ;
- fi
+ save l, r, b, t ;
+ l := min(xpart llcorner currentpicture, xpart lrcorner currentpicture) ;
+ r := max(xpart llcorner currentpicture, xpart lrcorner currentpicture) ;
+ b := min(ypart llcorner currentpicture, ypart ulcorner currentpicture) ;
+ t := max(ypart llcorner currentpicture, ypart ulcorner currentpicture) ;
+
+ if unknown chem_setting_l : chem_setting_l := l ; fi
+ if unknown chem_setting_r : chem_setting_r := r ; fi
+ if unknown chem_setting_b : chem_setting_b := b ; fi
+ if unknown chem_setting_t : chem_setting_t := t ; fi
-% draw textext(decimal chem_setting_l & "," & decimal chem_setting_r & " " &
-% decimal chem_setting_b & "," & decimal chem_setting_t) ;
if chem_setting_axis : % put it behind the picture
chem_pic := currentpicture ; currentpicture := nullpicture ;
chem_num0 := .5chem_b_length ;
chem_num1 := .2chem_num0 ;
- draw (-chem_setting_l,0) -- (chem_setting_r,0)
+ % draw the axes to the bounding box of the entire structure,
+ % not necessarily the bounding box of the final figure
+ draw (l,0) -- (r,0)
withpen pencircle scaled chem_axis_rulethickness withcolor colorpart(chem_axis_color) ;
- draw (0,-chem_setting_b) -- (0,chem_setting_t)
+ draw (0,b) -- (0,t)
withpen pencircle scaled chem_axis_rulethickness withcolor colorpart(chem_axis_color) ;
- for i = 0 step chem_num0 until chem_setting_r :
+ for i = 0 step chem_num0 until r :
draw (i,-chem_num1) -- (i,chem_num1)
withpen pencircle scaled chem_axis_rulethickness withcolor colorpart(chem_axis_color) ;
endfor
- for i = 0 step -chem_num0 until -chem_setting_l :
+ for i = 0 step -chem_num0 until l :
draw (i,-chem_num1) -- (i,chem_num1)
withpen pencircle scaled chem_axis_rulethickness withcolor colorpart(chem_axis_color) ;
endfor
- for i = 0 step chem_num0 until chem_setting_t :
+ for i = 0 step chem_num0 until t :
draw (-chem_num1,i) -- (chem_num1,i)
withpen pencircle scaled chem_axis_rulethickness withcolor colorpart(chem_axis_color) ;
endfor
- for i = 0 step -chem_num0 until -chem_setting_b :
+ for i = 0 step -chem_num0 until b :
draw (-chem_num1,i) -- (chem_num1,i)
withpen pencircle scaled chem_axis_rulethickness withcolor colorpart(chem_axis_color) ;
endfor
addto currentpicture also chem_pic ;
fi ;
+
if chem_tracing :
fill boundingbox currentpicture withcolor blue withtransparency(1,.25) ;
fi ;
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index e5016d3eb..add21fc90 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -1023,47 +1023,63 @@ end
-- touching files (signals regeneration of formats)
-local function touch(name,pattern)
+local function touch(name,versionpattern,kind,kindpattern)
local name = resolvers.findfile(name)
local olddata = io.loaddata(name)
if olddata then
+ local oldkind, newkind = "", kind or ""
local oldversion, newversion = "", os.date("%Y.%m.%d %H:%M")
- local newdata, ok = gsub(olddata,pattern,function(pre,mid,post)
- oldversion = mid
- return pre .. newversion .. post
- end)
- if ok > 0 then
+ local newdata
+ if versionpattern then
+ newdata = gsub(olddata,versionpattern,function(pre,mid,post)
+ oldversion = mid
+ return pre .. newversion .. post
+ end) or olddata
+ end
+ if kind and kindpattern then
+ newdata = gsub(newdata,kindpattern,function(pre,mid,post)
+ oldkind = mid
+ return pre .. newkind .. post
+ end) or newdata
+ end
+ if newdata ~= "" and (oldversion ~= newversion or oldkind ~= newkind or newdata ~= olddata) then
local backup = file.replacesuffix(name,"tmp")
os.remove(backup)
os.rename(name,backup)
io.savedata(name,newdata)
- return true, oldversion, newversion, name
- else
- return false
+ return name, oldversion, newversion, oldkind, newkind
end
end
end
-local function touchfiles(suffix)
- local done, oldversion, newversion, foundname = touch(file.addsuffix("context",suffix),"(\\edef\\contextversion{)(.-)(})")
- if done then
- report("old version : %s", oldversion)
- report("new version : %s", newversion)
- report("touched file: %s", foundname)
- local ok, _, _, foundname = touch(file.addsuffix("cont-new",suffix), "(\\newcontextversion{)(.-)(})")
- if ok then
- report("touched file: %s", foundname)
+local p_contextkind = "(\\edef\\contextkind%s*{)(.-)(})"
+local p_contextversion = "(\\edef\\contextversion%s*{)(.-)(})"
+local p_newcontextversion = "(\\newcontextversion%s*{)(.-)(})"
+
+local function touchfiles(suffix,kind)
+ local foundname, oldversion, newversion, oldkind, newkind = touch(file.addsuffix("context",suffix),p_contextversion,kind,p_contextkind)
+ if foundname then
+ report("old version : %s (%s)",oldversion,oldkind)
+ report("new version : %s (%s)",newversion,newkind)
+ report("touched file : %s",foundname)
+ local foundname = touch(file.addsuffix("cont-new",suffix),p_newcontextversion)
+ if foundname then
+ report("touched file : %s", foundname)
end
end
end
function scripts.context.touch()
if getargument("expert") then
- touchfiles("mkii")
- touchfiles("mkiv")
- touchfiles("mkvi")
- touchfiles("mkix")
- touchfiles("mkxi")
+ local touch = getargument("touch")
+ local kind = getargument("kind")
+ if touch == "mkii" or touch == "mkiv" or touch == "mkvi" then -- mkix mkxi
+ touchfiles(touch,kind)
+ else
+ touchfiles("mkii",kind)
+ touchfiles("mkiv",kind)
+ touchfiles("mkvi",kind)
+ end
else
report("touching needs --expert")
end
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 22089df7a..4997d7458 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: 8020, stripped down to: 5488
+-- original size: 10064, stripped down to: 5696
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -136,6 +136,7 @@ function optionalrequire(...)
return result
end
end
+local type=type
local gsub,format=string.gsub,string.format
local package=package
local searchers=package.searchers or package.loaders
@@ -167,45 +168,38 @@ local function getclibpaths()
end
package.libpaths=getlibpaths
package.clibpaths=getclibpaths
-function package.extralibpath(...)
- libpaths=getlibpaths()
+local function addpath(what,paths,extras,hash,...)
local pathlist={... }
local cleanpath=helpers.cleanpath
local trace=helpers.trace
local report=helpers.report
- for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not libhash[path] then
- if trace then
- report("! extra lua path: %s",path)
- end
- libextras[#libextras+1]=path
- libpaths [#libpaths+1]=path
+ local function add(path)
+ local path=cleanpath(path)
+ if not hash[path] then
+ if trace then
+ report("! extra %s path: %s",what,path)
end
+ paths [#paths+1]=path
+ extras[#extras+1]=path
end
end
-end
-function package.extraclibpath(...)
- clibpaths=getclibpaths()
- local pathlist={... }
- local cleanpath=helpers.cleanpath
- local trace=helpers.trace
- local report=helpers.report
for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not clibhash[path] then
- if trace then
- report("! extra lib path: %s",path)
- end
- clibextras[#clibextras+1]=path
- clibpaths [#clibpaths+1]=path
+ local path=pathlist[p]
+ if type(path)=="table" then
+ for i=1,#path do
+ add(path[i])
end
+ else
+ add(path)
end
end
+ return paths,extras
+end
+function package.extralibpath(...)
+ libpaths,libextras=addpath("lua",getlibpaths(),libextras,libhash,...)
+end
+function package.extraclibpath(...)
+ clibpaths,clibextras=addpath("lib",getclibpaths(),clibextras,clibhash,...)
end
if not searchers[-2] then
searchers[-2]=searchers[2]
@@ -213,14 +207,19 @@ end
searchers[2]=function(name)
return helpers.loaded(name)
end
+searchers[3]=nil
local function loadedaslib(resolved,rawname)
- return package.loadlib(resolved,"luaopen_"..gsub(rawname,"%.","_"))
+ local init="luaopen_"..gsub(rawname,"%.","_")
+ if helpers.trace then
+ 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)
end
- return searchers[-2](name)
+ return true,searchers[-2](name)
end
local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
@@ -239,9 +238,9 @@ local function loadedbypath(name,rawname,paths,islib,what)
report("! lib '%s' located on '%s'",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true,loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true,loadfile(resolved)
end
end
end
@@ -261,11 +260,23 @@ function helpers.loaded(name)
local libname=addsuffix(thename,os.libsuffix or "so")
local libpaths=getlibpaths()
local clibpaths=getclibpaths()
- return loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done,result=loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done,result=loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
@@ -3344,7 +3355,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 13035, stripped down to: 8133
+-- original size: 13139, stripped down to: 8196
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -3366,6 +3377,7 @@ local walkdir=lfs.dir
local isdir=lfs.isdir
local isfile=lfs.isfile
local currentdir=lfs.currentdir
+local chdir=lfs.chdir
if not isdir then
function isdir(name)
local a=attributes(name)
@@ -3622,7 +3634,7 @@ if onwindows then
function dir.expandname(str)
local first,nothing,last=match(str,"^(//)(//*)(.*)$")
if first then
- first=dir.current().."/"
+ first=dir.current().."/"
end
if not first then
first,last=match(str,"^(//)/*(.*)$")
@@ -3631,10 +3643,10 @@ if onwindows then
first,last=match(str,"^([a-zA-Z]:)(.*)$")
if first and not find(last,"^/") then
local d=currentdir()
- if lfs.chdir(first) then
+ if chdir(first) then
first=dir.current()
end
- lfs.chdir(d)
+ chdir(d)
end
end
if not first then
@@ -3664,12 +3676,15 @@ end
file.expandname=dir.expandname
local stack={}
function dir.push(newdir)
- insert(stack,lfs.currentdir())
+ insert(stack,currentdir())
+ if newdir and newdir~="" then
+ chdir(newdir)
+ end
end
function dir.pop()
local d=remove(stack)
if d then
- lfs.chdir(d)
+ chdir(d)
end
return d
end
@@ -5143,7 +5158,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sto"] = package.loaded["util-sto"] or true
--- original size: 4237, stripped down to: 2975
+-- original size: 4432, stripped down to: 3123
if not modules then modules={} end modules ['util-sto']={
version=1.001,
@@ -5152,7 +5167,7 @@ if not modules then modules={} end modules ['util-sto']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
-local setmetatable,getmetatable=setmetatable,getmetatable
+local setmetatable,getmetatable,type=setmetatable,getmetatable,type
utilities=utilities or {}
utilities.storage=utilities.storage or {}
local storage=utilities.storage
@@ -5219,6 +5234,9 @@ local t_self={ __index=f_self }
local t_table={ __index=f_table }
local t_ignore={ __newindex=f_ignore }
function table.setmetatableindex(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
if f=="empty" then
@@ -5244,6 +5262,9 @@ function table.setmetatableindex(t,f)
return t
end
function table.setmetatablenewindex(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
if f=="ignore" then
@@ -5261,6 +5282,9 @@ function table.setmetatablenewindex(t,f)
return t
end
function table.setmetatablecall(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
m.__call=f
@@ -7882,7 +7906,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-env"] = package.loaded["luat-env"] or true
--- original size: 5597, stripped down to: 3965
+-- original size: 5874, stripped down to: 4184
if not modules then modules={} end modules ['luat-env']={
version=1.001,
@@ -7908,6 +7932,14 @@ local mt={
else
return "unknown"
end
+ elseif k=="kind" then
+ local kind=tex.toks and tex.toks.contextkindtoks
+ if kind and kind~="" then
+ rawset(environment,"kind",kind)
+ return kind
+ else
+ return "unknown"
+ end
elseif k=="jobname" or k=="formatname" then
local name=tex and tex[k]
if name or name=="" then
@@ -12642,7 +12674,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 60140, stripped down to: 42335
+-- original size: 60509, stripped down to: 42429
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -13330,7 +13362,7 @@ local function collect_files(names)
local files=blobpath and instance.files[blobpath]
if files then
if trace_detail then
- report_resolving("deep checking %a (%s)",blobpath,bname)
+ report_resolving("deep checking %a, base %a, pattern %a",blobpath,bname,dname)
end
local blobfile=files[bname]
if not blobfile then
@@ -13461,7 +13493,7 @@ local function find_wildcard(filename,allresults)
end
end
end
-local function find_qualified(filename,allresults)
+local function find_qualified(filename,allresults,askedformat,alsostripped)
if not file.is_qualified_path(filename) then
return
end
@@ -13493,7 +13525,7 @@ local function find_qualified(filename,allresults)
end
end
end
- if suffix and suffix~="" then
+ if alsostripped and suffix and suffix~="" then
local basename=filebasename(filename)
local pattern=lpegmatch(preparetreepattern,filename)
local savedformat=askedformat
@@ -13693,7 +13725,7 @@ collect_instance_files=function(filename,askedformat,allresults)
local results={
{ find_direct (filename,true) },
{ find_wildcard (filename,true) },
- { find_qualified(filename,true) },
+ { find_qualified(filename,true,askedformat) },
{ find_intree (filename,filetype,wantedfiles,true) },
{ find_onpath (filename,filetype,wantedfiles,true) },
{ find_otherwise(filename,filetype,wantedfiles,true) },
@@ -13732,7 +13764,7 @@ collect_instance_files=function(filename,askedformat,allresults)
if not result then
method,result=find_wildcard(filename)
if not result then
- method,result=find_qualified(filename)
+ method,result=find_qualified(filename,false,askedformat)
if not result then
filetype,wantedfiles=find_analyze(filename,askedformat)
method,result=find_intree(filename,filetype,wantedfiles)
@@ -15077,7 +15109,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lua"] = package.loaded["data-lua"] or true
--- original size: 3796, stripped down to: 3187
+-- original size: 4333, stripped down to: 3534
if not modules then modules={} end modules ['data-lua']={
version=1.001,
@@ -15155,9 +15187,9 @@ local function loadedbyformat(name,rawname,suffixes,islib)
report("! lib %a located on %a",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true,loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true,loadfile(resolved)
end
end
end
@@ -15169,14 +15201,33 @@ function helpers.loaded(name)
local libname=addsuffix(thename,os.libsuffix)
local libpaths=getlibpaths()
local clibpaths=getclibpaths()
- return loadedbyformat(luaname,name,libsuffixes,false)
- or loadedbyformat(libname,name,clibsuffixes,true)
- or loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done,result=loadedbyformat(luaname,name,libsuffixes,false)
+ if done then
+ return result
+ end
+ local done,result=loadedbyformat(libname,name,clibsuffixes,true)
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done,result=loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
+package.searchers[3]=nil
resolvers.loadlualib=require
@@ -15623,8 +15674,8 @@ 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
-- skipped libraries : -
--- original bytes : 644822
--- stripped bytes : 232608
+-- original bytes : 648348
+-- stripped bytes : 235055
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.dll b/scripts/context/stubs/mswin/mtxrun.dll
index 4116c5a24..6ba2597d5 100644
--- a/scripts/context/stubs/mswin/mtxrun.dll
+++ b/scripts/context/stubs/mswin/mtxrun.dll
Binary files differ
diff --git a/scripts/context/stubs/mswin/mtxrun.exe b/scripts/context/stubs/mswin/mtxrun.exe
index 745eaf224..acd99ddbf 100644
--- a/scripts/context/stubs/mswin/mtxrun.exe
+++ b/scripts/context/stubs/mswin/mtxrun.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 22089df7a..4997d7458 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: 8020, stripped down to: 5488
+-- original size: 10064, stripped down to: 5696
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -136,6 +136,7 @@ function optionalrequire(...)
return result
end
end
+local type=type
local gsub,format=string.gsub,string.format
local package=package
local searchers=package.searchers or package.loaders
@@ -167,45 +168,38 @@ local function getclibpaths()
end
package.libpaths=getlibpaths
package.clibpaths=getclibpaths
-function package.extralibpath(...)
- libpaths=getlibpaths()
+local function addpath(what,paths,extras,hash,...)
local pathlist={... }
local cleanpath=helpers.cleanpath
local trace=helpers.trace
local report=helpers.report
- for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not libhash[path] then
- if trace then
- report("! extra lua path: %s",path)
- end
- libextras[#libextras+1]=path
- libpaths [#libpaths+1]=path
+ local function add(path)
+ local path=cleanpath(path)
+ if not hash[path] then
+ if trace then
+ report("! extra %s path: %s",what,path)
end
+ paths [#paths+1]=path
+ extras[#extras+1]=path
end
end
-end
-function package.extraclibpath(...)
- clibpaths=getclibpaths()
- local pathlist={... }
- local cleanpath=helpers.cleanpath
- local trace=helpers.trace
- local report=helpers.report
for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not clibhash[path] then
- if trace then
- report("! extra lib path: %s",path)
- end
- clibextras[#clibextras+1]=path
- clibpaths [#clibpaths+1]=path
+ local path=pathlist[p]
+ if type(path)=="table" then
+ for i=1,#path do
+ add(path[i])
end
+ else
+ add(path)
end
end
+ return paths,extras
+end
+function package.extralibpath(...)
+ libpaths,libextras=addpath("lua",getlibpaths(),libextras,libhash,...)
+end
+function package.extraclibpath(...)
+ clibpaths,clibextras=addpath("lib",getclibpaths(),clibextras,clibhash,...)
end
if not searchers[-2] then
searchers[-2]=searchers[2]
@@ -213,14 +207,19 @@ end
searchers[2]=function(name)
return helpers.loaded(name)
end
+searchers[3]=nil
local function loadedaslib(resolved,rawname)
- return package.loadlib(resolved,"luaopen_"..gsub(rawname,"%.","_"))
+ local init="luaopen_"..gsub(rawname,"%.","_")
+ if helpers.trace then
+ 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)
end
- return searchers[-2](name)
+ return true,searchers[-2](name)
end
local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
@@ -239,9 +238,9 @@ local function loadedbypath(name,rawname,paths,islib,what)
report("! lib '%s' located on '%s'",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true,loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true,loadfile(resolved)
end
end
end
@@ -261,11 +260,23 @@ function helpers.loaded(name)
local libname=addsuffix(thename,os.libsuffix or "so")
local libpaths=getlibpaths()
local clibpaths=getclibpaths()
- return loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done,result=loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done,result=loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
@@ -3344,7 +3355,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 13035, stripped down to: 8133
+-- original size: 13139, stripped down to: 8196
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -3366,6 +3377,7 @@ local walkdir=lfs.dir
local isdir=lfs.isdir
local isfile=lfs.isfile
local currentdir=lfs.currentdir
+local chdir=lfs.chdir
if not isdir then
function isdir(name)
local a=attributes(name)
@@ -3622,7 +3634,7 @@ if onwindows then
function dir.expandname(str)
local first,nothing,last=match(str,"^(//)(//*)(.*)$")
if first then
- first=dir.current().."/"
+ first=dir.current().."/"
end
if not first then
first,last=match(str,"^(//)/*(.*)$")
@@ -3631,10 +3643,10 @@ if onwindows then
first,last=match(str,"^([a-zA-Z]:)(.*)$")
if first and not find(last,"^/") then
local d=currentdir()
- if lfs.chdir(first) then
+ if chdir(first) then
first=dir.current()
end
- lfs.chdir(d)
+ chdir(d)
end
end
if not first then
@@ -3664,12 +3676,15 @@ end
file.expandname=dir.expandname
local stack={}
function dir.push(newdir)
- insert(stack,lfs.currentdir())
+ insert(stack,currentdir())
+ if newdir and newdir~="" then
+ chdir(newdir)
+ end
end
function dir.pop()
local d=remove(stack)
if d then
- lfs.chdir(d)
+ chdir(d)
end
return d
end
@@ -5143,7 +5158,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sto"] = package.loaded["util-sto"] or true
--- original size: 4237, stripped down to: 2975
+-- original size: 4432, stripped down to: 3123
if not modules then modules={} end modules ['util-sto']={
version=1.001,
@@ -5152,7 +5167,7 @@ if not modules then modules={} end modules ['util-sto']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
-local setmetatable,getmetatable=setmetatable,getmetatable
+local setmetatable,getmetatable,type=setmetatable,getmetatable,type
utilities=utilities or {}
utilities.storage=utilities.storage or {}
local storage=utilities.storage
@@ -5219,6 +5234,9 @@ local t_self={ __index=f_self }
local t_table={ __index=f_table }
local t_ignore={ __newindex=f_ignore }
function table.setmetatableindex(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
if f=="empty" then
@@ -5244,6 +5262,9 @@ function table.setmetatableindex(t,f)
return t
end
function table.setmetatablenewindex(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
if f=="ignore" then
@@ -5261,6 +5282,9 @@ function table.setmetatablenewindex(t,f)
return t
end
function table.setmetatablecall(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
m.__call=f
@@ -7882,7 +7906,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-env"] = package.loaded["luat-env"] or true
--- original size: 5597, stripped down to: 3965
+-- original size: 5874, stripped down to: 4184
if not modules then modules={} end modules ['luat-env']={
version=1.001,
@@ -7908,6 +7932,14 @@ local mt={
else
return "unknown"
end
+ elseif k=="kind" then
+ local kind=tex.toks and tex.toks.contextkindtoks
+ if kind and kind~="" then
+ rawset(environment,"kind",kind)
+ return kind
+ else
+ return "unknown"
+ end
elseif k=="jobname" or k=="formatname" then
local name=tex and tex[k]
if name or name=="" then
@@ -12642,7 +12674,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 60140, stripped down to: 42335
+-- original size: 60509, stripped down to: 42429
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -13330,7 +13362,7 @@ local function collect_files(names)
local files=blobpath and instance.files[blobpath]
if files then
if trace_detail then
- report_resolving("deep checking %a (%s)",blobpath,bname)
+ report_resolving("deep checking %a, base %a, pattern %a",blobpath,bname,dname)
end
local blobfile=files[bname]
if not blobfile then
@@ -13461,7 +13493,7 @@ local function find_wildcard(filename,allresults)
end
end
end
-local function find_qualified(filename,allresults)
+local function find_qualified(filename,allresults,askedformat,alsostripped)
if not file.is_qualified_path(filename) then
return
end
@@ -13493,7 +13525,7 @@ local function find_qualified(filename,allresults)
end
end
end
- if suffix and suffix~="" then
+ if alsostripped and suffix and suffix~="" then
local basename=filebasename(filename)
local pattern=lpegmatch(preparetreepattern,filename)
local savedformat=askedformat
@@ -13693,7 +13725,7 @@ collect_instance_files=function(filename,askedformat,allresults)
local results={
{ find_direct (filename,true) },
{ find_wildcard (filename,true) },
- { find_qualified(filename,true) },
+ { find_qualified(filename,true,askedformat) },
{ find_intree (filename,filetype,wantedfiles,true) },
{ find_onpath (filename,filetype,wantedfiles,true) },
{ find_otherwise(filename,filetype,wantedfiles,true) },
@@ -13732,7 +13764,7 @@ collect_instance_files=function(filename,askedformat,allresults)
if not result then
method,result=find_wildcard(filename)
if not result then
- method,result=find_qualified(filename)
+ method,result=find_qualified(filename,false,askedformat)
if not result then
filetype,wantedfiles=find_analyze(filename,askedformat)
method,result=find_intree(filename,filetype,wantedfiles)
@@ -15077,7 +15109,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lua"] = package.loaded["data-lua"] or true
--- original size: 3796, stripped down to: 3187
+-- original size: 4333, stripped down to: 3534
if not modules then modules={} end modules ['data-lua']={
version=1.001,
@@ -15155,9 +15187,9 @@ local function loadedbyformat(name,rawname,suffixes,islib)
report("! lib %a located on %a",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true,loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true,loadfile(resolved)
end
end
end
@@ -15169,14 +15201,33 @@ function helpers.loaded(name)
local libname=addsuffix(thename,os.libsuffix)
local libpaths=getlibpaths()
local clibpaths=getclibpaths()
- return loadedbyformat(luaname,name,libsuffixes,false)
- or loadedbyformat(libname,name,clibsuffixes,true)
- or loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done,result=loadedbyformat(luaname,name,libsuffixes,false)
+ if done then
+ return result
+ end
+ local done,result=loadedbyformat(libname,name,clibsuffixes,true)
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done,result=loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
+package.searchers[3]=nil
resolvers.loadlualib=require
@@ -15623,8 +15674,8 @@ 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
-- skipped libraries : -
--- original bytes : 644822
--- stripped bytes : 232608
+-- original bytes : 648348
+-- stripped bytes : 235055
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 22089df7a..4997d7458 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: 8020, stripped down to: 5488
+-- original size: 10064, stripped down to: 5696
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -136,6 +136,7 @@ function optionalrequire(...)
return result
end
end
+local type=type
local gsub,format=string.gsub,string.format
local package=package
local searchers=package.searchers or package.loaders
@@ -167,45 +168,38 @@ local function getclibpaths()
end
package.libpaths=getlibpaths
package.clibpaths=getclibpaths
-function package.extralibpath(...)
- libpaths=getlibpaths()
+local function addpath(what,paths,extras,hash,...)
local pathlist={... }
local cleanpath=helpers.cleanpath
local trace=helpers.trace
local report=helpers.report
- for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not libhash[path] then
- if trace then
- report("! extra lua path: %s",path)
- end
- libextras[#libextras+1]=path
- libpaths [#libpaths+1]=path
+ local function add(path)
+ local path=cleanpath(path)
+ if not hash[path] then
+ if trace then
+ report("! extra %s path: %s",what,path)
end
+ paths [#paths+1]=path
+ extras[#extras+1]=path
end
end
-end
-function package.extraclibpath(...)
- clibpaths=getclibpaths()
- local pathlist={... }
- local cleanpath=helpers.cleanpath
- local trace=helpers.trace
- local report=helpers.report
for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not clibhash[path] then
- if trace then
- report("! extra lib path: %s",path)
- end
- clibextras[#clibextras+1]=path
- clibpaths [#clibpaths+1]=path
+ local path=pathlist[p]
+ if type(path)=="table" then
+ for i=1,#path do
+ add(path[i])
end
+ else
+ add(path)
end
end
+ return paths,extras
+end
+function package.extralibpath(...)
+ libpaths,libextras=addpath("lua",getlibpaths(),libextras,libhash,...)
+end
+function package.extraclibpath(...)
+ clibpaths,clibextras=addpath("lib",getclibpaths(),clibextras,clibhash,...)
end
if not searchers[-2] then
searchers[-2]=searchers[2]
@@ -213,14 +207,19 @@ end
searchers[2]=function(name)
return helpers.loaded(name)
end
+searchers[3]=nil
local function loadedaslib(resolved,rawname)
- return package.loadlib(resolved,"luaopen_"..gsub(rawname,"%.","_"))
+ local init="luaopen_"..gsub(rawname,"%.","_")
+ if helpers.trace then
+ 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)
end
- return searchers[-2](name)
+ return true,searchers[-2](name)
end
local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
@@ -239,9 +238,9 @@ local function loadedbypath(name,rawname,paths,islib,what)
report("! lib '%s' located on '%s'",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true,loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true,loadfile(resolved)
end
end
end
@@ -261,11 +260,23 @@ function helpers.loaded(name)
local libname=addsuffix(thename,os.libsuffix or "so")
local libpaths=getlibpaths()
local clibpaths=getclibpaths()
- return loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done,result=loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done,result=loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
@@ -3344,7 +3355,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 13035, stripped down to: 8133
+-- original size: 13139, stripped down to: 8196
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -3366,6 +3377,7 @@ local walkdir=lfs.dir
local isdir=lfs.isdir
local isfile=lfs.isfile
local currentdir=lfs.currentdir
+local chdir=lfs.chdir
if not isdir then
function isdir(name)
local a=attributes(name)
@@ -3622,7 +3634,7 @@ if onwindows then
function dir.expandname(str)
local first,nothing,last=match(str,"^(//)(//*)(.*)$")
if first then
- first=dir.current().."/"
+ first=dir.current().."/"
end
if not first then
first,last=match(str,"^(//)/*(.*)$")
@@ -3631,10 +3643,10 @@ if onwindows then
first,last=match(str,"^([a-zA-Z]:)(.*)$")
if first and not find(last,"^/") then
local d=currentdir()
- if lfs.chdir(first) then
+ if chdir(first) then
first=dir.current()
end
- lfs.chdir(d)
+ chdir(d)
end
end
if not first then
@@ -3664,12 +3676,15 @@ end
file.expandname=dir.expandname
local stack={}
function dir.push(newdir)
- insert(stack,lfs.currentdir())
+ insert(stack,currentdir())
+ if newdir and newdir~="" then
+ chdir(newdir)
+ end
end
function dir.pop()
local d=remove(stack)
if d then
- lfs.chdir(d)
+ chdir(d)
end
return d
end
@@ -5143,7 +5158,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sto"] = package.loaded["util-sto"] or true
--- original size: 4237, stripped down to: 2975
+-- original size: 4432, stripped down to: 3123
if not modules then modules={} end modules ['util-sto']={
version=1.001,
@@ -5152,7 +5167,7 @@ if not modules then modules={} end modules ['util-sto']={
copyright="PRAGMA ADE / ConTeXt Development Team",
license="see context related readme files"
}
-local setmetatable,getmetatable=setmetatable,getmetatable
+local setmetatable,getmetatable,type=setmetatable,getmetatable,type
utilities=utilities or {}
utilities.storage=utilities.storage or {}
local storage=utilities.storage
@@ -5219,6 +5234,9 @@ local t_self={ __index=f_self }
local t_table={ __index=f_table }
local t_ignore={ __newindex=f_ignore }
function table.setmetatableindex(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
if f=="empty" then
@@ -5244,6 +5262,9 @@ function table.setmetatableindex(t,f)
return t
end
function table.setmetatablenewindex(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
if f=="ignore" then
@@ -5261,6 +5282,9 @@ function table.setmetatablenewindex(t,f)
return t
end
function table.setmetatablecall(t,f)
+ if type(t)~="table" then
+ f,t=t,{}
+ end
local m=getmetatable(t)
if m then
m.__call=f
@@ -7882,7 +7906,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-env"] = package.loaded["luat-env"] or true
--- original size: 5597, stripped down to: 3965
+-- original size: 5874, stripped down to: 4184
if not modules then modules={} end modules ['luat-env']={
version=1.001,
@@ -7908,6 +7932,14 @@ local mt={
else
return "unknown"
end
+ elseif k=="kind" then
+ local kind=tex.toks and tex.toks.contextkindtoks
+ if kind and kind~="" then
+ rawset(environment,"kind",kind)
+ return kind
+ else
+ return "unknown"
+ end
elseif k=="jobname" or k=="formatname" then
local name=tex and tex[k]
if name or name=="" then
@@ -12642,7 +12674,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 60140, stripped down to: 42335
+-- original size: 60509, stripped down to: 42429
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -13330,7 +13362,7 @@ local function collect_files(names)
local files=blobpath and instance.files[blobpath]
if files then
if trace_detail then
- report_resolving("deep checking %a (%s)",blobpath,bname)
+ report_resolving("deep checking %a, base %a, pattern %a",blobpath,bname,dname)
end
local blobfile=files[bname]
if not blobfile then
@@ -13461,7 +13493,7 @@ local function find_wildcard(filename,allresults)
end
end
end
-local function find_qualified(filename,allresults)
+local function find_qualified(filename,allresults,askedformat,alsostripped)
if not file.is_qualified_path(filename) then
return
end
@@ -13493,7 +13525,7 @@ local function find_qualified(filename,allresults)
end
end
end
- if suffix and suffix~="" then
+ if alsostripped and suffix and suffix~="" then
local basename=filebasename(filename)
local pattern=lpegmatch(preparetreepattern,filename)
local savedformat=askedformat
@@ -13693,7 +13725,7 @@ collect_instance_files=function(filename,askedformat,allresults)
local results={
{ find_direct (filename,true) },
{ find_wildcard (filename,true) },
- { find_qualified(filename,true) },
+ { find_qualified(filename,true,askedformat) },
{ find_intree (filename,filetype,wantedfiles,true) },
{ find_onpath (filename,filetype,wantedfiles,true) },
{ find_otherwise(filename,filetype,wantedfiles,true) },
@@ -13732,7 +13764,7 @@ collect_instance_files=function(filename,askedformat,allresults)
if not result then
method,result=find_wildcard(filename)
if not result then
- method,result=find_qualified(filename)
+ method,result=find_qualified(filename,false,askedformat)
if not result then
filetype,wantedfiles=find_analyze(filename,askedformat)
method,result=find_intree(filename,filetype,wantedfiles)
@@ -15077,7 +15109,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-lua"] = package.loaded["data-lua"] or true
--- original size: 3796, stripped down to: 3187
+-- original size: 4333, stripped down to: 3534
if not modules then modules={} end modules ['data-lua']={
version=1.001,
@@ -15155,9 +15187,9 @@ local function loadedbyformat(name,rawname,suffixes,islib)
report("! lib %a located on %a",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true,loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true,loadfile(resolved)
end
end
end
@@ -15169,14 +15201,33 @@ function helpers.loaded(name)
local libname=addsuffix(thename,os.libsuffix)
local libpaths=getlibpaths()
local clibpaths=getclibpaths()
- return loadedbyformat(luaname,name,libsuffixes,false)
- or loadedbyformat(libname,name,clibsuffixes,true)
- or loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done,result=loadedbyformat(luaname,name,libsuffixes,false)
+ if done then
+ return result
+ end
+ local done,result=loadedbyformat(libname,name,clibsuffixes,true)
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done,result=loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
+package.searchers[3]=nil
resolvers.loadlualib=require
@@ -15623,8 +15674,8 @@ 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
-- skipped libraries : -
--- original bytes : 644822
--- stripped bytes : 232608
+-- original bytes : 648348
+-- stripped bytes : 235055
-- end library merge
diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua
index 9fa5494fd..c76583fed 100644
--- a/tex/context/base/chem-str.lua
+++ b/tex/context/base/chem-str.lua
@@ -52,6 +52,7 @@ local v_big = variables.big
local v_normal = variables.normal
local v_fit = variables.fit
local v_on = variables.on
+local v_none = variables.none
local mpnamedcolor = attributes.colors.mpnamedcolor
local topoints = number.topoints
@@ -602,20 +603,92 @@ end
--
-- rulethickness in points
+local function checked(d,factor,unit,scale)
+ if d == v_none then
+ return 0
+ end
+ local n = tonumber(d)
+ if not n then
+ -- assume dimen
+ elseif n >= 10 or n <= -10 then
+ return factor * unit * n / 1000
+ else
+ return factor * unit * n
+ end
+ local n = todimen(d)
+ if n then
+ return scale * n
+ else
+ return v_fit
+ end
+end
+
+local function calculated(height,bottom,top,factor,unit,scale)
+ if height == v_none then
+ -- this always wins
+ height = "0pt"
+ bottom = "0pt"
+ top = "0pt"
+ elseif height == v_fit then
+ height = "true"
+ bottom = bottom == v_fit and "true" or topoints(checked(bottom,factor,unit,scale))
+ top = top == v_fit and "true" or topoints(checked(top, factor,unit,scale))
+ else
+ height = checked(height,factor,unit,scale)
+ if bottom == v_fit then
+ if top == v_fit then
+ bottom = height / 2
+ top = bottom
+ else
+ top = checked(top,factor,unit,scale)
+ bottom = height - top
+ end
+ elseif top == v_fit then
+ bottom = checked(bottom,factor,unit,scale)
+ top = height - bottom
+ else
+ bottom = checked(bottom,factor,unit,scale)
+ top = checked(top, factor,unit,scale)
+ local ratio = height / (bottom+top)
+ bottom = bottom * ratio
+ top = top * ratio
+ end
+ top = topoints(top)
+ bottom = topoints(bottom)
+ height = topoints(height)
+ end
+ return height, bottom, top
+end
+
function chemistry.start(settings)
chemistry.structures = chemistry.structures + 1
- local emwidth, rulethickness, rulecolor, axiscolor = settings.emwidth, settings.rulethickness, settings.rulecolor, settings.framecolor
- local width, height, scale, rotation, offset = settings.width or v_fit, settings.height or v_fit, settings.scale or "normal", settings.rotation or 0, settings.offset or 0
- local l, r, t, b = settings.left or v_fit, settings.right or v_fit, settings.top or v_fit, settings.bottom or v_fit
+ local unit = settings.unit or 655360
+ local factor = settings.factor or 3
+ local rulethickness = settings.rulethickness or 65536
+ local rulecolor = settings.rulecolor or ""
+ local axiscolor = settings.framecolor or ""
+ local width = settings.width or v_fit
+ local height = settings.height or v_fit
+ local scale = settings.scale or "normal"
+ local rotation = settings.rotation or 0
+ local offset = settings.offset or 0
+ local left = settings.left or v_fit
+ local right = settings.right or v_fit
+ local top = settings.top or v_fit
+ local bottom = settings.bottom or v_fit
--
metacode = { }
--
align = settings.symalign or "auto"
if trace_structure then
- report_chemistry("%s scale %a, rotation %a, width %a, height %a, left %a, right %a, top %a, bottom %a","asked",scale,rotation,width,height,l,r,t,b)
- report_chemistry("symalign: %s", align)
+ report_chemistry("unit %p, factor %s, symalign %s",unit,factor,align)
+ end
+ if align ~= "" then
+ align = "." .. align
+ end
+ if trace_structure then
+ report_chemistry("%s scale %a, rotation %a, width %s, height %s, left %s, right %s, top %s, bottom %s","asked",scale,rotation,width,height,left,right,top,bottom)
end
- if align ~= "" then align = "." .. align end
if scale == v_small then
scale = 1/1.2
elseif scale == v_normal or scale == v_medium or scale == 0 then
@@ -633,107 +706,21 @@ function chemistry.start(settings)
end
end
--
- -- -- shorter:
- --
- -- local width = tonumber(width) or v_fit
- -- if width ~= v_fit and (width >= 10 or width <= -10) then
- -- width = width / 1000
- -- end
+ unit = scale * unit
--
- if width ~= v_fit then
- if tonumber(width) then
- width = tonumber(width)
- if width >= 10 or width <= -10 then
- width = width / 1000
- end
- else
- width = v_fit
- end
- end
- if r ~= v_fit then
- if tonumber(r) then
- r = tonumber(r)
- if r >= 10 or r <= -10 then
- r = r / 1000
- end
- else
- r = v_fit
- end
- end
- if l ~= v_fit then
- if tonumber(l) then
- l = tonumber(l)
- if l >= 10 or l <= -10 then
- l = l / 1000
- end
- else
- l = v_fit
- end
- end
- if width ~= v_fit and r == v_fit and l == v_fit then
- l = width/2
- r = width/2
- elseif r == v_fit and l ~= v_fit and width ~= v_fit then
- r = width - l -- left and width are specified, but not right
- elseif l == v_fit and r ~= v_fit and width ~= v_fit then
- l = width - r -- right and width are specified, but not left
- end
- -- setting both left and right overrides width (width is no longer needed)
- if l == v_fit then l = "true" end
- if r == v_fit then r = "true" end
- --
- if height ~= v_fit then
- if tonumber(height) then
- height = tonumber(height)
- if height >= 10 or height <= -10 then
- height = height / 1000
- end
- else
- height = v_fit
- end
- end
- if b ~= v_fit then
- if tonumber(b) then
- b = tonumber(b)
- if b >= 10 or b <= -10 then
- b = b / 1000
- end
- else
- b = v_fit
- end
- end
- if t ~= v_fit then
- if tonumber(t) then
- t = tonumber(t)
- if t >= 10 or t <= -10 then
- t = t / 1000
- end
- else
- t = v_fit
- end
- end
- if height ~= v_fit and b == v_fit and t == v_fit then
- b = height/2
- t = height/2
- elseif b == v_fit and t ~= v_fit and height ~= v_fit then
- b = height - t -- top and height are specified, but not bottom
- elseif t == v_fit and b ~= v_fit and height ~= v_fit then
- t = height - b -- bottom and height are specified, but not top
- end
- -- setting both top and bottom overrides height (height is no longer needed)
- if b == v_fit then b = "true" end
- if t == v_fit then t = "true" end
+ width, left, right = calculated(width, left, right,factor,unit,scale)
+ height, bottom, top = calculated(height,bottom,top, factor,unit,scale)
--
rotation = tonumber(rotation) or 0
--
if trace_structure then
- report_chemistry("%s scale %a, rotation %a, width %a, height %a, left %a, right %a, top %a, bottom %a","used",scale,rotation,width,height,l,r,t,b)
+ report_chemistry("%s scale %a, rotation %a, width %s, height %s, left %s, right %s, top %s, bottom %s","used",scale,rotation,width,height,left,right,top,bottom)
end
metacode[#metacode+1] = f_start_structure(
chemistry.structures,
- l, r, t, b, scale, rotation,
- tostring(emwidth), tostring(offset),
- tostring(settings.axis == v_on), tostring(rulethickness), tostring(axiscolor)
+ left, right, top, bottom,
+ rotation, topoints(unit), factor, topoints(offset),
+ tostring(settings.axis == v_on), topoints(rulethickness), tostring(axiscolor)
)
metacode[#metacode+1] = f_set_tracing(trace_metapost) ;
--
diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv
index a43b756b8..c28ea21d9 100644
--- a/tex/context/base/chem-str.mkiv
+++ b/tex/context/base/chem-str.mkiv
@@ -163,18 +163,19 @@
\ctxcommand{startchemical {
width = "\chemicalparameter\c!width",
height = "\chemicalparameter\c!height",
- left = \chemicalparameter\c!left,
- right = \chemicalparameter\c!right,
- top = \chemicalparameter\c!top,
- bottom = \chemicalparameter\c!bottom,
+ left = "\chemicalparameter\c!left",
+ right = "\chemicalparameter\c!right",
+ top = "\chemicalparameter\c!top",
+ bottom = "\chemicalparameter\c!bottom",
scale = "\chemicalparameter\c!scale",
rotation = "\chemicalparameter\c!rotation",
symalign = "\chemicalparameter\c!symalign",
axis = "\chemicalparameter\c!axis",
framecolor = "\MPcolor{\chemicalparameter\c!framecolor}",
- rulethickness = "\the\dimexpr\chemicalparameter\c!rulethickness\relax",
- offset = "\the\dimexpr\chemicalparameter\c!offset\relax",
- emwidth = "\the\emwidth", % EmWidth (\the\emwidth) does not work in MP...
+ rulethickness = \number\dimexpr\chemicalparameter\c!rulethickness\relax,
+ offset = \number\dimexpr\chemicalparameter\c!offset\relax,
+ unit = \number\dimexpr\chemicalparameter\c!unit\relax,
+ factor = \number\chemicalparameter\c!factor,
} }%
\startnointerference}
@@ -689,12 +690,13 @@
\c!symalign=\v!auto,
\c!location=, % not yet used (was interaction related in mkii)
\c!offset=.25em,
+ \c!unit=\emwidth,
+ \c!factor=3,
\c!color=,
\c!strut=\v!yes,
\c!framecolor=chemicalframecolor,
\c!rulethickness=0.6pt, %1.5\linewidth,
- \c!rulecolor=,
- \c!factor=1] % how is factor used??
+ \c!rulecolor=]
%D Compatibility:
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 6bb07be54..21e24eb48 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.29 01:03}
+\newcontextversion{2013.03.27 13:27}
%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 17348a12f..de55fbb3e 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.03.29 01:03}
+\newcontextversion{2013.04.01 14:16}
%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 2d4af29ec..b01bf0369 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 da8d14758..e274ca41e 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 7ac0a0c82..6fed3272e 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.03.29 01:03}
+\edef\contextversion{2013.03.29 01:31}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index bc697a9a6..dd9e85779 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -25,7 +25,8 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.03.29 01:03}
+\edef\contextversion{2013.04.01 14:16}
+\edef\contextkind {beta}
%D For those who want to use this:
@@ -64,10 +65,11 @@
\expandafter\end
\fi
-%D There is only this way to pass the version info
-%D to \LUA\ (currently).
+%D There is only this way to pass the version info to \LUA\ (currently). Hm, we could
+%D now put it into the environment.
\newtoks\contextversiontoks \contextversiontoks\expandafter{\contextversion}
+\newtoks\contextkindtoks \contextkindtoks \expandafter{\contextkind}
% \normaleverypar{\wait} % uncomment for test of funny injections
@@ -89,8 +91,8 @@
\loadmarkfile{cldf-ini}
-% From here on we have \unexpanded being \normalprotected, as we
-% already had \unexpanded long before etex came around.
+% From here on we have \unexpanded being \normalprotected, as we already had
+% \unexpanded long before etex came around.
\loadmarkfile{syst-aux}
\loadmarkfile{syst-lua}
@@ -501,7 +503,7 @@
\to \everyjob
\appendtoks
- \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv")}% can become automatic
+ \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv","\contextkind")}% can become automatic
\to \everydump
\errorstopmode \dump \endinput
diff --git a/tex/context/base/data-lua.lua b/tex/context/base/data-lua.lua
index 2725c149f..fde79d464 100644
--- a/tex/context/base/data-lua.lua
+++ b/tex/context/base/data-lua.lua
@@ -90,9 +90,9 @@ local function loadedbyformat(name,rawname,suffixes,islib)
report("! lib %a located on %a",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true, loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true, loadfile(resolved)
end
end
end
@@ -100,19 +100,43 @@ end
helpers.loadedbyformat = loadedbyformat
+-- alternatively we could set the package.searchers
+
function helpers.loaded(name)
local thename = gsub(name,"%.","/")
local luaname = addsuffix(thename,"lua")
local libname = addsuffix(thename,os.libsuffix)
local libpaths = getlibpaths()
local clibpaths = getclibpaths()
- return loadedbyformat(luaname,name,libsuffixes,false)
- or loadedbyformat(libname,name,clibsuffixes,true)
- or loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done, result = loadedbyformat(luaname,name,libsuffixes,false)
+ if done then
+ return result
+ end
+ local done, result = loadedbyformat(libname,name,clibsuffixes,true)
+ if done then
+ return result
+ end
+ local done, result = loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done, result = loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done, result = loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done, result = loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
+package.searchers[3] = nil -- get rid of the built in one
+
+-- package.extraclibpath(environment.ownpath)
+
resolvers.loadlualib = require
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua
index f0b7a96cb..c69ee4ce3 100644
--- a/tex/context/base/data-res.lua
+++ b/tex/context/base/data-res.lua
@@ -12,6 +12,9 @@ if not modules then modules = { } end modules ['data-res'] = {
-- instance but for practical purposes we now avoid this and use a
-- instance variable. We always have one instance active (sort of global).
+-- I will reimplement this module ... way too fuzzy now and we can work
+-- with some sensible constraints as it is only is used for context.
+
-- todo: cache:/// home:/// selfautoparent:/// (sometime end 2012)
local gsub, find, lower, upper, match, gmatch = string.gsub, string.find, string.lower, string.upper, string.match, string.gmatch
@@ -870,7 +873,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- report_resolving("deep checking %a (%s)",blobpath,bname)
+ report_resolving("deep checking %a, base %a, pattern %a",blobpath,bname,dname)
end
local blobfile = files[bname]
if not blobfile then
@@ -1022,7 +1025,7 @@ local function find_wildcard(filename,allresults)
end
end
-local function find_qualified(filename,allresults) -- this one will be split too
+local function find_qualified(filename,allresults,askedformat,alsostripped) -- this one will be split too
if not file.is_qualified_path(filename) then
return
end
@@ -1054,7 +1057,7 @@ local function find_qualified(filename,allresults) -- this one will be split too
end
end
end
- if suffix and suffix ~= "" then
+ if alsostripped and suffix and suffix ~= "" then
-- try to find in tree (no suffix manipulation), here we search for the
-- matching last part of the name
local basename = filebasename(filename)
@@ -1069,6 +1072,8 @@ local function find_qualified(filename,allresults) -- this one will be split too
askedformat = "othertextfiles" -- kind of everything, maybe all
end
--
+ -- is this really what we want? basename if we have an explicit path?
+ --
if basename ~= filename then
local resolved = collect_instance_files(basename,askedformat,allresults)
if #resolved == 0 then
@@ -1291,7 +1296,7 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste
local results = {
{ find_direct (filename,true) },
{ find_wildcard (filename,true) },
- { find_qualified(filename,true) },
+ { find_qualified(filename,true,askedformat) }, -- we can add ,true if we want to find dups
{ find_intree (filename,filetype,wantedfiles,true) },
{ find_onpath (filename,filetype,wantedfiles,true) },
{ find_otherwise(filename,filetype,wantedfiles,true) },
@@ -1330,7 +1335,7 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste
if not result then
method, result = find_wildcard(filename)
if not result then
- method, result = find_qualified(filename)
+ method, result = find_qualified(filename,false,askedformat)
if not result then
filetype, wantedfiles = find_analyze(filename,askedformat)
method, result = find_intree(filename,filetype,wantedfiles)
diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua
index 5dbd1f0fd..74073227a 100644
--- a/tex/context/base/font-def.lua
+++ b/tex/context/base/font-def.lua
@@ -437,6 +437,10 @@ function definers.read(specification,size,id) -- id can be optional, name can al
return tfmdata
end
+function font.getfont(id)
+ return fontdata[id] -- otherwise issues
+end
+
--[[ldx--
<p>We overload the <l n='tfm'/> reader.</p>
--ldx]]--
diff --git a/tex/context/base/font-hsh.lua b/tex/context/base/font-hsh.lua
index 42c4be950..d6c226b7c 100644
--- a/tex/context/base/font-hsh.lua
+++ b/tex/context/base/font-hsh.lua
@@ -176,3 +176,7 @@ setmetatableindex(dynamics, function(t,k)
return dynamics
end
end)
+
+function font.getfont(id)
+ return identifiers[id]
+end
diff --git a/tex/context/base/l-dir.lua b/tex/context/base/l-dir.lua
index 0568bcfb5..00cda3899 100644
--- a/tex/context/base/l-dir.lua
+++ b/tex/context/base/l-dir.lua
@@ -24,6 +24,7 @@ local walkdir = lfs.dir
local isdir = lfs.isdir
local isfile = lfs.isfile
local currentdir = lfs.currentdir
+local chdir = lfs.chdir
-- in case we load outside luatex
@@ -385,7 +386,7 @@ if onwindows then
function dir.expandname(str) -- will be merged with cleanpath and collapsepath
local first, nothing, last = match(str,"^(//)(//*)(.*)$")
if first then
- first = dir.current() .. "/"
+ first = dir.current() .. "/" -- dir.current sanitizes
end
if not first then
first, last = match(str,"^(//)/*(.*)$")
@@ -394,10 +395,10 @@ if onwindows then
first, last = match(str,"^([a-zA-Z]:)(.*)$")
if first and not find(last,"^/") then
local d = currentdir()
- if lfs.chdir(first) then
+ if chdir(first) then
first = dir.current()
end
- lfs.chdir(d)
+ chdir(d)
end
end
if not first then
@@ -433,13 +434,16 @@ file.expandname = dir.expandname -- for convenience
local stack = { }
function dir.push(newdir)
- insert(stack,lfs.currentdir())
+ insert(stack,currentdir())
+ if newdir and newdir ~= "" then
+ chdir(newdir)
+ end
end
function dir.pop()
local d = remove(stack)
if d then
- lfs.chdir(d)
+ chdir(d)
end
return d
end
diff --git a/tex/context/base/l-lua.lua b/tex/context/base/l-lua.lua
index 39f15cd65..555d5d746 100644
--- a/tex/context/base/l-lua.lua
+++ b/tex/context/base/l-lua.lua
@@ -159,9 +159,10 @@ end
-- -- local mylib = require("libtest")
-- -- local mysql = require("luasql.mysql")
+local type = type
local gsub, format = string.gsub, string.format
-local package = package
+local package = package
local searchers = package.searchers or package.loaders
local libpaths = nil
@@ -203,48 +204,104 @@ end
package.libpaths = getlibpaths
package.clibpaths = getclibpaths
-function package.extralibpath(...)
- libpaths = getlibpaths()
+local function addpath(what,paths,extras,hash,...)
local pathlist = { ... }
local cleanpath = helpers.cleanpath
local trace = helpers.trace
local report = helpers.report
- for p=1,#pathlist do
- local paths = pathlist[p]
- for i=1,#paths do
- local path = cleanpath(paths[i])
- if not libhash[path] then
- if trace then
- report("! extra lua path: %s",path)
- end
- libextras[#libextras+1] = path
- libpaths [#libpaths +1] = path
+ --
+ local function add(path)
+ local path = cleanpath(path)
+ if not hash[path] then
+ if trace then
+ report("! extra %s path: %s",what,path)
end
+ paths [#paths +1] = path
+ extras[#extras+1] = path
end
end
-end
-
-function package.extraclibpath(...)
- clibpaths = getclibpaths()
- local pathlist = { ... }
- local cleanpath = helpers.cleanpath
- local trace = helpers.trace
- local report = helpers.report
+ --
for p=1,#pathlist do
- local paths = pathlist[p]
- for i=1,#paths do
- local path = cleanpath(paths[i])
- if not clibhash[path] then
- if trace then
- report("! extra lib path: %s",path)
- end
- clibextras[#clibextras+1] = path
- clibpaths [#clibpaths +1] = path
+ local path = pathlist[p]
+ if type(path) == "table" then
+ for i=1,#path do
+ add(path[i])
end
+ else
+ add(path)
end
end
+ return paths, extras
+end
+
+function package.extralibpath(...)
+ libpaths, libextras = addpath("lua", getlibpaths(), libextras, libhash,...)
+end
+
+function package.extraclibpath(...)
+ clibpaths, clibextras = addpath("lib",getclibpaths(),clibextras,clibhash,...)
end
+-- function package.extralibpath(...)
+-- libpaths = getlibpaths()
+-- local pathlist = { ... }
+-- local cleanpath = helpers.cleanpath
+-- local trace = helpers.trace
+-- local report = helpers.report
+-- --
+-- local function add(path)
+-- local path = cleanpath(path)
+-- if not libhash[path] then
+-- if trace then
+-- report("! extra lua path: %s",path)
+-- end
+-- libextras[#libextras+1] = path
+-- libpaths [#libpaths +1] = path
+-- end
+-- end
+-- --
+-- for p=1,#pathlist do
+-- local path = pathlist[p]
+-- if type(path) == "table" then
+-- for i=1,#path do
+-- add(path[i])
+-- end
+-- else
+-- add(path)
+-- end
+-- end
+-- end
+
+-- function package.extraclibpath(...)
+-- clibpaths = getclibpaths()
+-- local pathlist = { ... }
+-- local cleanpath = helpers.cleanpath
+-- local trace = helpers.trace
+-- local report = helpers.report
+-- --
+-- local function add(path)
+-- local path = cleanpath(path)
+-- if not clibhash[path] then
+-- if trace then
+-- report("! extra lib path: %s",path)
+-- end
+-- clibextras[#clibextras+1] = path
+-- clibpaths [#clibpaths +1] = path
+-- end
+-- end
+-- --
+-- for p=1,#pathlist do
+-- local path = pathlist[p]
+-- if type(path) == "table" then
+-- for i=1,#path do
+-- add(path[i])
+-- end
+-- else
+-- add(path)
+-- end
+-- end
+-- end
+
if not searchers[-2] then
-- use package-path and package-cpath
searchers[-2] = searchers[2]
@@ -254,15 +311,22 @@ searchers[2] = function(name)
return helpers.loaded(name)
end
+searchers[3] = nil -- get rid of the built in one
+
local function loadedaslib(resolved,rawname)
- return package.loadlib(resolved,"luaopen_" .. gsub(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)
+ end
+ return package.loadlib(resolved,init)
end
local function loadedbylua(name)
if helpers.trace then
helpers.report("! locating '%s' using normal loader",name)
end
- return searchers[-2](name)
+ return true, searchers[-2](name) -- the original
end
local function loadedbypath(name,rawname,paths,islib,what)
@@ -282,9 +346,9 @@ local function loadedbypath(name,rawname,paths,islib,what)
report("! lib '%s' located on '%s'",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true, loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true, loadfile(resolved)
end
end
end
@@ -301,15 +365,29 @@ helpers.loadedbylua = loadedbylua
helpers.loadedbypath = loadedbypath
helpers.notloaded = notloaded
+-- alternatively we could set the package.searchers
+
function helpers.loaded(name)
local thename = gsub(name,"%.","/")
local luaname = addsuffix(thename,"lua")
local libname = addsuffix(thename,os.libsuffix or "so") -- brrr
local libpaths = getlibpaths()
local clibpaths = getclibpaths()
- return loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done, result = loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done, result = loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done, result = loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done, result = loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
diff --git a/tex/context/base/luat-env.lua b/tex/context/base/luat-env.lua
index e741bca6a..8753972c6 100644
--- a/tex/context/base/luat-env.lua
+++ b/tex/context/base/luat-env.lua
@@ -35,6 +35,14 @@ local mt = {
else
return "unknown"
end
+ elseif k == "kind" then
+ local kind = tex.toks and tex.toks.contextkindtoks
+ if kind and kind ~= "" then
+ rawset(environment,"kind",kind)
+ return kind
+ else
+ return "unknown"
+ end
elseif k == "jobname" or k == "formatname" then
local name = tex and tex[k]
if name or name== "" then
diff --git a/tex/context/base/luat-lib.mkiv b/tex/context/base/luat-lib.mkiv
index 26596c157..a2ad4cac4 100644
--- a/tex/context/base/luat-lib.mkiv
+++ b/tex/context/base/luat-lib.mkiv
@@ -30,6 +30,7 @@
\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
diff --git a/tex/context/base/math-map.lua b/tex/context/base/math-map.lua
index 7772a981c..9a8c8a69c 100644
--- a/tex/context/base/math-map.lua
+++ b/tex/context/base/math-map.lua
@@ -105,8 +105,8 @@ registerotffeature {
-- fallbacks; symbols is currently mostly greek
local function todigit(n) local t = { } for i=0, 9 do t[0x00030+i] = n+i end return t end
-local function toupper(n) local t = { } for i=0,26 do t[0x00041+i] = n+i end return t end
-local function tolower(n) local t = { } for i=0,26 do t[0x00061+i] = n+i end return t end
+local function toupper(n) local t = { } for i=0,25 do t[0x00041+i] = n+i end return t end
+local function tolower(n) local t = { } for i=0,25 do t[0x00061+i] = n+i end return t end
local regular_tf = {
digits = todigit(0x00030),
diff --git a/tex/context/base/mult-ini.mkiv b/tex/context/base/mult-ini.mkiv
index 79b94f202..52f9255c8 100644
--- a/tex/context/base/mult-ini.mkiv
+++ b/tex/context/base/mult-ini.mkiv
@@ -819,7 +819,7 @@
\def\contextbanner
{ConTeXt \space
- ver: \contextversion \space \contextmark \space \space
+ ver: \contextversion \space \contextmark \space \contextkind \space \space
fmt: \formatversion \space \space
int: \currentinterface/\currentresponses}
diff --git a/tex/context/base/s-inf-01.mkvi b/tex/context/base/s-inf-01.mkvi
index 9d624c168..8263413ac 100644
--- a/tex/context/base/s-inf-01.mkvi
+++ b/tex/context/base/s-inf-01.mkvi
@@ -78,13 +78,18 @@
end
end
local data = io.loaddata(name)
- if suffix == "lua" then
- data = gsub(data,"%-%-%[%[.-%]%]%-%-","")
- data = gsub(data,"%-%-.-[\n\r]","")
+ if data then
+ if suffix == "lua" then
+ data = gsub(data,"%-%-%[%[.-%]%]%-%-","")
+ data = gsub(data,"%-%-.-[\n\r]","")
+ else
+ data = gsub(data,"%%.-[\n\r]","")
+ end
+ data = gsub(data,"%s","")
else
- data = gsub(data,"%%.-[\n\r]","")
+ logs.report("error","unknown file %a",name)
+ data = ""
end
- data = gsub(data,"%s","")
sm[n+5] = sm[n+5] + #data
if done then
sm[n] = sm[n] + #data
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 17e374e90..303deffba 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 ca5714750..ce82487af 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index 5f101e7d6..f08b2ec63 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -4724,6 +4724,12 @@ return {
},
{
category = "lua",
+ filename = "util-lib",
+ loading = "luat-lib",
+ status = "okay",
+ },
+ {
+ category = "lua",
filename = "util-mrg",
loading = "luat-lib",
status = "todo",
diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi
index 13de171dc..0f5b202b9 100644
--- a/tex/context/base/strc-con.mkvi
+++ b/tex/context/base/strc-con.mkvi
@@ -248,11 +248,19 @@
\constructionparameter\c!before
\begingroup
\edef\currentconstructionalternative{\constructionparameter\c!alternative}%
- % \checkconstructionalternativeparent % this catches an unknown alternative
\edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}%
- \doifnotsetups\p_strc_constructions_renderingsetup
- {\letconstructionparameter\c!alternative\v!left
- \let\currentconstructionalternative\v!left}%
+ % catch fuzzyness
+ \ifx\p_strc_constructions_renderingsetup\empty
+ \letconstructionparameter\c!alternative\v!left
+ \let\currentconstructionalternative\v!left
+ \edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}%
+ \else
+ \doifnotsetups\p_strc_constructions_renderingsetup
+ {\letconstructionparameter\c!alternative\v!left
+ \let\currentconstructionalternative\v!left
+ \edef\p_strc_constructions_renderingsetup{\constructionalternativeparameter\c!renderingsetup}}%
+ \fi
+ %
\doadaptleftskip{\constructionparameter\c!margin}%
\setlocalhsize % so we can use \localhsize in width assignments
\edef\p_strc_constructions_distance{\constructionalternativeparameter\c!distance}%
diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi
index a7cad42aa..324499b4e 100644
--- a/tex/context/base/strc-not.mkvi
+++ b/tex/context/base/strc-not.mkvi
@@ -1584,7 +1584,7 @@
\fi
\begingroup
\strc_notes_set_bodyfont
- \getvalue{\??notealternative\noteparameter\c!alternative}%
+ \csname\??notealternative\noteparameter\c!alternative\endcsname
\endgroup
\ifvmode
\noteparameter\c!after
diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua
index 9e724f9fa..ba37447a6 100644
--- a/tex/context/base/trac-deb.lua
+++ b/tex/context/base/trac-deb.lua
@@ -6,7 +6,8 @@ if not modules then modules = { } end modules ['trac-deb'] = {
license = "see context related readme files"
}
-local lpeg = lpeg
+local lpeg, status = lpeg, status
+
local lpegmatch = lpeg.match
local format, concat, match = string.format, table.concat, string.match
local tonumber, tostring = tonumber, tostring
diff --git a/tex/context/base/trac-tex.lua b/tex/context/base/trac-tex.lua
index 362a1dd67..7e3406073 100644
--- a/tex/context/base/trac-tex.lua
+++ b/tex/context/base/trac-tex.lua
@@ -58,6 +58,7 @@ local function saveusedfilesintrees(format)
local data = {
jobname = environment.jobname or "?",
version = environment.version or "?",
+ kind = environment.kind or "?",
files = resolvers.instance.foundintrees
}
local filename = file.replacesuffix(environment.jobname or "context-job",'jlg')
diff --git a/tex/context/base/util-lib.lua b/tex/context/base/util-lib.lua
new file mode 100644
index 000000000..c987bdde3
--- /dev/null
+++ b/tex/context/base/util-lib.lua
@@ -0,0 +1,146 @@
+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",
+}
+
+-- This is experimental code for Hans and Luigi. Don't depend on it! There
+-- will be a plain variant.
+
+--[[
+
+The problem with library bindings is manyfold. They are of course platform
+dependent and while a binary with its directly related libraries are often
+easy to maintain and load, additional libraries can each have their demands.
+
+One important aspect is that loading additional libraries from within the
+loaded one is also operating system dependent. There can be shared libraries
+elsewhere on the system and as there can be multiple libraries with the same
+name but different usage and versioning there can be clashes. So there has to
+be some logic in where to look for these sublibraries.
+
+We found out that for instance on windows libraries are by default sought on
+the parents path and then on the binary paths and these of course can be in
+an out of our control, thereby enlarging the changes on a clash. A rather
+safe solution for that to load the library on the path where it sits.
+
+Another aspect is initialization. When you ask for a library t.e.x it will
+try to initialize luaopen_t_e_x no matter if such an inializer is present.
+However, because loading is configurable and in the case of luatex is already
+partly under out control, this is easy to deal with. We only have to make
+sure that we inform the loader that the library has been loaded so that
+it won't load it twice.
+
+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
+
+]]--
+
+local savedrequire = require
+local loaded = package.loaded
+local gsub, find = string.gsub, string.find
+
+--[[
+
+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
+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.
+
+]]--
+
+local function requireswiglib(required)
+ 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)
+ 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)
+ if type(library) == "function" then
+ library = library()
+ else
+ -- some error
+ end
+ -- end
+ dir.pop()
+ loaded[required] = library
+ end
+ return library
+end
+
+--[[
+
+For convenience we make the require loader function swiglib aware. Alternatively
+we could put the specific loader in the global namespace.
+
+]]--
+
+function require(name,...) -- this might disappear or change
+ if find(name,"^swiglib%.") then
+ return requireswiglib(name,...)
+ else
+ 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.
+
+]]--
+
+local report_swiglib = logs.reporter("swiglib")
+
+local swiglibs = { }
+
+function swiglib(name)
+ local library = swiglibs[name]
+ if not library then
+ statistics.starttiming(swiglibs)
+ report_swiglib("loading %a",name)
+ library = requireswiglib("swiglib." .. name)
+ 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)
+
+--[[
+
+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
+
+Watch out, the last one is less explicit and lacks the swiglib prefix.
+
+]]--
diff --git a/tex/context/base/util-sto.lua b/tex/context/base/util-sto.lua
index ddf699bca..191d6cd73 100644
--- a/tex/context/base/util-sto.lua
+++ b/tex/context/base/util-sto.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['util-sto'] = {
license = "see context related readme files"
}
-local setmetatable, getmetatable = setmetatable, getmetatable
+local setmetatable, getmetatable, type = setmetatable, getmetatable, type
utilities = utilities or { }
utilities.storage = utilities.storage or { }
@@ -111,6 +111,9 @@ local t_table = { __index = f_table }
local t_ignore = { __newindex = f_ignore }
function table.setmetatableindex(t,f)
+ if type(t) ~= "table" then
+ f, t = t, { }
+ end
local m = getmetatable(t)
if m then
if f == "empty" then
@@ -137,6 +140,9 @@ function table.setmetatableindex(t,f)
end
function table.setmetatablenewindex(t,f)
+ if type(t) ~= "table" then
+ f, t = t, { }
+ end
local m = getmetatable(t)
if m then
if f == "ignore" then
@@ -155,6 +161,9 @@ function table.setmetatablenewindex(t,f)
end
function table.setmetatablecall(t,f)
+ if type(t) ~= "table" then
+ f, t = t, { }
+ end
local m = getmetatable(t)
if m then
m.__call = f
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index a6a0a2e87..a7b4d64ee 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 : 03/29/13 01:03:45
+-- merge date : 04/01/13 14:16:57
do -- begin closure to overcome local limits and interference
@@ -82,6 +82,7 @@ function optionalrequire(...)
return result
end
end
+local type=type
local gsub,format=string.gsub,string.format
local package=package
local searchers=package.searchers or package.loaders
@@ -113,45 +114,38 @@ local function getclibpaths()
end
package.libpaths=getlibpaths
package.clibpaths=getclibpaths
-function package.extralibpath(...)
- libpaths=getlibpaths()
+local function addpath(what,paths,extras,hash,...)
local pathlist={... }
local cleanpath=helpers.cleanpath
local trace=helpers.trace
local report=helpers.report
- for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not libhash[path] then
- if trace then
- report("! extra lua path: %s",path)
- end
- libextras[#libextras+1]=path
- libpaths [#libpaths+1]=path
+ local function add(path)
+ local path=cleanpath(path)
+ if not hash[path] then
+ if trace then
+ report("! extra %s path: %s",what,path)
end
+ paths [#paths+1]=path
+ extras[#extras+1]=path
end
end
-end
-function package.extraclibpath(...)
- clibpaths=getclibpaths()
- local pathlist={... }
- local cleanpath=helpers.cleanpath
- local trace=helpers.trace
- local report=helpers.report
for p=1,#pathlist do
- local paths=pathlist[p]
- for i=1,#paths do
- local path=cleanpath(paths[i])
- if not clibhash[path] then
- if trace then
- report("! extra lib path: %s",path)
- end
- clibextras[#clibextras+1]=path
- clibpaths [#clibpaths+1]=path
+ local path=pathlist[p]
+ if type(path)=="table" then
+ for i=1,#path do
+ add(path[i])
end
+ else
+ add(path)
end
end
+ return paths,extras
+end
+function package.extralibpath(...)
+ libpaths,libextras=addpath("lua",getlibpaths(),libextras,libhash,...)
+end
+function package.extraclibpath(...)
+ clibpaths,clibextras=addpath("lib",getclibpaths(),clibextras,clibhash,...)
end
if not searchers[-2] then
searchers[-2]=searchers[2]
@@ -159,14 +153,19 @@ end
searchers[2]=function(name)
return helpers.loaded(name)
end
+searchers[3]=nil
local function loadedaslib(resolved,rawname)
- return package.loadlib(resolved,"luaopen_"..gsub(rawname,"%.","_"))
+ local init="luaopen_"..gsub(rawname,"%.","_")
+ if helpers.trace then
+ 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)
end
- return searchers[-2](name)
+ return true,searchers[-2](name)
end
local function loadedbypath(name,rawname,paths,islib,what)
local trace=helpers.trace
@@ -185,9 +184,9 @@ local function loadedbypath(name,rawname,paths,islib,what)
report("! lib '%s' located on '%s'",name,resolved)
end
if islib then
- return loadedaslib(resolved,rawname)
+ return true,loadedaslib(resolved,rawname)
else
- return loadfile(resolved)
+ return true,loadfile(resolved)
end
end
end
@@ -207,11 +206,23 @@ function helpers.loaded(name)
local libname=addsuffix(thename,os.libsuffix or "so")
local libpaths=getlibpaths()
local clibpaths=getclibpaths()
- return loadedbypath(luaname,name,libpaths,false,"lua")
- or loadedbypath(luaname,name,clibpaths,false,"lua")
- or loadedbypath(libname,name,clibpaths,true,"lib")
- or loadedbylua(name)
- or notloaded(name)
+ local done,result=loadedbypath(luaname,name,libpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(luaname,name,clibpaths,false,"lua")
+ if done then
+ return result
+ end
+ local done,result=loadedbypath(libname,name,clibpaths,true,"lib")
+ if done then
+ return result
+ end
+ local done,result=loadedbylua(name)
+ if done then
+ return result
+ end
+ return notloaded(name)
end
end -- closure
@@ -10780,6 +10791,9 @@ function definers.read(specification,size,id)
statistics.stoptiming(fonts)
return tfmdata
end
+function font.getfont(id)
+ return fontdata[id]
+end
callbacks.register('define_font',definers.read,"definition of fonts (tfmdata preparation)")
end -- closure
diff --git a/tex/generic/context/luatex/luatex-languages.lua b/tex/generic/context/luatex/luatex-languages.lua
index 712118dbc..1ea8c1fd1 100644
--- a/tex/generic/context/luatex/luatex-languages.lua
+++ b/tex/generic/context/luatex/luatex-languages.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['luatex-languages'] = {
license = "see context related readme files"
}
--- We borrow fron ConTeXt.
+-- We borrow from ConTeXt.
languages = languages or { }