CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [alex_v2] Help Needed for Pattern Matchin for Variable Seperator. : Edit Log



1arryb
User

May 19, 2009, 8:11 AM


Views: 13834
Re: [alex_v2] Help Needed for Pattern Matchin for Variable Seperator.

Vikas,

Not bad (definitely more concise than my attempt!). However, you'll get some false positives from boolean operators. Try your regex against:

Code
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:

Code
# 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)


Edit Log:
Post edited by 1arryb (User) on May 19, 2009, 8:24 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives