From 14d7e02285857226e26288c1ac83a14eb4fbd478 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 23 Mar 2020 10:45:24 +0800 Subject: add support for macro system expanding to Lua codes directly. --- src/MoonP/stacktraceplus.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/MoonP/stacktraceplus.h') diff --git a/src/MoonP/stacktraceplus.h b/src/MoonP/stacktraceplus.h index fcd887a..ea53885 100644 --- a/src/MoonP/stacktraceplus.h +++ b/src/MoonP/stacktraceplus.h @@ -334,16 +334,17 @@ local function getMoonLineNumber(fname, line) end end if source then - local i, target = 1, tonumber(line) + local current, target = 1, tonumber(line) + local findLine = line for lineCode in source:gmatch("([^\n]*)\n") do - if i == target then - local num = lineCode:match("--%s*(%d*)%s*$") - if num then - return fname, num - end - break + local num = lineCode:match("--%s*(%d+)%s*$") + if num then + findLine = num + end + if current == target then + return fname, findLine or line end - i = i + 1 + current = current + 1 end end return fname, line -- cgit v1.2.3-55-g6feb