summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2010-05-20 20:00:00 +0200
committerHans Hagen <pragma@wxs.nl>2010-05-20 20:00:00 +0200
commit24c19e9dcac5d1ec7e6b26fb86d34f0756a8d98a (patch)
tree4e813a7e38b60df6586ed91301cf9a23c9011d8a /scripts
parent663cdcff77510b4cf9f165a7c8aa147f8ad2a50a (diff)
downloadcontext-24c19e9dcac5d1ec7e6b26fb86d34f0756a8d98a.tar.gz
beta 2010.05.20 20:00
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-context.lua4
-rw-r--r--scripts/context/lua/mtxrun.lua61
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua61
-rwxr-xr-xscripts/context/stubs/unix/mtxrun61
4 files changed, 170 insertions, 17 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index df1ff3b85..79e74e407 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -237,8 +237,8 @@ do
commands[e.at and e.at['name'] or "unknown"] = e
end
- local suffix = xml.filter(ctxdata.xmldata,"/ctx:job/ctx:preprocess/attribute(suffix)") or ctxdata.suffix
- local runlocal = xml.filter(ctxdata.xmldata,"/ctx:job/ctx:preprocess/ctx:processors/attribute(local)")
+ local suffix = xml.filter(ctxdata.xmldata,"/ctx:job/ctx:preprocess/attribute('suffix')") or ctxdata.suffix
+ local runlocal = xml.filter(ctxdata.xmldata,"/ctx:job/ctx:preprocess/ctx:processors/attribute('local')")
runlocal = toboolean(runlocal)
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index d3e50e00e..ae0ee162f 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -525,7 +525,55 @@ local concat, sort, insert, remove = table.concat, table.sort, table.insert, tab
local format, find, gsub, lower, dump, match = string.format, string.find, string.gsub, string.lower, string.dump, string.match
local getmetatable, setmetatable = getmetatable, setmetatable
local type, next, tostring, tonumber, ipairs = type, next, tostring, tonumber, ipairs
-local unpack = unpack or table.unpack
+
+-- Starting with version 5.2 Lua no longer provide ipairs, which makes
+-- sense. As we already used the for loop and # in most places the
+-- impact on ConTeXt was not that large; the remaining ipairs already
+-- have been replaced. In a similar fashio we also hardly used pairs.
+--
+-- Just in case, we provide the fallbacks as discussed in Programming
+-- in Lua (http://www.lua.org/pil/7.3.html):
+
+if not ipairs then
+
+ -- for k, v in ipairs(t) do ... end
+ -- for k=1,#t do local v = t[k] ... end
+
+ local function iterate(a,i)
+ i = i + 1
+ local v = a[i]
+ if v ~= nil then
+ return i, v --, nil
+ end
+ end
+
+ function ipairs(a)
+ return iterate, a, 0
+ end
+
+end
+
+if not pairs then
+
+ -- for k, v in pairs(t) do ... end
+ -- for k, v in next, t do ... end
+
+ function pairs(t)
+ return next, t -- , nil
+ end
+
+end
+
+-- Also, unpack has been moved to the table table, and for compatiility
+-- reasons we provide both now.
+
+if not table.unpack then
+ table.unpack = _G.unpack
+elseif not unpack then
+ _G.unpack = table.unpack
+end
+
+-- extra functions, some might go (when not used)
function table.strip(tab)
local lst = { }
@@ -712,7 +760,7 @@ end
table.fastcopy = fastcopy
table.copy = copy
--- rougly: copy-loop : unpack : sub == 0.9 : 0.4 : 0.45 (so in critical apps, use unpack)
+-- roughly: copy-loop : unpack : sub == 0.9 : 0.4 : 0.45 (so in critical apps, use unpack)
function table.sub(t,i,j)
return { unpack(t,i,j) }
@@ -735,7 +783,7 @@ function table.one_entry(t) -- obolete, use inline code instead
return n and not next(t,n)
end
---~ function table.starts_at(t) -- obsolete, not nice
+--~ function table.starts_at(t) -- obsolete, not nice anyway
--~ return ipairs(t,1)(t,0)
--~ end
@@ -1374,6 +1422,7 @@ function table.insert_after_value(t,value,extra)
end
+
end -- of closure
do -- create closure to overcome 200 locals limit
@@ -6974,8 +7023,10 @@ local function reverse(collected)
end
local function attribute(collected,name)
- local at = collected and collected[1].at
- return at and at[name]
+ if collected and #collected > 0 then
+ local at = collected[1].at
+ return at and at[name]
+ end
end
local function att(id,name)
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index d3e50e00e..ae0ee162f 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -525,7 +525,55 @@ local concat, sort, insert, remove = table.concat, table.sort, table.insert, tab
local format, find, gsub, lower, dump, match = string.format, string.find, string.gsub, string.lower, string.dump, string.match
local getmetatable, setmetatable = getmetatable, setmetatable
local type, next, tostring, tonumber, ipairs = type, next, tostring, tonumber, ipairs
-local unpack = unpack or table.unpack
+
+-- Starting with version 5.2 Lua no longer provide ipairs, which makes
+-- sense. As we already used the for loop and # in most places the
+-- impact on ConTeXt was not that large; the remaining ipairs already
+-- have been replaced. In a similar fashio we also hardly used pairs.
+--
+-- Just in case, we provide the fallbacks as discussed in Programming
+-- in Lua (http://www.lua.org/pil/7.3.html):
+
+if not ipairs then
+
+ -- for k, v in ipairs(t) do ... end
+ -- for k=1,#t do local v = t[k] ... end
+
+ local function iterate(a,i)
+ i = i + 1
+ local v = a[i]
+ if v ~= nil then
+ return i, v --, nil
+ end
+ end
+
+ function ipairs(a)
+ return iterate, a, 0
+ end
+
+end
+
+if not pairs then
+
+ -- for k, v in pairs(t) do ... end
+ -- for k, v in next, t do ... end
+
+ function pairs(t)
+ return next, t -- , nil
+ end
+
+end
+
+-- Also, unpack has been moved to the table table, and for compatiility
+-- reasons we provide both now.
+
+if not table.unpack then
+ table.unpack = _G.unpack
+elseif not unpack then
+ _G.unpack = table.unpack
+end
+
+-- extra functions, some might go (when not used)
function table.strip(tab)
local lst = { }
@@ -712,7 +760,7 @@ end
table.fastcopy = fastcopy
table.copy = copy
--- rougly: copy-loop : unpack : sub == 0.9 : 0.4 : 0.45 (so in critical apps, use unpack)
+-- roughly: copy-loop : unpack : sub == 0.9 : 0.4 : 0.45 (so in critical apps, use unpack)
function table.sub(t,i,j)
return { unpack(t,i,j) }
@@ -735,7 +783,7 @@ function table.one_entry(t) -- obolete, use inline code instead
return n and not next(t,n)
end
---~ function table.starts_at(t) -- obsolete, not nice
+--~ function table.starts_at(t) -- obsolete, not nice anyway
--~ return ipairs(t,1)(t,0)
--~ end
@@ -1374,6 +1422,7 @@ function table.insert_after_value(t,value,extra)
end
+
end -- of closure
do -- create closure to overcome 200 locals limit
@@ -6974,8 +7023,10 @@ local function reverse(collected)
end
local function attribute(collected,name)
- local at = collected and collected[1].at
- return at and at[name]
+ if collected and #collected > 0 then
+ local at = collected[1].at
+ return at and at[name]
+ end
end
local function att(id,name)
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index d3e50e00e..ae0ee162f 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -525,7 +525,55 @@ local concat, sort, insert, remove = table.concat, table.sort, table.insert, tab
local format, find, gsub, lower, dump, match = string.format, string.find, string.gsub, string.lower, string.dump, string.match
local getmetatable, setmetatable = getmetatable, setmetatable
local type, next, tostring, tonumber, ipairs = type, next, tostring, tonumber, ipairs
-local unpack = unpack or table.unpack
+
+-- Starting with version 5.2 Lua no longer provide ipairs, which makes
+-- sense. As we already used the for loop and # in most places the
+-- impact on ConTeXt was not that large; the remaining ipairs already
+-- have been replaced. In a similar fashio we also hardly used pairs.
+--
+-- Just in case, we provide the fallbacks as discussed in Programming
+-- in Lua (http://www.lua.org/pil/7.3.html):
+
+if not ipairs then
+
+ -- for k, v in ipairs(t) do ... end
+ -- for k=1,#t do local v = t[k] ... end
+
+ local function iterate(a,i)
+ i = i + 1
+ local v = a[i]
+ if v ~= nil then
+ return i, v --, nil
+ end
+ end
+
+ function ipairs(a)
+ return iterate, a, 0
+ end
+
+end
+
+if not pairs then
+
+ -- for k, v in pairs(t) do ... end
+ -- for k, v in next, t do ... end
+
+ function pairs(t)
+ return next, t -- , nil
+ end
+
+end
+
+-- Also, unpack has been moved to the table table, and for compatiility
+-- reasons we provide both now.
+
+if not table.unpack then
+ table.unpack = _G.unpack
+elseif not unpack then
+ _G.unpack = table.unpack
+end
+
+-- extra functions, some might go (when not used)
function table.strip(tab)
local lst = { }
@@ -712,7 +760,7 @@ end
table.fastcopy = fastcopy
table.copy = copy
--- rougly: copy-loop : unpack : sub == 0.9 : 0.4 : 0.45 (so in critical apps, use unpack)
+-- roughly: copy-loop : unpack : sub == 0.9 : 0.4 : 0.45 (so in critical apps, use unpack)
function table.sub(t,i,j)
return { unpack(t,i,j) }
@@ -735,7 +783,7 @@ function table.one_entry(t) -- obolete, use inline code instead
return n and not next(t,n)
end
---~ function table.starts_at(t) -- obsolete, not nice
+--~ function table.starts_at(t) -- obsolete, not nice anyway
--~ return ipairs(t,1)(t,0)
--~ end
@@ -1374,6 +1422,7 @@ function table.insert_after_value(t,value,extra)
end
+
end -- of closure
do -- create closure to overcome 200 locals limit
@@ -6974,8 +7023,10 @@ local function reverse(collected)
end
local function attribute(collected,name)
- local at = collected and collected[1].at
- return at and at[name]
+ if collected and #collected > 0 then
+ local at = collected[1].at
+ return at and at[name]
+ end
end
local function att(id,name)