summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/data-exp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/data-exp.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/data-exp.lua37
1 files changed, 32 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/context/base/data-exp.lua b/Master/texmf-dist/tex/context/base/data-exp.lua
index 52368f8a82e..1e323728c86 100644
--- a/Master/texmf-dist/tex/context/base/data-exp.lua
+++ b/Master/texmf-dist/tex/context/base/data-exp.lua
@@ -42,6 +42,16 @@ local function f_second(a,b)
return concat(t,",")
end
+-- local function f_both(a,b)
+-- local t, n = { }, 0
+-- for sb in gmatch(b,"[^,]+") do -- and not sa
+-- for sa in gmatch(a,"[^,]+") do -- sb
+-- n = n + 1 ; t[n] = sa .. sb
+-- end
+-- end
+-- return concat(t,",")
+-- end
+
local function f_both(a,b)
local t, n = { }, 0
for sa in gmatch(a,"[^,]+") do
@@ -52,6 +62,7 @@ local function f_both(a,b)
return concat(t,",")
end
+
local left = P("{")
local right = P("}")
local var = P((1 - S("{}" ))^0)
@@ -66,6 +77,9 @@ local l_rest = Cs( ( left * var * (left/"") * var * (right/"") * var * right
local stripper_1 = lpeg.stripper ("{}@")
local replacer_1 = lpeg.replacer { { ",}", ",@}" }, { "{,", "{@," }, }
+-- old {a,b}{c,d} => ac ad bc bd
+-- new {a,b}{c,d} => ac bc ad bd
+
local function splitpathexpr(str, newlist, validate) -- I couldn't resist lpegging it (nice exercise).
if trace_expansions then
report_expansions("expanding variable '%s'",str)
@@ -73,11 +87,24 @@ local function splitpathexpr(str, newlist, validate) -- I couldn't resist lpeggi
local t, ok, done = newlist or { }, false, false
local n = #t
str = lpegmatch(replacer_1,str)
- repeat local old = str
- repeat local old = str ; str = lpegmatch(l_first, str) until old == str
- repeat local old = str ; str = lpegmatch(l_second,str) until old == str
- repeat local old = str ; str = lpegmatch(l_both, str) until old == str
- repeat local old = str ; str = lpegmatch(l_rest, str) until old == str
+ repeat
+ local old = str
+ repeat
+ local old = str
+ str = lpegmatch(l_first, str)
+ until old == str
+ repeat
+ local old = str
+ str = lpegmatch(l_second,str)
+ until old == str
+ repeat
+ local old = str
+ str = lpegmatch(l_both, str)
+ until old == str
+ repeat
+ local old = str
+ str = lpegmatch(l_rest, str)
+ until old == str
until old == str -- or not find(str,"{")
str = lpegmatch(stripper_1,str)
if validate then