2
0

globals.lua 418 B

12345678910111213
  1. -- reads luac listings and reports global variable usage
  2. -- lines where a global is written to are marked with "*"
  3. -- typical usage: luac -p -l file.lua | lua globals.lua | sort | lua table.lua
  4. while 1 do
  5. local s=io.read()
  6. if s==nil then break end
  7. local ok,_,l,op,g=string.find(s,"%[%-?(%d*)%]%s*([GS])ETGLOBAL.-;%s+(.*)$")
  8. if ok then
  9. if op=="S" then op="*" else op="" end
  10. io.write(g,"\t",l,op,"\n")
  11. end
  12. end