summaryrefslogtreecommitdiff
path: root/test/globals.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/globals.lua')
-rw-r--r--test/globals.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/test/globals.lua b/test/globals.lua
index 03b977c3..baa75049 100644
--- a/test/globals.lua
+++ b/test/globals.lua
@@ -1,20 +1,19 @@
--- globals.lua
-- reads the output of luac -d -l -p and reports global variable usage
--- typical usage: luac -p -l -d file.lua | lua globals.lua | sort
+-- lines where a global is written to are marked with "*"
+-- typical usage: luac -p -l file.lua | lua globals.lua | sort
local P="^.*; " -- pattern to extract comments
-local l="" -- last line seen
while 1 do
local s=read()
if s==nil then return end
- if strfind(s,"%sSETLINE") then
- l=gsub(s,P,"")
- elseif strfind(s,"%sGETGLOBAL") then
+ if strfind(s,"%sGETGLOBAL") then
local g=gsub(s,P,"")
+ local _,_,l=strfind(s,"(%d+)")
write(g,"\t",l,"\n")
elseif strfind(s,"%sSETGLOBAL") then
local g=gsub(s,P,"")
- write(g,"*\t",l,"\n")
+ local _,_,l=strfind(s,"(%d+)")
+ write(g,"\t",l,"*\n")
end
end