diff options
| author | Lua Team <team@lua.org> | 1998-07-11 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 1998-07-11 12:00:00 +0000 |
| commit | 377347776f1f3d820f92151f70bec667f96d5e6b (patch) | |
| tree | cdb3ba26158df33547dfe765547177afcee119d1 /test/globals.lua | |
| parent | 4f8c5d0f284e1f4da717aea5008915f185cd2e05 (diff) | |
| download | lua-github-3.1.tar.gz | |
Lua 3.13.1
Diffstat (limited to 'test/globals.lua')
| -rw-r--r-- | test/globals.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/globals.lua b/test/globals.lua new file mode 100644 index 00000000..03b977c3 --- /dev/null +++ b/test/globals.lua @@ -0,0 +1,20 @@ +-- 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 + +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 + local g=gsub(s,P,"") + write(g,"\t",l,"\n") + elseif strfind(s,"%sSETGLOBAL") then + local g=gsub(s,P,"") + write(g,"*\t",l,"\n") + end +end |
