> 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
> import re
> f = open(p[0].file)
> lines = f.readlines()
> line = lines[int(p[0].line)-1]
> if not re.search('}[ \t]*;', line):
> cocci.include_match(False)
>
> @depends on r2@
The depends on is not needed. Python rules always succeed, as long as all
the metavariables are bound. The cocci.include_match(False) makes the
cases that you want to exclude here just disappear.
julia
> position r1.p;
> @@
> -;@p
> _______________________________________________
> Cocci mailing list
> [email protected]
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
>
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)