On Fri, 3 Aug 2012, Lars-Peter Clausen wrote:

On 08/03/2012 06:36 PM, Julia Lawall wrote:
This one is a bit tricky, but it takes care of the case where cocci can't
parse the statement inform of the semicolon.

A simpler approach would be as follows:

@r1@
statement S;
position p;
  position p1;
@@
S

change to S@p1

;@p

@script:python r2@
p << r1.p;
@@

Change to call cocci.include_match(False) if p1[0].line_end != p[0].line

Hm, that's a good idea. But I guess it may produce false positives for
something like foo(); not_parseable(...);, but that's probably bad coding
style anyway.

And this still leaves us with the false positives for case:; and default:;

Maybe this could work:
@r_case@
position p;
@@
switch (...)
{
case ...: ...;@p
}

I don't think you need the ... in front of the ;

julia

@r_default@
position p;
@@
switch (...)
{
default: ...;@p
}

@r1@
statement S;
position p1;
position p != {r_case.p, r_default.p};
identifier label;
@@
(
label:;
|
S@p1;@p
)

@script:python r2@
p << r1.p;
p_case << r_case.p;
p1 << r1.p1;
@@
if p[0].line != p1[0].line_end:
        cocci.include_match(False)

@@
position r1.p;
@@
-;@p

_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to