summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham.hm@gmail.com>2009-04-30 14:44:44 +0000
committerHisham Muhammad <hisham.hm@gmail.com>2009-04-30 14:44:44 +0000
commitf25d61293a8296b187a46ea636773aba3d51e7b6 (patch)
tree95f21b5223fb1f0cbfa5cc4bc545f2ecbf6bcf5b
parentde64f02f60de77181c0d3d5f77d382b562f11337 (diff)
downloadluacov-f25d61293a8296b187a46ea636773aba3d51e7b6.tar.gz
Fix report of longer sourcefile names. Bug reported by Guilherme Lopes.
-rwxr-xr-xsrc/luacov.lua33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/luacov.lua b/src/luacov.lua
index 21b8d12..0c97674 100755
--- a/src/luacov.lua
+++ b/src/luacov.lua
@@ -19,21 +19,24 @@ local function on_line(_, line_nr)
end
end
- local name = debug.getinfo(2, "S").short_src
- local file = data[name]
- if not file then
- file = {}
- file.max = 0
- data[name] = file
- end
- if line_nr > file.max then
- file.max = line_nr
- end
- local current = file[line_nr]
- if not current then
- file[line_nr] = 1
- else
- file[line_nr] = current + 1
+ local name = debug.getinfo(2, "S").source
+ if name:match("^@") then
+ name = name:sub(2)
+ local file = data[name]
+ if not file then
+ file = {}
+ file.max = 0
+ data[name] = file
+ end
+ if line_nr > file.max then
+ file.max = line_nr
+ end
+ local current = file[line_nr]
+ if not current then
+ file[line_nr] = 1
+ else
+ file[line_nr] = current + 1
+ end
end
end