[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A practical code analysis question
- From: Alexander Gladysh <agladysh@...>
- Date: Sat, 18 Feb 2012 04:36:24 +0400
On Tue, Feb 14, 2012 at 23:13, Roberto Ierusalimschy
>> In particular we want to find the string concatenations in loops:
>> local foo = ...
>> for ... do
>> foo = something .. foo .. something .. else
> Wouldn't be easier to find string concatenations used with accumulators?
> I guess the following pattern (for plain Lua pattern matching),
> applied at each line of the program, would be a good filter:
> p = "^%s*([a-zA-Z_][a-zA-Z0-9_]*)%s*=.*%1%s*%.%."
> You may also need this other one:
> p = "^%s*([a-zA-Z_][a-zA-Z0-9_]*)%s*=.*%.%.%s*%1"
> (You may need to change it something if you want to detect accumulation
> over a table field, like a.x = a.x .. something...)
This approach would work for me, and will give even results closer to
what I need, thank you for the insight!