summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-03-05 00:48:46 +0000
committerKarl Berry <karl@freefriends.org>2020-03-05 00:48:46 +0000
commitf210bce174e1f2f05305ab03e88e120a1cbfc4da (patch)
tree5c4e2ad096b5c745e859516ac3196fa0864292d5 /Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua
parent35fd641a3546acc0c62e0aa7f134888e36da30d4 (diff)
context (from cont-tmf.zip of Feb 17 16:00, size 116339406)
git-svn-id: svn://tug.org/texlive/trunk@54086 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua48
1 files changed, 45 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua
index ecb5d9dd054..5b5c4786756 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/buff-ini.lua
@@ -36,6 +36,7 @@ local scanstring = scanners.string
local scaninteger = scanners.integer
local scanboolean = scanners.boolean
local scancode = scanners.code
+local scantokencode = scanners.tokencode
----- scantoken = scanners.token
local getters = tokens.getters
@@ -357,6 +358,23 @@ local split = table.setmetatableindex(function(t,k)
return v
end)
+local tochar = {
+ [ 0] = "\\",
+ [ 1] = "{",
+ [ 2] = "}",
+ [ 3] = "$",
+ [ 4] = "&",
+ [ 5] = "\n",
+ [ 6] = "#",
+ [ 7] = "^",
+ [ 8] = "_",
+ [10] = " ",
+ [14] = "%",
+}
+
+local experiment = false
+local experiment = scantokencode and true
+
function tokens.pickup(start,stop)
local stoplist = split[stop] -- totable(stop)
local stoplength = #stoplist
@@ -367,7 +385,8 @@ function tokens.pickup(start,stop)
local list = { }
local size = 0
local depth = 0
--- local done = 32
+-- local done = 32
+ local scancode = experiment and scantokencode or scancode
while true do -- or use depth
local char = scancode()
if char then
@@ -418,15 +437,37 @@ function tokens.pickup(start,stop)
local t = gettoken()
if t then
-- we're skipping leading stuff, like obeyedlines and relaxes
+ if experiment and size > 0 then
+ -- we're probably in a macro
+ local char = tochar[token.get_command(t)] -- could also be char(token.get_mode(t))
+ if char then
+ size = size + 1 ; list[size] = char
+ else
+ local csname = token.get_csname(t)
+ if csname == stop then
+ stoplength = 0
+ break
+ else
+ size = size + 1 ; list[size] = "\\"
+ size = size + 1 ; list[size] = csname
+ size = size + 1 ; list[size] = " "
+ end
+ end
+ else
+ -- ignore and hope for the best
+ end
else
break
end
end
end
local start = 1
- local stop = size-stoplength-1
+ local stop = size - stoplength - 1
-- not good enough: only empty lines, but even then we miss the leading
-- for verbatim
+ --
+ -- the next is not yet adapted to the new scanner ... we don't need lpeg here
+ --
for i=start,stop do
local li = list[i]
if lpegmatch(blackspace,li) then
@@ -445,6 +486,7 @@ function tokens.pickup(start,stop)
break
end
end
+ --
if start <= stop then
return concat(list,"",start,stop)
else
@@ -512,7 +554,7 @@ local runner = sandbox.registerrunner {
name = "run buffer",
program = "context",
method = "execute",
- template = "--purgeall " .. (jit and "--jit" or "") .. " %filename%",
+ template = jit and "--purgeall --jit %filename%" or "--purgeall %filename%",
reporter = report_typeset,
checkers = {
filename = "readable",