From da4ee63f3f9b552f79e6b82d318d681e28773228 Mon Sep 17 00:00:00 2001 From: Reuh Date: Fri, 23 Aug 2019 23:16:52 +0200 Subject: [PATCH] Fixed line numbers in errors for Lua 5.1/LuaJIT, hopefully finally for some reason gmatch("[^\n]*") matches *two times* per line (one with the line, and an empty string) in Lua 5.1 and LuaJIT, but behave as expected in Lua 5.2/5.3... --- candran.can | 4 ++-- candran.lua | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/candran.can b/candran.can index b60384c..923e588 100644 --- a/candran.can +++ b/candran.can @@ -11,7 +11,7 @@ #import("lib.lua-parser.parser") local candran = { - VERSION = "0.9.0" + VERSION = "0.9.1" } --- Default options. @@ -248,7 +248,7 @@ function candran.messageHandler(message) if originalFile then local i = 0 - for l in originalFile:gmatch("([^\n]*)") do + for l in originalFile:gmatch("([^\n]*)\n") do i = i +1 if i == line then local extSource, lineMap = l:match(".*%-%- (.-)%:(%d+)$") diff --git a/candran.lua b/candran.lua index 82584c6..a7ea161 100644 --- a/candran.lua +++ b/candran.lua @@ -3584,7 +3584,7 @@ return parser -- ./lib/lua-parser/parser.lua:685 end -- ./lib/lua-parser/parser.lua:685 local parser = _() or parser -- ./lib/lua-parser/parser.lua:689 package["loaded"]["lib.lua-parser.parser"] = parser or true -- ./lib/lua-parser/parser.lua:690 -local candran = { ["VERSION"] = "0.9.0" } -- candran.can:14 +local candran = { ["VERSION"] = "0.9.1" } -- candran.can:14 candran["default"] = { -- candran.can:18 ["target"] = "lua53", -- candran.can:19 ["indentation"] = "", -- candran.can:20 @@ -3773,7 +3773,8 @@ end -- candran.can:245 if originalFile then -- candran.can:249 local i = 0 -- candran.can:250 for l in originalFile:gmatch("([^\ -]*)") do -- candran.can:251 +]*)\ +") do -- candran.can:251 i = i + 1 -- candran.can:252 if i == line then -- candran.can:253 local extSource, lineMap = l:match(".*%-%- (.-)%:(%d+)$") -- candran.can:254