comparison: handle canonical for loops with variable limit
This change is not terribly useful on it's own perhaps, but I am partly
doing it to figure out a better way of handling increment, decrement. I'm
hoping that handling this specific case will show how to handle the generic
case.
Here is a canonical for loop:
for (i = 0; i < variable; i++) {
If the limit is a constant then this is handled by SMATCH_EXTRA.
Otherwise, what we want here is to say that at the end of the loop then
"i == variable". Except, in the fairly common case where we don't know that
"variable" is positive.
What we do is the first time through the loop then we set "i" to the &start
state. If "i" is incremented once we set it to the &increment state. If
it's modified other than that, then we set it to undefined.
If, at the end of the loop, i is set to &increment then the false condition
is ==.
This doesn't work for "i <= variable - 1" because that is a stupid way to
write code. But probably I will update it to handle that later.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>