On Sat, Dec 18, 2010 at 09:53:50PM +0100, Julia Lawall wrote:
> On Sat, 18 Dec 2010, L. Alberto Giménez wrote:
> > - if (E) {
> > if (E)
> >         S1
> > - } else {
> > + else
> >         S2
> > -}
> > -------8<----------
> > 
> > But it doesn't work, I get a lot of errors when parsing the .cocci file 
> > itself: 
> These are warnings not errors.  They refer to the inability to apply 
> certain isomorphisms.  For example, neg_if switches the branches of an if 
> and replaces the test by its negation.  But adjusting the braces and the 
> else makes it unwilling to do this.  You could try leaving the else 
> unmodified, since you want to both remove and add it.  You can find the 
> various isomorphisms it would like to apply in the file standard.iso (I'm 
> not sure where this file ends up when you get coccinelle from Debian).
> 
> julia

Hi everyone,

At last I could manage to write a semantic patch that seems to work:

------8<---------------
@@
expression E;
statement S1,S2;
@@


if (E)
-{
S1
-}
else
-{
S2
-}
--------8<--------------

I didn't realize (until I found an example) that I could break the construction,
and that I can just delete the unneeded braces (instead of making a diff-like
substitution pattern (that didn't work properly, it found a lot of syntax
errors, don't know why).

Thanks a lot for your help and congratulations for your great tool.


Regards,
-- 
L. Alberto Giménez
JabberID [email protected]
GnuPG key ID 0x3BAABDE1
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to