
1arryb
User
May 19, 2009, 8:11 AM
Post #11 of 19
(32856 views)
|
Re: [alex_v2] Help Needed for Pattern Matchin for Variable Seperator.
[In reply to]
|
Can't Post
|
|
Vikas, Not bad (definitely more concise than my attempt!). However, you'll get some false positives from boolean operators. Try your regex against:
for(x=1; x<foo;x++) { for( x=1; x<foo;x++ ) { for( x = 1 ; x < foo; x ++ ) { if ( x == 3 ) { Also, (for alex), This kind of analysis can't be definitive unless you run the c code through the pre-processor first; otherwise, the code could be "tainted" indirectly via macro definitions including x. UPDATE: Here's the full test data I used:
# Unindented # simple assignment. x=1; x =1; x = 1; x-=1; x+=1; x -= 1; x += 1; # Unary operators. x++; x--; ++x; --x; # indented; x=1; x =1; x = 1; x = 1; x-=1; x+=1; x -= 1; x += 1; x++; x--; ++x; --x; # false positives xx=1; xxx=1; if (x == 3) { if ( x < 3 ) { # Loops and conditionals. for(x=1; x<foo;x++) { for( x=1; x<foo;x++ ) { for( x = 1 ; x < foo; x ++ ) { Cheers, Larry
(This post was edited by 1arryb on May 19, 2009, 8:24 AM)
|