diff options
Diffstat (limited to 'relabel.lua')
-rw-r--r-- | relabel.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/relabel.lua b/relabel.lua index 3f3894d..d038531 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -360,13 +360,19 @@ local function lineno (s, i) | |||
360 | return 1 + num, (r ~= 0 and r or 1) + adjust | 360 | return 1 + num, (r ~= 0 and r or 1) + adjust |
361 | end | 361 | end |
362 | 362 | ||
363 | local function splitlines(str) | ||
364 | local t = {} | ||
365 | local function helper(line) tinsert(t, line) return "" end | ||
366 | helper((str:gsub("(.-)\r?\n", helper))) | ||
367 | return t | ||
368 | end | ||
369 | |||
363 | local function compile (p, defs) | 370 | local function compile (p, defs) |
364 | if mm.type(p) == "pattern" then return p end -- already compiled | 371 | if mm.type(p) == "pattern" then return p end -- already compiled |
365 | p = p .. " " -- for better reporting of column numbers in errors when at EOF | 372 | p = p .. " " -- for better reporting of column numbers in errors when at EOF |
366 | local cp, label, suffix = pattern:match(p, 1, defs) | 373 | local cp, label, suffix = pattern:match(p, 1, defs) |
367 | if #errfound > 0 then | 374 | if #errfound > 0 then |
368 | local lines = {} | 375 | local lines = splitlines(p) |
369 | for line in p:gmatch("[^\r\n]+") do tinsert(lines, line) end | ||
370 | local errors = {} | 376 | local errors = {} |
371 | for i, err in ipairs(errfound) do | 377 | for i, err in ipairs(errfound) do |
372 | if #err == 1 then | 378 | if #err == 1 then |