diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-05-31 22:46:30 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-05-31 22:46:30 +0800 |
commit | dfc07e0c3404af762b80ba2e6948478d8830a08e (patch) | |
tree | 87c9a52b0ba91b1c552b7dfea253da89ad489d89 | |
parent | a4f79b266b890616feebb7ad476788b18c8864a9 (diff) | |
download | lpeglabel-dfc07e0c3404af762b80ba2e6948478d8830a08e.tar.gz lpeglabel-dfc07e0c3404af762b80ba2e6948478d8830a08e.tar.bz2 lpeglabel-dfc07e0c3404af762b80ba2e6948478d8830a08e.zip |
Clarifying adjustment in code
-rw-r--r-- | relabel.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/relabel.lua b/relabel.lua index 8b12811..6fdbb7c 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -352,14 +352,15 @@ local pattern = S * m.Cg(m.Cc(false), "G") * expect(exp, "NoPatt") / mm.P | |||
352 | 352 | ||
353 | local function lineno (s, i) | 353 | local function lineno (s, i) |
354 | if i == 1 then return 1, 1 end | 354 | if i == 1 then return 1, 1 end |
355 | local adjust = 0 | 355 | local adjustment = 0 |
356 | -- report the current line if at end of line, not the next | ||
356 | if s:sub(i,i) == '\n' then | 357 | if s:sub(i,i) == '\n' then |
357 | i = i-1 | 358 | i = i-1 |
358 | adjust = 1 | 359 | adjustment = 1 |
359 | end | 360 | end |
360 | local rest, num = s:sub(1,i):gsub("[^\n]*\n", "") | 361 | local rest, num = s:sub(1,i):gsub("[^\n]*\n", "") |
361 | local r = #rest | 362 | local r = #rest |
362 | return 1 + num, (r ~= 0 and r or 1) + adjust | 363 | return 1 + num, (r ~= 0 and r or 1) + adjustment |
363 | end | 364 | end |
364 | 365 | ||
365 | local function splitlines(str) | 366 | local function splitlines(str) |