lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, list,

This is more or less idle question (i.e. no big pain behind the fact
that I have no solution and no big hurry), but it has some practical
applications and I am curious. I also am a bit lazy (utter lack of
time, actually, sorry), and I admit that I did not do my homework.

We have some rather large existing Lua codebase (several hundreds KLOC
of private code), where we found some deviations which we would like
to fix.

In particular we want to find the string concatenations in loops:

local foo = ...
for ... do
  ...
  foo = something .. foo .. something .. else
  ...
end

We're not interested in concatenations that do not survive outside of
the loop (and there are much more of those):

local foo = ...
for ... do
  ...
  print(something .. foo .. something .. else)
  ...
end

The question is how to find these things in the codebase? Non-strict
solutions are OK, we're fine if we miss something or find a some false
positives and would have to filter them out manually.

I tried doing some simple grepping:

git grep -n -A 3 -B 10 '\.\.' schema | grep -A 13 for | grep '.lua'

...but this yields too many results.

Any better ways out there? Some Metalua coding is OK, but I forgot
most of the stuff, so you'll have to show me an example I can start
from.

Thanks,
Alexander.