From 14fbfde2ad32d2fe4a831aa9007877e5cb5764be Mon Sep 17 00:00:00 2001
From: Hans Hagen 
Date: Thu, 9 Aug 2007 13:04:00 +0200
Subject: stable 2007.08.09 13:04
---
 scripts/context/lua/luatools.lua  | 138 ++++++++++++++++++-------------------
 scripts/context/lua/mtxrun.lua    | 140 +++++++++++++++++++-------------------
 tex/context/base/char-utf.lua     |  23 ++++---
 tex/context/base/cont-new.tex     |   2 +-
 tex/context/base/context.tex      |   2 +-
 tex/context/base/font-def.lua     |  34 ++++++---
 tex/context/base/font-ini.lua     |   3 +-
 tex/context/base/font-tfm.lua     |  27 +++++++-
 tex/context/base/luat-inp.lua     | 138 ++++++++++++++++++-------------------
 tex/context/base/meta-ini.tex     |   6 ++
 tex/context/base/type-ghz.tex     |  32 ++++-----
 tex/context/interface/keys-cz.xml |   2 +-
 tex/context/interface/keys-de.xml |   2 +-
 tex/context/interface/keys-en.xml |   2 +-
 tex/context/interface/keys-fr.xml |   2 +-
 tex/context/interface/keys-it.xml |   2 +-
 tex/context/interface/keys-nl.xml |   2 +-
 tex/context/interface/keys-ro.xml |   2 +-
 18 files changed, 302 insertions(+), 257 deletions(-)
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua
index e46337223..cd7ee1ed5 100644
--- a/scripts/context/lua/luatools.lua
+++ b/scripts/context/lua/luatools.lua
@@ -1774,6 +1774,8 @@ end
 
 -- Beware, loading and saving is overloaded in luat-tmp!
 
+-- todo: instances.[hashes,cnffiles,configurations,522] -> ipairs (alles check, sneller)
+
 if not versions    then versions    = { } end versions['luat-inp'] = 1.001
 if not environment then environment = { } end
 if not file        then file        = { } end
@@ -1881,6 +1883,7 @@ function input.reset()
     instance.files           = { }
     instance.remap           = { }
     instance.configuration   = { }
+    instance.order           = { }
     instance.found           = { }
     instance.foundintrees    = { }
     instance.kpsevars        = { }
@@ -2135,14 +2138,14 @@ function input.load_cnf(instance)
 end
 
 function input.loadconfigdata(instance)
-    for _, fname in pairs(instance.cnffiles) do
+    for _, fname in ipairs(instance.cnffiles) do
         input.aux.load_cnf(instance,fname)
     end
 end
 
 if os.env then
     function input.aux.collapse_cnf_data(instance)
-        for _,c in pairs(instance.configuration) do
+        for _,c in ipairs(instance.order) do
             for k,v in pairs(c) do
                 if not instance.variables[k] then
                     if instance.environment[k] then
@@ -2157,7 +2160,7 @@ if os.env then
     end
 else
     function input.aux.collapse_cnf_data(instance)
-        for _,c in pairs(instance.configuration) do
+        for _,c in ipairs(instance.order) do
             for k,v in pairs(c) do
                 if not instance.variables[k] then
                     local e = os.getenv(k)
@@ -2180,7 +2183,11 @@ function input.aux.load_cnf(instance,fname)
     local f = io.open(lname)
     if f then
         f:close()
-        input.aux.load_data(instance,file.dirname(lname),'configuration',file.basename(lname))
+        local dname = file.dirname(fname)
+        if not instance.configuration[dname] then
+            input.aux.load_data(instance,dname,'configuration',file.basename(lname))
+            instance.order[#instance.order+1] = instance.configuration[dname]
+        end
     else
         f = io.open(fname)
         if f then
@@ -2189,6 +2196,7 @@ function input.aux.load_cnf(instance,fname)
             local dname = file.dirname(fname)
             if not instance.configuration[dname] then
                 instance.configuration[dname] = { }
+                instance.order[#instance.order+1] = instance.configuration[dname]
             end
             local data = instance.configuration[dname]
             while true do
@@ -2344,7 +2352,7 @@ function input.generators.tex(instance,specification)
         input.report("scanning path",specification)
         instance.files[tag] = { }
         local files = instance.files[tag]
-        local n, m = 0, 0
+        local n, m, r = 0, 0, 0
         local spec = specification .. '/'
         local attributes = lfs.attributes
         local directory = lfs.dir
@@ -2384,6 +2392,7 @@ function input.generators.tex(instance,specification)
                             local lower = name:lower()
                             if name ~= lower then
                                 files["remap:"..lower] = name
+                                r = r + 1
                             end
                         end
                     end
@@ -2391,7 +2400,7 @@ function input.generators.tex(instance,specification)
             end
         end
         action()
-        input.report(n,"files found on",m,"directories")
+        input.report(string.format("%s files found on %s directories with %s uppercase remappings",n,m,r))
     else
         local fullname = file.join(specification,input.lsrname)
         local path     = '.'
@@ -2442,7 +2451,7 @@ end
 -- is more convenient.
 
 function input.splitconfig(instance)
-    for i,c in pairs(instance.configuration) do
+    for i,c in ipairs(instance.order) do
         for k,v in pairs(c) do
             if type(v) == 'string' then
                 local t = file.split_path(v)
@@ -2454,7 +2463,7 @@ function input.splitconfig(instance)
     end
 end
 function input.joinconfig(instance)
-    for i,c in pairs(instance.configuration) do
+    for i,c in ipairs(instance.order) do
         for k,v in pairs(c) do
             if type(v) == 'table' then
                 c[k] = file.join_path(v)
@@ -2567,10 +2576,12 @@ function input.aux.save_data(instance, dataname, check)
 end
 
 function input.loadconfig(instance)
-    instance.configuration, instance.loaderror = { }, false
+    instance.configuration, instance.order, instance.loaderror = { }, { }, false
     if not instance.renewcache then
-        for _, cnf in pairs(instance.cnffiles) do
-            input.aux.load_data(instance,file.dirname(cnf),'configuration')
+        for _, cnf in ipairs(instance.cnffiles) do
+            local dname = file.dirname(cnf)
+            input.aux.load_data(instance,dname,'configuration')
+            instance.order[#instance.order+1] = instance.configuration[dname]
             if instance.loaderror then break end
         end
     end
@@ -2726,7 +2737,7 @@ function input.list_configurations(instance)
     for _,key in pairs(table.sortedkeys(instance.kpsevars)) do
         if not instance.pattern or (instance.pattern=="") or key:find(instance.pattern) then
             print(key.."\n")
-            for i,c in pairs(instance.configuration) do
+            for i,c in ipairs(instance.order) do
                 local str = c[key]
                 if str then
                     print("\t" .. i .. "\t\t" .. input.aux.tabstr(str))
@@ -2879,8 +2890,7 @@ function input.aux.expanded_path(instance,pathlist)
                     local pre, mid, post = v:match(pattern)
                     if pre and mid and post then
                         more = true
---~                         for vv in string.gmatch(mid..',',"(.-),") do
-                        for vv in string.gmatch(mid,"([^,]+)") do
+                        for vv in string.gmatch(mid..',',"(.-),") do
                             if vv == '.' then
                                 t[#t+1] = pre..post
                             else
@@ -2895,13 +2905,12 @@ function input.aux.expanded_path(instance,pathlist)
                 if not more then break end
             end
         end
-        for _,v in pairs(oldlist) do
+        for _,v in ipairs(oldlist) do
             v = file.collapse_path(v)
             if v ~= "" and not v:find(instance.dummy_path_expr) then newlist[#newlist+1] = v end
         end
     else
-        for _,v in pairs(pathlist) do
-         -- for _,vv in pairs(v:split(",")) do
+        for _,v in ipairs(pathlist) do
             for vv in string.gmatch(v..',',"(.-),") do
                 vv = file.collapse_path(v)
                 if vv ~= "" then newlist[#newlist+1] = vv end
@@ -2952,7 +2961,7 @@ function input.aux.collect_files(instance,names)
             else
                 dname = "/" .. dname .. "$"
             end
-            for _, hash in pairs(instance.hashes) do
+            for _, hash in ipairs(instance.hashes) do
                 local blobpath = hash.tag
                 local files = blobpath and instance.files[blobpath]
                 if files then
@@ -3086,15 +3095,15 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
         local filetype, extra, done, wantedfiles, ext = '', nil, false, { }, file.extname(filename)
         if ext == "" then
             if not instance.force_suffixes then
-                table.insert(wantedfiles, filename)
+                wantedfiles[#wantedfiles+1] = filename
             end
         else
-            table.insert(wantedfiles, filename)
+            wantedfiles[#wantedfiles+1] = filename
         end
         if instance.format == "" then
             if ext == "" then
                 local forcedname = filename .. '.tex'
-                table.insert(wantedfiles, forcedname)
+                wantedfiles[#wantedfiles+1] = forcedname
                 filetype = input.format_of_suffix(forcedname)
                 input.logger('! forcing filetype',filetype)
             else
@@ -3104,7 +3113,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
         else
             if ext == "" then
                 for _, s in pairs(input.suffixes_of_format(instance.format)) do
-                    table.insert(wantedfiles, filename .. "." .. s)
+                    wantedfiles[#wantedfiles+1] = filename .. "." .. s
                 end
             end
             filetype = instance.format
@@ -3122,7 +3131,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
             for _, fname in pairs(wantedfiles) do
                 if fname and input.is_readable.file(fname) then
                     filename, done = fname, true
-                    table.insert(result, file.join('.',fname))
+                    result[#result+1] = file.join('.',fname)
                     break
                 end
             end
@@ -3130,7 +3139,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
             local filelist = input.aux.collect_files(instance,wantedfiles)
             filename = filelist and filelist[1]
             if filename then
-                table.insert(result, filename)
+                result[#result+1] = filename
                 done = true
             end
         else
@@ -3162,7 +3171,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
                             if input.trace > 2 then
                                 input.logger('= found in hash',f)
                             end
-                            table.insert(result,f)
+                            result[#result+1] = f
                             input.aux.register_in_trees(instance,f) -- for tracing used files
                             done = true
                             if not instance.allresults then break end
@@ -3184,7 +3193,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
                                         if input.trace > 2 then
                                             input.logger('= found by scanning',fname)
                                         end
-                                        table.insert(result,fname)
+                                        result[#result+1] = fname
                                         done = true
                                         if not instance.allresults then break end
                                     end
@@ -3275,15 +3284,23 @@ end
 
 function input.find_given_files(instance,filename)
     local bname, result = file.basename(filename), { }
-    for k, hash in pairs(instance.hashes) do
+    for k, hash in ipairs(instance.hashes) do
         local blist = instance.files[hash.tag][bname]
+        if not blist then
+            local rname = "remap:"..bname
+            blist = files[rname]
+            if blist then
+                bname = files[rname]
+                blist = files[bname]
+            end
+        end
         if blist then
             if type(blist) == 'string' then
-                table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
+                result[#result+1] = input.concatinators[hash.type](hash.tag,blist,bname) or ""
                 if not instance.allresults then break end
             else
                 for kk,vv in pairs(blist) do
-                    table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
+                    result[#result+1] = input.concatinators[hash.type](hash.tag,vv,bname) or ""
                     if not instance.allresults then break end
                 end
             end
@@ -3296,35 +3313,7 @@ function input.find_given_file(instance,filename)
     return (input.find_given_files(instance,filename)[1] or "")
 end
 
---~ function input.find_wildcard_files(instance,filename)
---~     local result = { }
---~     local bname, dname = file.basename(filename), file.dirname(filename)
---~     local expr = dname:gsub("^*/","")
---~     expr = expr:gsub("*",".*")
---~     expr = expr:gsub("-","%-")
---~     for k, hash in pairs(instance.hashes) do
---~         local blist = instance.files[hash.tag][bname]
---~         if blist then
---~             if type(blist) == 'string' then
---~                 -- make function and share code
---~                 if blist:find(expr) then
---~                     table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
---~                     if not instance.allresults then break end
---~                 end
---~             else
---~                 for kk,vv in pairs(blist) do
---~                     if vv:find(expr) then
---~                         table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
---~                         if not instance.allresults then break end
---~                     end
---~                 end
---~             end
---~         end
---~     end
---~     return result
---~ end
-
-function input.find_wildcard_files(instance,filename)
+function input.find_wildcard_files(instance,filename) -- todo: remap:
     local result = { }
     local bname, dname = file.basename(filename), file.dirname(filename)
     local path = dname:gsub("^*/","")
@@ -3344,13 +3333,13 @@ function input.find_wildcard_files(instance,filename)
             if type(blist) == 'string' then
                 -- make function and share code
                 if (blist:lower()):find(path) then
-                    table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
+                    result[#result+1] = input.concatinators[hash.type](hash.tag,blist,bname) or ""
                     done = true
                 end
             else
                 for kk,vv in pairs(blist) do
                     if (vv:lower()):find(path) then
-                        table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
+                        result[#result+1] = input.concatinators[hash.type](hash.tag,vv,bname) or ""
                         done = true
                         if not allresults then break end
                     end
@@ -3361,7 +3350,7 @@ function input.find_wildcard_files(instance,filename)
     end
     local files, allresults, done = instance.files, instance.allresults, false
     if name:find("%*") then
-        for k, hash in pairs(instance.hashes) do
+        for k, hash in ipairs(instance.hashes) do
             for kk, hh in pairs(files[hash.tag]) do
                 if (kk:lower()):find(name) then
                     if doit(hh,kk,hash,allresults) then done = true end
@@ -3370,7 +3359,7 @@ function input.find_wildcard_files(instance,filename)
             end
         end
     else
-        for k, hash in pairs(instance.hashes) do
+        for k, hash in ipairs(instance.hashes) do
             if doit(files[hash.tag][bname],bname,hash,allresults) then done = true end
             if done and not allresults then break end
         end
@@ -3610,17 +3599,24 @@ function input.do_with_var(name,func)
 end
 
 function input.with_files(instance,pattern,handle)
-    for _, hash in pairs(instance.hashes) do
+    for _, hash in ipairs(instance.hashes) do
         local blobpath = hash.tag
         local blobtype = hash.type
-        if blobpath and instance.files[blobpath] then -- sort them?
-            for k,v in pairs(instance.files[blobpath]) do
-                if k:find(pattern) then
-                    if type(v) == "string" then
-                        handle(blobtype,blobpath,v,k)
-                    else
-                        for _,vv in pairs(v) do
-                            handle(blobtype,blobpath,vv,k)
+        if blobpath then
+            local files = instance.files[blobpath]
+            if files then
+                for k,v in pairs(files) do
+                    if k:find("^remap:") then
+                        k = files[k]
+                        v = files[k] -- chained
+                    end
+                    if k:find(pattern) then
+                        if type(v) == "string" then
+                            handle(blobtype,blobpath,v,k)
+                        else
+                            for _,vv in pairs(v) do
+                                handle(blobtype,blobpath,vv,k)
+                            end
                         end
                     end
                 end
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index caaca8d30..18dc95ff3 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -1630,6 +1630,8 @@ end
 
 -- Beware, loading and saving is overloaded in luat-tmp!
 
+-- todo: instances.[hashes,cnffiles,configurations,522] -> ipairs (alles check, sneller)
+
 if not versions    then versions    = { } end versions['luat-inp'] = 1.001
 if not environment then environment = { } end
 if not file        then file        = { } end
@@ -1737,6 +1739,7 @@ function input.reset()
     instance.files           = { }
     instance.remap           = { }
     instance.configuration   = { }
+    instance.order           = { }
     instance.found           = { }
     instance.foundintrees    = { }
     instance.kpsevars        = { }
@@ -1991,14 +1994,14 @@ function input.load_cnf(instance)
 end
 
 function input.loadconfigdata(instance)
-    for _, fname in pairs(instance.cnffiles) do
+    for _, fname in ipairs(instance.cnffiles) do
         input.aux.load_cnf(instance,fname)
     end
 end
 
 if os.env then
     function input.aux.collapse_cnf_data(instance)
-        for _,c in pairs(instance.configuration) do
+        for _,c in ipairs(instance.order) do
             for k,v in pairs(c) do
                 if not instance.variables[k] then
                     if instance.environment[k] then
@@ -2013,7 +2016,7 @@ if os.env then
     end
 else
     function input.aux.collapse_cnf_data(instance)
-        for _,c in pairs(instance.configuration) do
+        for _,c in ipairs(instance.order) do
             for k,v in pairs(c) do
                 if not instance.variables[k] then
                     local e = os.getenv(k)
@@ -2036,7 +2039,11 @@ function input.aux.load_cnf(instance,fname)
     local f = io.open(lname)
     if f then
         f:close()
-        input.aux.load_data(instance,file.dirname(lname),'configuration',file.basename(lname))
+        local dname = file.dirname(fname)
+        if not instance.configuration[dname] then
+            input.aux.load_data(instance,dname,'configuration',file.basename(lname))
+            instance.order[#instance.order+1] = instance.configuration[dname]
+        end
     else
         f = io.open(fname)
         if f then
@@ -2045,6 +2052,7 @@ function input.aux.load_cnf(instance,fname)
             local dname = file.dirname(fname)
             if not instance.configuration[dname] then
                 instance.configuration[dname] = { }
+                instance.order[#instance.order+1] = instance.configuration[dname]
             end
             local data = instance.configuration[dname]
             while true do
@@ -2200,7 +2208,7 @@ function input.generators.tex(instance,specification)
         input.report("scanning path",specification)
         instance.files[tag] = { }
         local files = instance.files[tag]
-        local n, m = 0, 0
+        local n, m, r = 0, 0, 0
         local spec = specification .. '/'
         local attributes = lfs.attributes
         local directory = lfs.dir
@@ -2240,6 +2248,7 @@ function input.generators.tex(instance,specification)
                             local lower = name:lower()
                             if name ~= lower then
                                 files["remap:"..lower] = name
+                                r = r + 1
                             end
                         end
                     end
@@ -2247,7 +2256,7 @@ function input.generators.tex(instance,specification)
             end
         end
         action()
-        input.report(n,"files found on",m,"directories")
+        input.report(string.format("%s files found on %s directories with %s uppercase remappings",n,m,r))
     else
         local fullname = file.join(specification,input.lsrname)
         local path     = '.'
@@ -2298,7 +2307,7 @@ end
 -- is more convenient.
 
 function input.splitconfig(instance)
-    for i,c in pairs(instance.configuration) do
+    for i,c in ipairs(instance.order) do
         for k,v in pairs(c) do
             if type(v) == 'string' then
                 local t = file.split_path(v)
@@ -2310,7 +2319,7 @@ function input.splitconfig(instance)
     end
 end
 function input.joinconfig(instance)
-    for i,c in pairs(instance.configuration) do
+    for i,c in ipairs(instance.order) do
         for k,v in pairs(c) do
             if type(v) == 'table' then
                 c[k] = file.join_path(v)
@@ -2423,10 +2432,12 @@ function input.aux.save_data(instance, dataname, check)
 end
 
 function input.loadconfig(instance)
-    instance.configuration, instance.loaderror = { }, false
+    instance.configuration, instance.order, instance.loaderror = { }, { }, false
     if not instance.renewcache then
-        for _, cnf in pairs(instance.cnffiles) do
-            input.aux.load_data(instance,file.dirname(cnf),'configuration')
+        for _, cnf in ipairs(instance.cnffiles) do
+            local dname = file.dirname(cnf)
+            input.aux.load_data(instance,dname,'configuration')
+            instance.order[#instance.order+1] = instance.configuration[dname]
             if instance.loaderror then break end
         end
     end
@@ -2582,7 +2593,7 @@ function input.list_configurations(instance)
     for _,key in pairs(table.sortedkeys(instance.kpsevars)) do
         if not instance.pattern or (instance.pattern=="") or key:find(instance.pattern) then
             print(key.."\n")
-            for i,c in pairs(instance.configuration) do
+            for i,c in ipairs(instance.order) do
                 local str = c[key]
                 if str then
                     print("\t" .. i .. "\t\t" .. input.aux.tabstr(str))
@@ -2735,8 +2746,7 @@ function input.aux.expanded_path(instance,pathlist)
                     local pre, mid, post = v:match(pattern)
                     if pre and mid and post then
                         more = true
---~                         for vv in string.gmatch(mid..',',"(.-),") do
-                        for vv in string.gmatch(mid,"([^,]+)") do
+                        for vv in string.gmatch(mid..',',"(.-),") do
                             if vv == '.' then
                                 t[#t+1] = pre..post
                             else
@@ -2751,13 +2761,12 @@ function input.aux.expanded_path(instance,pathlist)
                 if not more then break end
             end
         end
-        for _,v in pairs(oldlist) do
+        for _,v in ipairs(oldlist) do
             v = file.collapse_path(v)
             if v ~= "" and not v:find(instance.dummy_path_expr) then newlist[#newlist+1] = v end
         end
     else
-        for _,v in pairs(pathlist) do
-         -- for _,vv in pairs(v:split(",")) do
+        for _,v in ipairs(pathlist) do
             for vv in string.gmatch(v..',',"(.-),") do
                 vv = file.collapse_path(v)
                 if vv ~= "" then newlist[#newlist+1] = vv end
@@ -2808,7 +2817,7 @@ function input.aux.collect_files(instance,names)
             else
                 dname = "/" .. dname .. "$"
             end
-            for _, hash in pairs(instance.hashes) do
+            for _, hash in ipairs(instance.hashes) do
                 local blobpath = hash.tag
                 local files = blobpath and instance.files[blobpath]
                 if files then
@@ -2942,15 +2951,15 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
         local filetype, extra, done, wantedfiles, ext = '', nil, false, { }, file.extname(filename)
         if ext == "" then
             if not instance.force_suffixes then
-                table.insert(wantedfiles, filename)
+                wantedfiles[#wantedfiles+1] = filename
             end
         else
-            table.insert(wantedfiles, filename)
+            wantedfiles[#wantedfiles+1] = filename
         end
         if instance.format == "" then
             if ext == "" then
                 local forcedname = filename .. '.tex'
-                table.insert(wantedfiles, forcedname)
+                wantedfiles[#wantedfiles+1] = forcedname
                 filetype = input.format_of_suffix(forcedname)
                 input.logger('! forcing filetype',filetype)
             else
@@ -2960,7 +2969,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
         else
             if ext == "" then
                 for _, s in pairs(input.suffixes_of_format(instance.format)) do
-                    table.insert(wantedfiles, filename .. "." .. s)
+                    wantedfiles[#wantedfiles+1] = filename .. "." .. s
                 end
             end
             filetype = instance.format
@@ -2978,7 +2987,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
             for _, fname in pairs(wantedfiles) do
                 if fname and input.is_readable.file(fname) then
                     filename, done = fname, true
-                    table.insert(result, file.join('.',fname))
+                    result[#result+1] = file.join('.',fname)
                     break
                 end
             end
@@ -2986,7 +2995,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
             local filelist = input.aux.collect_files(instance,wantedfiles)
             filename = filelist and filelist[1]
             if filename then
-                table.insert(result, filename)
+                result[#result+1] = filename
                 done = true
             end
         else
@@ -3018,7 +3027,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
                             if input.trace > 2 then
                                 input.logger('= found in hash',f)
                             end
-                            table.insert(result,f)
+                            result[#result+1] = f
                             input.aux.register_in_trees(instance,f) -- for tracing used files
                             done = true
                             if not instance.allresults then break end
@@ -3040,7 +3049,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
                                         if input.trace > 2 then
                                             input.logger('= found by scanning',fname)
                                         end
-                                        table.insert(result,fname)
+                                        result[#result+1] = fname
                                         done = true
                                         if not instance.allresults then break end
                                     end
@@ -3131,15 +3140,23 @@ end
 
 function input.find_given_files(instance,filename)
     local bname, result = file.basename(filename), { }
-    for k, hash in pairs(instance.hashes) do
+    for k, hash in ipairs(instance.hashes) do
         local blist = instance.files[hash.tag][bname]
+        if not blist then
+            local rname = "remap:"..bname
+            blist = files[rname]
+            if blist then
+                bname = files[rname]
+                blist = files[bname]
+            end
+        end
         if blist then
             if type(blist) == 'string' then
-                table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
+                result[#result+1] = input.concatinators[hash.type](hash.tag,blist,bname) or ""
                 if not instance.allresults then break end
             else
                 for kk,vv in pairs(blist) do
-                    table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
+                    result[#result+1] = input.concatinators[hash.type](hash.tag,vv,bname) or ""
                     if not instance.allresults then break end
                 end
             end
@@ -3152,35 +3169,7 @@ function input.find_given_file(instance,filename)
     return (input.find_given_files(instance,filename)[1] or "")
 end
 
---~ function input.find_wildcard_files(instance,filename)
---~     local result = { }
---~     local bname, dname = file.basename(filename), file.dirname(filename)
---~     local expr = dname:gsub("^*/","")
---~     expr = expr:gsub("*",".*")
---~     expr = expr:gsub("-","%-")
---~     for k, hash in pairs(instance.hashes) do
---~         local blist = instance.files[hash.tag][bname]
---~         if blist then
---~             if type(blist) == 'string' then
---~                 -- make function and share code
---~                 if blist:find(expr) then
---~                     table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
---~                     if not instance.allresults then break end
---~                 end
---~             else
---~                 for kk,vv in pairs(blist) do
---~                     if vv:find(expr) then
---~                         table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
---~                         if not instance.allresults then break end
---~                     end
---~                 end
---~             end
---~         end
---~     end
---~     return result
---~ end
-
-function input.find_wildcard_files(instance,filename)
+function input.find_wildcard_files(instance,filename) -- todo: remap:
     local result = { }
     local bname, dname = file.basename(filename), file.dirname(filename)
     local path = dname:gsub("^*/","")
@@ -3200,13 +3189,13 @@ function input.find_wildcard_files(instance,filename)
             if type(blist) == 'string' then
                 -- make function and share code
                 if (blist:lower()):find(path) then
-                    table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
+                    result[#result+1] = input.concatinators[hash.type](hash.tag,blist,bname) or ""
                     done = true
                 end
             else
                 for kk,vv in pairs(blist) do
                     if (vv:lower()):find(path) then
-                        table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
+                        result[#result+1] = input.concatinators[hash.type](hash.tag,vv,bname) or ""
                         done = true
                         if not allresults then break end
                     end
@@ -3217,7 +3206,7 @@ function input.find_wildcard_files(instance,filename)
     end
     local files, allresults, done = instance.files, instance.allresults, false
     if name:find("%*") then
-        for k, hash in pairs(instance.hashes) do
+        for k, hash in ipairs(instance.hashes) do
             for kk, hh in pairs(files[hash.tag]) do
                 if (kk:lower()):find(name) then
                     if doit(hh,kk,hash,allresults) then done = true end
@@ -3226,7 +3215,7 @@ function input.find_wildcard_files(instance,filename)
             end
         end
     else
-        for k, hash in pairs(instance.hashes) do
+        for k, hash in ipairs(instance.hashes) do
             if doit(files[hash.tag][bname],bname,hash,allresults) then done = true end
             if done and not allresults then break end
         end
@@ -3466,17 +3455,24 @@ function input.do_with_var(name,func)
 end
 
 function input.with_files(instance,pattern,handle)
-    for _, hash in pairs(instance.hashes) do
+    for _, hash in ipairs(instance.hashes) do
         local blobpath = hash.tag
         local blobtype = hash.type
-        if blobpath and instance.files[blobpath] then -- sort them?
-            for k,v in pairs(instance.files[blobpath]) do
-                if k:find(pattern) then
-                    if type(v) == "string" then
-                        handle(blobtype,blobpath,v,k)
-                    else
-                        for _,vv in pairs(v) do
-                            handle(blobtype,blobpath,vv,k)
+        if blobpath then
+            local files = instance.files[blobpath]
+            if files then
+                for k,v in pairs(files) do
+                    if k:find("^remap:") then
+                        k = files[k]
+                        v = files[k] -- chained
+                    end
+                    if k:find(pattern) then
+                        if type(v) == "string" then
+                            handle(blobtype,blobpath,v,k)
+                        else
+                            for _,vv in pairs(v) do
+                                handle(blobtype,blobpath,vv,k)
+                            end
                         end
                     end
                 end
@@ -4577,6 +4573,8 @@ function input.runners.execute_ctx_script(instance,filename)
             return true
         end
     else
+        input.verbose = true
+        input.report("unknown script: " .. filename)
         return false
     end
 end
diff --git a/tex/context/base/char-utf.lua b/tex/context/base/char-utf.lua
index c30a160bc..79f5718fd 100644
--- a/tex/context/base/char-utf.lua
+++ b/tex/context/base/char-utf.lua
@@ -127,7 +127,7 @@ do
         ug("(.)", cfup.high)
     end
 
-    for _, ch in pairs({ '~', '#', '$', '%', '^', '&', '_', '{', '}' }) do
+    for _, ch in ipairs({ '~', '#', '$', '%', '^', '&', '_', '{', '}' }) do
         cfup.set(ch)
     end
 
@@ -200,10 +200,12 @@ callback.register('process_input_buffer', characters.filters.process)
 
 
 The following helper functions may disappear (or become optional)
-in the future.
+in the future. Well, they are now.
 --ldx]]--
 
-characters.filters.sequences = { }
+--[[obsolete--
+
+characters.filters.sequences = characters.filters.sequences or { }
 characters.filters.activated = false
 
 function characters.filters.append(name)
@@ -215,7 +217,7 @@ function characters.filters.prepend(name)
 end
 
 function characters.filters.remove(name)
-    for k,v in pairs(characters.filters.sequences) do
+    for k,v in ipairs(characters.filters.sequences) do
         if v == name then
             table.remove(characters.filters.sequences,k)
         end
@@ -223,25 +225,28 @@ function characters.filters.remove(name)
 end
 
 function characters.filters.replace(name_1,name_2)
-    for k,v in pairs(characters.filters.sequences) do
-        if v == name then
+    for k,v in ipairs(characters.filters.sequences) do
+        if v == name_1 then
             characters.filters.sequences[k] = name_2
+            break
         end
     end
 end
 
 function characters.filters.insert_before(name_1,name_2)
-    for k,v in pairs(characters.filters.sequences) do
+    for k,v in ipairs(characters.filters.sequences) do
         if v == name_1 then
             table.insert(characters.filters.sequences,k,name_2)
+            break
         end
     end
 end
 
 function characters.filters.insert_after(name_1,name_2)
-    for k,v in pairs(characters.filters.sequences) do
+    for k,v in ipairs(characters.filters.sequences) do
         if v == name_1 then
             table.insert(characters.filters.sequences,k+1,name_2)
+            break
         end
     end
 end
@@ -261,6 +266,8 @@ function characters.filters.process(str)
     end
 end
 
+--obsolete]]--
+
 --[[ldx--
 The following code is no longer needed and replaced by token
 collectors somehwere else.
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index d2154bec8..0ee61b10a 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
 %C details.
 
-\newcontextversion{2007.08.08 14:35}
+\newcontextversion{2007.08.09 13:04}
 
 %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/context.tex b/tex/context/base/context.tex
index fd7fe52ec..541ae1ead 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -42,7 +42,7 @@
 %D your styles an modules.
 
 \edef\contextformat {\jobname}
-\edef\contextversion{2007.08.08 14:35}
+\edef\contextversion{2007.08.09 13:04}
 
 %D For those who want to use this:
 
diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua
index aba0728d0..581005c8a 100644
--- a/tex/context/base/font-def.lua
+++ b/tex/context/base/font-def.lua
@@ -235,9 +235,16 @@ function fonts.tfm.read_and_define(name,size) -- no id
     local id = fonts.tfm.internalized[hash]
     if not id then
         local fontdata = fonts.tfm.read(specification)
-        id = font.define(fontdata)
-        fonts.tfm.id[id] = fontdata
-        fonts.tfm.internalized[hash] = id
+        if not fonts.tfm.internalized[hash] then
+            id = font.define(fontdata)
+            fonts.tfm.id[id] = fontdata
+            fonts.tfm.internalized[hash] = id
+            if fonts.trace then
+                logs.report("define font", string.format("at 1 id %s, hash: %s",id,hash))
+            end
+        else
+            id = fonts.tfm.internalized[hash]
+        end
     end
     return fonts.tfm.id[id], id
 end
@@ -285,9 +292,10 @@ function fonts.tfm.readers.afm(specification,method)
         if not fullname or fullname == "" then
             tfmtable = fonts.tfm.read_from_afm(specification)
             fonts.logger.save(tfmtable,'afm',specification)
-        else
+        else -- redundant
             specification.filename = fullname
             tfmtable = fonts.tfm.read_from_tfm(specification)
+            fonts.logger.save(tfmdata,'tfm',specification)
         end
     elseif method == 3 then -- maybe also findbinfile here
         if fonts.define.auto_afm then
@@ -445,7 +453,7 @@ function fonts.define.read(name,size,id)
     if true then
         local fontdata = containers.read(fonts.cache,hash) -- for tracing purposes
     end
-    local fontdata = fonts.tfm.internalized[hash]
+    local fontdata = fonts.tfm.internalized[hash] -- id
     if not fontdata then
         if specification.features.vtf and specification.features.vtf.preset then
             fontdata = fonts.tfm.make(specification)
@@ -455,8 +463,15 @@ function fonts.define.read(name,size,id)
         if true then
             fontdata = containers.write(fonts.cache,hash,fontdata) -- for tracing purposes
         end
-        fonts.tfm.id[id] = fontdata
-        fonts.tfm.internalized[hash] = id
+        if not fonts.tfm.internalized[hash] then
+            fonts.tfm.id[id] = fontdata
+            fonts.tfm.internalized[hash] = id
+            if fonts.trace then
+                logs.report("define font", string.format("at 2 id %s, hash: %s",id,hash))
+            end
+        else
+            fontdata = fonts.tfm.internalized[hash]
+        end
     end
     if not fontdata then
         logs.error("defining font", string.format("name: %s, loading aborted",specification.name))
@@ -475,10 +490,11 @@ end
 --~ end
 
 function fonts.vf.find(name)
-    if fonts.logger.format(name) == 'tfm' then
+    local format = fonts.logger.format(name)
+    if format == 'tfm' or format == 'ofm' then
         return input.findbinfile(texmf.instance,name,"ovf")
     else
-        return ""
+        return nil -- ""
     end
 end
 
diff --git a/tex/context/base/font-ini.lua b/tex/context/base/font-ini.lua
index 68cb49439..16fcf7271 100644
--- a/tex/context/base/font-ini.lua
+++ b/tex/context/base/font-ini.lua
@@ -15,7 +15,8 @@ if not modules then modules = { } end modules ['font-ini'] = {
 
 fonts = fonts or { }
 
-fonts.mode = 'base'
+fonts.trace = false -- true
+fonts.mode  = 'base'
 
 fonts.methods = {
     base = { tfm = { }, afm = { }, otf = { }, vtf = { }, fix = { } },
diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua
index 61b1d3a94..21a02a67b 100644
--- a/tex/context/base/font-tfm.lua
+++ b/tex/context/base/font-tfm.lua
@@ -17,7 +17,6 @@ fonts.logger     = fonts.logger     or { }
 fonts.loadtime   = 0
 fonts.tfm        = fonts.tfm        or { }
 fonts.triggers   = fonts.triggers   or { } -- brrr
-fonts.trace      = false
 
 --[[ldx--
 The next function encapsulates the standard  loader as
@@ -43,6 +42,32 @@ function fonts.tfm.read_from_tfm(specification)
             logs.report("define font",string.format("loading tfm file %s at size %s",fname,specification.size))
         end
         tfmdata = font.read_tfm(fname,specification.size)
+        if tfmdata then
+--~ fonts.logger.save(tfmdata,'tfm',specification)
+--~ if false then
+            fname = input.findbinfile(texmf.instance, specification.name, 'ovf')
+            if fname and fname ~= "" then
+callback.register('find_vf_file', nil)
+                local vfdata = font.read_vf(fname,specification.size)
+                if vfdata then
+                    local chars = tfmdata.characters
+                    for k,v in ipairs(vfdata.characters) do
+                        chars[k].commands = v.commands
+                    end
+--~                     tfmdata.type = 'virtual'
+                    local fnts = vfdata.fonts
+                    for k,v in ipairs(fnts) do
+                        local dummy, id = fonts.tfm.read_and_define(v.name,v.size)
+                        fnts[k].id = id
+                        if fonts.trace then
+                            logs.report("define font",string.format("vf file %s needs tfm file %s (id %s)", fname, v.name, id))
+                        end
+                    end
+                    tfmdata.fonts = fnts
+                end
+            end
+--~ end
+        end
     else
         if fonts.trace then
             logs.report("define font",string.format("loading tfm with name %s fails",specification.name))
diff --git a/tex/context/base/luat-inp.lua b/tex/context/base/luat-inp.lua
index 656bd76a1..6551d1011 100644
--- a/tex/context/base/luat-inp.lua
+++ b/tex/context/base/luat-inp.lua
@@ -18,6 +18,8 @@
 
 -- Beware, loading and saving is overloaded in luat-tmp!
 
+-- todo: instances.[hashes,cnffiles,configurations,522] -> ipairs (alles check, sneller)
+
 if not versions    then versions    = { } end versions['luat-inp'] = 1.001
 if not environment then environment = { } end
 if not file        then file        = { } end
@@ -125,6 +127,7 @@ function input.reset()
     instance.files           = { }
     instance.remap           = { }
     instance.configuration   = { }
+    instance.order           = { }
     instance.found           = { }
     instance.foundintrees    = { }
     instance.kpsevars        = { }
@@ -379,14 +382,14 @@ function input.load_cnf(instance)
 end
 
 function input.loadconfigdata(instance)
-    for _, fname in pairs(instance.cnffiles) do
+    for _, fname in ipairs(instance.cnffiles) do
         input.aux.load_cnf(instance,fname)
     end
 end
 
 if os.env then
     function input.aux.collapse_cnf_data(instance)
-        for _,c in pairs(instance.configuration) do
+        for _,c in ipairs(instance.order) do
             for k,v in pairs(c) do
                 if not instance.variables[k] then
                     if instance.environment[k] then
@@ -401,7 +404,7 @@ if os.env then
     end
 else
     function input.aux.collapse_cnf_data(instance)
-        for _,c in pairs(instance.configuration) do
+        for _,c in ipairs(instance.order) do
             for k,v in pairs(c) do
                 if not instance.variables[k] then
                     local e = os.getenv(k)
@@ -424,7 +427,11 @@ function input.aux.load_cnf(instance,fname)
     local f = io.open(lname)
     if f then
         f:close()
-        input.aux.load_data(instance,file.dirname(lname),'configuration',file.basename(lname))
+        local dname = file.dirname(fname)
+        if not instance.configuration[dname] then
+            input.aux.load_data(instance,dname,'configuration',file.basename(lname))
+            instance.order[#instance.order+1] = instance.configuration[dname]
+        end
     else
         f = io.open(fname)
         if f then
@@ -433,6 +440,7 @@ function input.aux.load_cnf(instance,fname)
             local dname = file.dirname(fname)
             if not instance.configuration[dname] then
                 instance.configuration[dname] = { }
+                instance.order[#instance.order+1] = instance.configuration[dname]
             end
             local data = instance.configuration[dname]
             while true do
@@ -588,7 +596,7 @@ function input.generators.tex(instance,specification)
         input.report("scanning path",specification)
         instance.files[tag] = { }
         local files = instance.files[tag]
-        local n, m = 0, 0
+        local n, m, r = 0, 0, 0
         local spec = specification .. '/'
         local attributes = lfs.attributes
         local directory = lfs.dir
@@ -628,6 +636,7 @@ function input.generators.tex(instance,specification)
                             local lower = name:lower()
                             if name ~= lower then
                                 files["remap:"..lower] = name
+                                r = r + 1
                             end
                         end
                     end
@@ -635,7 +644,7 @@ function input.generators.tex(instance,specification)
             end
         end
         action()
-        input.report(n,"files found on",m,"directories")
+        input.report(string.format("%s files found on %s directories with %s uppercase remappings",n,m,r))
     else
         local fullname = file.join(specification,input.lsrname)
         local path     = '.'
@@ -686,7 +695,7 @@ end
 -- is more convenient.
 
 function input.splitconfig(instance)
-    for i,c in pairs(instance.configuration) do
+    for i,c in ipairs(instance.order) do
         for k,v in pairs(c) do
             if type(v) == 'string' then
                 local t = file.split_path(v)
@@ -698,7 +707,7 @@ function input.splitconfig(instance)
     end
 end
 function input.joinconfig(instance)
-    for i,c in pairs(instance.configuration) do
+    for i,c in ipairs(instance.order) do
         for k,v in pairs(c) do
             if type(v) == 'table' then
                 c[k] = file.join_path(v)
@@ -811,10 +820,12 @@ function input.aux.save_data(instance, dataname, check)
 end
 
 function input.loadconfig(instance)
-    instance.configuration, instance.loaderror = { }, false
+    instance.configuration, instance.order, instance.loaderror = { }, { }, false
     if not instance.renewcache then
-        for _, cnf in pairs(instance.cnffiles) do
-            input.aux.load_data(instance,file.dirname(cnf),'configuration')
+        for _, cnf in ipairs(instance.cnffiles) do
+            local dname = file.dirname(cnf)
+            input.aux.load_data(instance,dname,'configuration')
+            instance.order[#instance.order+1] = instance.configuration[dname]
             if instance.loaderror then break end
         end
     end
@@ -970,7 +981,7 @@ function input.list_configurations(instance)
     for _,key in pairs(table.sortedkeys(instance.kpsevars)) do
         if not instance.pattern or (instance.pattern=="") or key:find(instance.pattern) then
             print(key.."\n")
-            for i,c in pairs(instance.configuration) do
+            for i,c in ipairs(instance.order) do
                 local str = c[key]
                 if str then
                     print("\t" .. i .. "\t\t" .. input.aux.tabstr(str))
@@ -1123,8 +1134,7 @@ function input.aux.expanded_path(instance,pathlist)
                     local pre, mid, post = v:match(pattern)
                     if pre and mid and post then
                         more = true
---~                         for vv in string.gmatch(mid..',',"(.-),") do
-                        for vv in string.gmatch(mid,"([^,]+)") do
+                        for vv in string.gmatch(mid..',',"(.-),") do
                             if vv == '.' then
                                 t[#t+1] = pre..post
                             else
@@ -1139,13 +1149,12 @@ function input.aux.expanded_path(instance,pathlist)
                 if not more then break end
             end
         end
-        for _,v in pairs(oldlist) do
+        for _,v in ipairs(oldlist) do
             v = file.collapse_path(v)
             if v ~= "" and not v:find(instance.dummy_path_expr) then newlist[#newlist+1] = v end
         end
     else
-        for _,v in pairs(pathlist) do
-         -- for _,vv in pairs(v:split(",")) do
+        for _,v in ipairs(pathlist) do
             for vv in string.gmatch(v..',',"(.-),") do
                 vv = file.collapse_path(v)
                 if vv ~= "" then newlist[#newlist+1] = vv end
@@ -1196,7 +1205,7 @@ function input.aux.collect_files(instance,names)
             else
                 dname = "/" .. dname .. "$"
             end
-            for _, hash in pairs(instance.hashes) do
+            for _, hash in ipairs(instance.hashes) do
                 local blobpath = hash.tag
                 local files = blobpath and instance.files[blobpath]
                 if files then
@@ -1330,15 +1339,15 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
         local filetype, extra, done, wantedfiles, ext = '', nil, false, { }, file.extname(filename)
         if ext == "" then
             if not instance.force_suffixes then
-                table.insert(wantedfiles, filename)
+                wantedfiles[#wantedfiles+1] = filename
             end
         else
-            table.insert(wantedfiles, filename)
+            wantedfiles[#wantedfiles+1] = filename
         end
         if instance.format == "" then
             if ext == "" then
                 local forcedname = filename .. '.tex'
-                table.insert(wantedfiles, forcedname)
+                wantedfiles[#wantedfiles+1] = forcedname
                 filetype = input.format_of_suffix(forcedname)
                 input.logger('! forcing filetype',filetype)
             else
@@ -1348,7 +1357,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
         else
             if ext == "" then
                 for _, s in pairs(input.suffixes_of_format(instance.format)) do
-                    table.insert(wantedfiles, filename .. "." .. s)
+                    wantedfiles[#wantedfiles+1] = filename .. "." .. s
                 end
             end
             filetype = instance.format
@@ -1366,7 +1375,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
             for _, fname in pairs(wantedfiles) do
                 if fname and input.is_readable.file(fname) then
                     filename, done = fname, true
-                    table.insert(result, file.join('.',fname))
+                    result[#result+1] = file.join('.',fname)
                     break
                 end
             end
@@ -1374,7 +1383,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
             local filelist = input.aux.collect_files(instance,wantedfiles)
             filename = filelist and filelist[1]
             if filename then
-                table.insert(result, filename)
+                result[#result+1] = filename
                 done = true
             end
         else
@@ -1406,7 +1415,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
                             if input.trace > 2 then
                                 input.logger('= found in hash',f)
                             end
-                            table.insert(result,f)
+                            result[#result+1] = f
                             input.aux.register_in_trees(instance,f) -- for tracing used files
                             done = true
                             if not instance.allresults then break end
@@ -1428,7 +1437,7 @@ function input.aux.find_file(instance,filename) -- todo : plugin (scanners, chec
                                         if input.trace > 2 then
                                             input.logger('= found by scanning',fname)
                                         end
-                                        table.insert(result,fname)
+                                        result[#result+1] = fname
                                         done = true
                                         if not instance.allresults then break end
                                     end
@@ -1519,15 +1528,23 @@ end
 
 function input.find_given_files(instance,filename)
     local bname, result = file.basename(filename), { }
-    for k, hash in pairs(instance.hashes) do
+    for k, hash in ipairs(instance.hashes) do
         local blist = instance.files[hash.tag][bname]
+        if not blist then
+            local rname = "remap:"..bname
+            blist = files[rname]
+            if blist then
+                bname = files[rname]
+                blist = files[bname]
+            end
+        end
         if blist then
             if type(blist) == 'string' then
-                table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
+                result[#result+1] = input.concatinators[hash.type](hash.tag,blist,bname) or ""
                 if not instance.allresults then break end
             else
                 for kk,vv in pairs(blist) do
-                    table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
+                    result[#result+1] = input.concatinators[hash.type](hash.tag,vv,bname) or ""
                     if not instance.allresults then break end
                 end
             end
@@ -1540,35 +1557,7 @@ function input.find_given_file(instance,filename)
     return (input.find_given_files(instance,filename)[1] or "")
 end
 
---~ function input.find_wildcard_files(instance,filename)
---~     local result = { }
---~     local bname, dname = file.basename(filename), file.dirname(filename)
---~     local expr = dname:gsub("^*/","")
---~     expr = expr:gsub("*",".*")
---~     expr = expr:gsub("-","%-")
---~     for k, hash in pairs(instance.hashes) do
---~         local blist = instance.files[hash.tag][bname]
---~         if blist then
---~             if type(blist) == 'string' then
---~                 -- make function and share code
---~                 if blist:find(expr) then
---~                     table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
---~                     if not instance.allresults then break end
---~                 end
---~             else
---~                 for kk,vv in pairs(blist) do
---~                     if vv:find(expr) then
---~                         table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
---~                         if not instance.allresults then break end
---~                     end
---~                 end
---~             end
---~         end
---~     end
---~     return result
---~ end
-
-function input.find_wildcard_files(instance,filename)
+function input.find_wildcard_files(instance,filename) -- todo: remap:
     local result = { }
     local bname, dname = file.basename(filename), file.dirname(filename)
     local path = dname:gsub("^*/","")
@@ -1588,13 +1577,13 @@ function input.find_wildcard_files(instance,filename)
             if type(blist) == 'string' then
                 -- make function and share code
                 if (blist:lower()):find(path) then
-                    table.insert(result,input.concatinators[hash.type](hash.tag,blist,bname) or "")
+                    result[#result+1] = input.concatinators[hash.type](hash.tag,blist,bname) or ""
                     done = true
                 end
             else
                 for kk,vv in pairs(blist) do
                     if (vv:lower()):find(path) then
-                        table.insert(result,input.concatinators[hash.type](hash.tag,vv,bname) or "")
+                        result[#result+1] = input.concatinators[hash.type](hash.tag,vv,bname) or ""
                         done = true
                         if not allresults then break end
                     end
@@ -1605,7 +1594,7 @@ function input.find_wildcard_files(instance,filename)
     end
     local files, allresults, done = instance.files, instance.allresults, false
     if name:find("%*") then
-        for k, hash in pairs(instance.hashes) do
+        for k, hash in ipairs(instance.hashes) do
             for kk, hh in pairs(files[hash.tag]) do
                 if (kk:lower()):find(name) then
                     if doit(hh,kk,hash,allresults) then done = true end
@@ -1614,7 +1603,7 @@ function input.find_wildcard_files(instance,filename)
             end
         end
     else
-        for k, hash in pairs(instance.hashes) do
+        for k, hash in ipairs(instance.hashes) do
             if doit(files[hash.tag][bname],bname,hash,allresults) then done = true end
             if done and not allresults then break end
         end
@@ -1854,17 +1843,24 @@ function input.do_with_var(name,func)
 end
 
 function input.with_files(instance,pattern,handle)
-    for _, hash in pairs(instance.hashes) do
+    for _, hash in ipairs(instance.hashes) do
         local blobpath = hash.tag
         local blobtype = hash.type
-        if blobpath and instance.files[blobpath] then -- sort them?
-            for k,v in pairs(instance.files[blobpath]) do
-                if k:find(pattern) then
-                    if type(v) == "string" then
-                        handle(blobtype,blobpath,v,k)
-                    else
-                        for _,vv in pairs(v) do
-                            handle(blobtype,blobpath,vv,k)
+        if blobpath then
+            local files = instance.files[blobpath]
+            if files then
+                for k,v in pairs(files) do
+                    if k:find("^remap:") then
+                        k = files[k]
+                        v = files[k] -- chained
+                    end
+                    if k:find(pattern) then
+                        if type(v) == "string" then
+                            handle(blobtype,blobpath,v,k)
+                        else
+                            for _,vv in pairs(v) do
+                                handle(blobtype,blobpath,vv,k)
+                            end
                         end
                     end
                 end
diff --git a/tex/context/base/meta-ini.tex b/tex/context/base/meta-ini.tex
index b095431cd..ad2037b9e 100644
--- a/tex/context/base/meta-ini.tex
+++ b/tex/context/base/meta-ini.tex
@@ -83,6 +83,12 @@
   defaultscale:=\the\bodyfontsize/10pt;
 \stopMPinitializations
 
+\beginLUATEX
+    \startMPinitializations % scale is not yet ok
+      defaultfont:="rm-lmtt10";
+    \stopMPinitializations
+\endLUATEX
+
 %D In order to support fancy text features (like outline
 %D fonts), we set:
 
diff --git a/tex/context/base/type-ghz.tex b/tex/context/base/type-ghz.tex
index 12ee9f3a3..52de82043 100644
--- a/tex/context/base/type-ghz.tex
+++ b/tex/context/base/type-ghz.tex
@@ -89,22 +89,6 @@
 
 % see antykwa, we could define variants for light and osf
 
-\starttypescript[optima-nova][texnansi,ec] % will change to more narrow tt
-    \definetypeface[optima][ss][sans][optima-nova] [default][encoding=\typescripttwo]
-    \definetypeface[optima][rm][sans][optima-nova] [default][encoding=\typescripttwo]
-    \definetypeface[optima][tt][mono][latin-modern][default][encoding=\typescripttwo,rscale=1.1]
-    \definetypeface[optima][mm][mono][latin-modern][default][encoding=\typescripttwo,rscale=1.1]
-    \quittypescriptscanning
-\stoptypescript
-
-\starttypescript[optima-nova-os][texnansi,ec] % will change to more narrow tt
-    \definetypeface[optima-os][ss][sans][optima-nova-os] [default][encoding=\typescripttwo]
-    \definetypeface[optima-os][rm][sans][optima-nova-os] [default][encoding=\typescripttwo]
-    \definetypeface[optima-os][tt][mono][latin-modern]   [default][encoding=\typescripttwo,rscale=1.1]
-    \definetypeface[optima-os][mm][mono][latin-modern]   [default][encoding=\typescripttwo,rscale=1.1]
-    \quittypescriptscanning
-\stoptypescript
-
 \starttypescript [sans] [optima-nova] [name]
 
   \definefontsynonym [Sans]            [OptimaNovaLT-Regular]
@@ -219,6 +203,22 @@
 
 \stoptypescript
 
+\starttypescript[optima-nova][texnansi,ec] % will change to more narrow tt
+    \definetypeface[optima][ss][sans][optima-nova] [default][encoding=\typescripttwo]
+    \definetypeface[optima][rm][sans][optima-nova] [default][encoding=\typescripttwo]
+    \definetypeface[optima][tt][mono][latin-modern][default][encoding=\typescripttwo,rscale=1.1]
+    \definetypeface[optima][mm][mono][latin-modern][default][encoding=\typescripttwo,rscale=1.1]
+    \quittypescriptscanning
+\stoptypescript
+
+\starttypescript[optima-nova-os][texnansi,ec] % will change to more narrow tt
+    \definetypeface[optima-os][ss][sans][optima-nova-os] [default][encoding=\typescripttwo]
+    \definetypeface[optima-os][rm][sans][optima-nova-os] [default][encoding=\typescripttwo]
+    \definetypeface[optima-os][tt][mono][latin-modern]   [default][encoding=\typescripttwo,rscale=1.1]
+    \definetypeface[optima-os][mm][mono][latin-modern]   [default][encoding=\typescripttwo,rscale=1.1]
+    \quittypescriptscanning
+\stoptypescript
+
 % palatino
 
 \starttypescript [serif] [palatino] [name]
diff --git a/tex/context/interface/keys-cz.xml b/tex/context/interface/keys-cz.xml
index b7385fccb..05766e2c8 100644
--- a/tex/context/interface/keys-cz.xml
+++ b/tex/context/interface/keys-cz.xml
@@ -1,6 +1,6 @@
 
 
-
+
 
   
     
diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml
index e740f71ff..3461fc0fa 100644
--- a/tex/context/interface/keys-de.xml
+++ b/tex/context/interface/keys-de.xml
@@ -1,6 +1,6 @@
 
 
-
+
 
   
     
diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml
index 8705ff11f..3867cf38f 100644
--- a/tex/context/interface/keys-en.xml
+++ b/tex/context/interface/keys-en.xml
@@ -1,6 +1,6 @@
 
 
-
+
 
   
     
diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml
index 1f78f000e..5680b44a7 100644
--- a/tex/context/interface/keys-fr.xml
+++ b/tex/context/interface/keys-fr.xml
@@ -1,6 +1,6 @@
 
 
-
+
 
   
     
diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml
index 1de46baa0..c9de9c5e9 100644
--- a/tex/context/interface/keys-it.xml
+++ b/tex/context/interface/keys-it.xml
@@ -1,6 +1,6 @@
 
 
-
+
 
   
     
diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml
index eac4f545d..08c82396f 100644
--- a/tex/context/interface/keys-nl.xml
+++ b/tex/context/interface/keys-nl.xml
@@ -1,6 +1,6 @@
 
 
-
+
 
   
     
diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml
index 2bf0b1792..9a0c50c08 100644
--- a/tex/context/interface/keys-ro.xml
+++ b/tex/context/interface/keys-ro.xml
@@ -1,6 +1,6 @@
 
 
-
+
 
   
     
-- 
cgit v1.2.3