summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/syst-lua.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
committerKarl Berry <karl@freefriends.org>2013-04-08 00:43:40 +0000
commit824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch)
treeabfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/tex/context/base/syst-lua.lua
parent689aefb0727676ed3cddf331337b4be226495e72 (diff)
context import for TL13, from www.pragma-ade.com/context/beta/cont-tmf.zip
git-svn-id: svn://tug.org/texlive/trunk@29731 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/syst-lua.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/syst-lua.lua52
1 files changed, 36 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/context/base/syst-lua.lua b/Master/texmf-dist/tex/context/base/syst-lua.lua
index f735b1962e6..ef524c339fa 100644
--- a/Master/texmf-dist/tex/context/base/syst-lua.lua
+++ b/Master/texmf-dist/tex/context/base/syst-lua.lua
@@ -16,14 +16,17 @@ commands = commands or { }
function commands.writestatus(...) logs.status(...) end -- overloaded later
--- todo: use shorter names i.e. less tokenization, like prtcatcodes + f_o_t_a
-
local firstoftwoarguments = context.firstoftwoarguments -- context.constructcsonly("firstoftwoarguments" )
local secondoftwoarguments = context.secondoftwoarguments -- context.constructcsonly("secondoftwoarguments")
local firstofoneargument = context.firstofoneargument -- context.constructcsonly("firstofoneargument" )
local gobbleoneargument = context.gobbleoneargument -- context.constructcsonly("gobbleoneargument" )
-local function testcase(b)
+-- contextsprint(prtcatcodes,[[\ui_fo]]) -- firstofonearguments
+-- contextsprint(prtcatcodes,[[\ui_go]]) -- gobbleonearguments
+-- contextsprint(prtcatcodes,[[\ui_ft]]) -- firstoftwoarguments
+-- contextsprint(prtcatcodes,[[\ui_st]]) -- secondoftwoarguments
+
+function commands.doifelse(b)
if b then
firstoftwoarguments()
else
@@ -47,33 +50,45 @@ function commands.doifnot(b)
end
end
-commands.testcase = testcase
-commands.doifelse = testcase
+commands.testcase = commands.doifelse -- obsolete
function commands.boolcase(b)
context(b and 1 or 0)
end
function commands.doifelsespaces(str)
- return testcase(find(str,"^ +$"))
+ if find(str,"^ +$") then
+ firstoftwoarguments()
+ else
+ secondoftwoarguments()
+ end
end
local s = lpegtsplitat(",")
local h = { }
-function commands.doifcommonelse(a,b)
+function commands.doifcommonelse(a,b) -- often the same test
local ha = h[a]
local hb = h[b]
- if not ha then ha = lpegmatch(s,a) h[a] = ha end
- if not hb then hb = lpegmatch(s,b) h[b] = hb end
- for i=1,#ha do
- for j=1,#hb do
+ if not ha then
+ ha = lpegmatch(s,a)
+ h[a] = ha
+ end
+ if not hb then
+ hb = lpegmatch(s,b)
+ h[b] = hb
+ end
+ local na = #ha
+ local nb = #hb
+ for i=1,na do
+ for j=1,nb do
if ha[i] == hb[j] then
- return testcase(true)
+ firstoftwoarguments()
+ return
end
end
end
- return testcase(false)
+ secondoftwoarguments()
end
function commands.doifinsetelse(a,b)
@@ -81,16 +96,21 @@ function commands.doifinsetelse(a,b)
if not hb then hb = lpegmatch(s,b) h[b] = hb end
for i=1,#hb do
if a == hb[i] then
- return testcase(true)
+ firstoftwoarguments()
+ return
end
end
- return testcase(false)
+ secondoftwoarguments()
end
local pattern = lpeg.patterns.validdimen
function commands.doifdimenstringelse(str)
- testcase(lpegmatch(pattern,str))
+ if lpegmatch(pattern,str) then
+ firstoftwoarguments()
+ else
+ secondoftwoarguments()
+ end
end
function commands.firstinset(str)