summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-01-16 18:33:00 +0100
committerHans Hagen <pragma@wxs.nl>2012-01-16 18:33:00 +0100
commit2c97049c16bd99dc7226b879c171246e34ec219c (patch)
treeb0608851e05083bd413fa35f8c65e8536dafd013 /scripts
parent5b13bdfca0e081ef26d49ba405b7fb62d7724c24 (diff)
downloadcontext-2c97049c16bd99dc7226b879c171246e34ec219c.tar.gz
beta 2012.01.16 18:33
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtxrun.lua19
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua19
-rwxr-xr-xscripts/context/stubs/unix/mtxrun19
3 files changed, 33 insertions, 24 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index f3c09d598..d289891c2 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -7566,7 +7566,7 @@ function xml.is_valid(root)
return root and not root.error
end
-xml.errorhandler = report
+xml.errorhandler = report_xml
--[[ldx--
<p>We cannot load an <l n='lpeg'/> from a filehandle so we need to load
@@ -9128,9 +9128,9 @@ end
expressions.child = function(e,pattern)
return applylpath(e,pattern) -- todo: cache
end
-expressions.count = function(e,pattern)
+expressions.count = function(e,pattern) -- what if pattern == empty or nil
local collected = applylpath(e,pattern) -- todo: cache
- return (collected and #collected) or 0
+ return pattern and (collected and #collected) or 0
end
-- external
@@ -9139,7 +9139,7 @@ expressions.oneof = function(s,...) -- slow
local t = {...} for i=1,#t do if s == t[i] then return true end end return false
end
expressions.error = function(str)
- xml.errorhandler("unknown function in lpath expression",tostring(str or "?"))
+ xml.errorhandler(format("unknown function in lpath expression: %s",tostring(str or "?")))
return false
end
expressions.undefined = function(s)
@@ -10167,6 +10167,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
+local find = string.find
local xml = xml
@@ -10416,7 +10417,7 @@ local function tags(collected,nonamespace)
return t
end
-local function empty(collected)
+local function empty(collected,spacesonly)
if not collected then
return true
end
@@ -10435,7 +10436,9 @@ local function empty(collected)
local typ = type(edk)
if typ == "table" then
return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
+ elseif edk ~= "" then
+ return false
+ elseif spacesonly and not find(edk,"%S") then
return false
end
elseif n > 1 then
@@ -10519,8 +10522,8 @@ function xml.match(id,pattern) -- number
return match(xmlfilter(id,pattern))
end
-function xml.empty(id,pattern)
- return empty(xmlfilter(id,pattern))
+function xml.empty(id,pattern,spacesonly)
+ return empty(xmlfilter(id,pattern),spacesonly)
end
xml.all = xml.filter
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index f3c09d598..d289891c2 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -7566,7 +7566,7 @@ function xml.is_valid(root)
return root and not root.error
end
-xml.errorhandler = report
+xml.errorhandler = report_xml
--[[ldx--
<p>We cannot load an <l n='lpeg'/> from a filehandle so we need to load
@@ -9128,9 +9128,9 @@ end
expressions.child = function(e,pattern)
return applylpath(e,pattern) -- todo: cache
end
-expressions.count = function(e,pattern)
+expressions.count = function(e,pattern) -- what if pattern == empty or nil
local collected = applylpath(e,pattern) -- todo: cache
- return (collected and #collected) or 0
+ return pattern and (collected and #collected) or 0
end
-- external
@@ -9139,7 +9139,7 @@ expressions.oneof = function(s,...) -- slow
local t = {...} for i=1,#t do if s == t[i] then return true end end return false
end
expressions.error = function(str)
- xml.errorhandler("unknown function in lpath expression",tostring(str or "?"))
+ xml.errorhandler(format("unknown function in lpath expression: %s",tostring(str or "?")))
return false
end
expressions.undefined = function(s)
@@ -10167,6 +10167,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
+local find = string.find
local xml = xml
@@ -10416,7 +10417,7 @@ local function tags(collected,nonamespace)
return t
end
-local function empty(collected)
+local function empty(collected,spacesonly)
if not collected then
return true
end
@@ -10435,7 +10436,9 @@ local function empty(collected)
local typ = type(edk)
if typ == "table" then
return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
+ elseif edk ~= "" then
+ return false
+ elseif spacesonly and not find(edk,"%S") then
return false
end
elseif n > 1 then
@@ -10519,8 +10522,8 @@ function xml.match(id,pattern) -- number
return match(xmlfilter(id,pattern))
end
-function xml.empty(id,pattern)
- return empty(xmlfilter(id,pattern))
+function xml.empty(id,pattern,spacesonly)
+ return empty(xmlfilter(id,pattern),spacesonly)
end
xml.all = xml.filter
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index f3c09d598..d289891c2 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -7566,7 +7566,7 @@ function xml.is_valid(root)
return root and not root.error
end
-xml.errorhandler = report
+xml.errorhandler = report_xml
--[[ldx--
<p>We cannot load an <l n='lpeg'/> from a filehandle so we need to load
@@ -9128,9 +9128,9 @@ end
expressions.child = function(e,pattern)
return applylpath(e,pattern) -- todo: cache
end
-expressions.count = function(e,pattern)
+expressions.count = function(e,pattern) -- what if pattern == empty or nil
local collected = applylpath(e,pattern) -- todo: cache
- return (collected and #collected) or 0
+ return pattern and (collected and #collected) or 0
end
-- external
@@ -9139,7 +9139,7 @@ expressions.oneof = function(s,...) -- slow
local t = {...} for i=1,#t do if s == t[i] then return true end end return false
end
expressions.error = function(str)
- xml.errorhandler("unknown function in lpath expression",tostring(str or "?"))
+ xml.errorhandler(format("unknown function in lpath expression: %s",tostring(str or "?")))
return false
end
expressions.undefined = function(s)
@@ -10167,6 +10167,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
+local find = string.find
local xml = xml
@@ -10416,7 +10417,7 @@ local function tags(collected,nonamespace)
return t
end
-local function empty(collected)
+local function empty(collected,spacesonly)
if not collected then
return true
end
@@ -10435,7 +10436,9 @@ local function empty(collected)
local typ = type(edk)
if typ == "table" then
return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
+ elseif edk ~= "" then
+ return false
+ elseif spacesonly and not find(edk,"%S") then
return false
end
elseif n > 1 then
@@ -10519,8 +10522,8 @@ function xml.match(id,pattern) -- number
return match(xmlfilter(id,pattern))
end
-function xml.empty(id,pattern)
- return empty(xmlfilter(id,pattern))
+function xml.empty(id,pattern,spacesonly)
+ return empty(xmlfilter(id,pattern),spacesonly)
end
xml.all = xml.filter