On Mon, 27 Jun 2011, Ajay Panyala wrote: > Is the comment relevant for matching ? > > Yes, I would like to transform only the occurrence of foo(..) > with the comment above it. The patch would replace all > occurrences of foo(...) instead of replacing only the one > with a comment above it. I am assuming the number of > calls to foo(..) in the code is unknown.
No, there is no way to match on comments. julia > Thanks > Ajay > > On Mon, Jun 27, 2011 at 11:05 AM, Nicolas Palix <[email protected]>wrote: > > > Hi, > > > > Have you already tried the following semantic patch ? > > Which problem you have with it ? > > > > -------------------------------- > > @@ > > expression x,y; > > @@ > > -foo(x,y) > > +bar(x,y,z) > > ... > > foo(x,y) > > -------------------------------- > > > > Do you always have two calls to foo or could you have more/less of them ? > > Is the comment relevant for matching ? > > > > Regards. > > > > On Mon, Jun 27, 2011 at 4:21 PM, Ajay Panyala <[email protected]> wrote: > > > Hello > > > Is something like the following possible. > > > > > > Original code : > > > ... > > > // some comment > > > foo(x,y); > > > ..... > > > foo(x,y) > > > The code should be transformed after applying a patch > > > such that only the occurrence of foo(...) with the comment > > > above it should be transformed, i.e > > > The code after the transformation should look like > > > ... > > > // some comment > > > bar(x,y,z) > > > ... > > > foo(x,y) > > > The second call to foo(..) should remain untouched. > > > > > > If possible, how should a patch be specified to handle this case. > > > Thanks > > > Ajay > > > _______________________________________________ > > > Cocci mailing list > > > [email protected] > > > http://lists.diku.dk/mailman/listinfo/cocci > > > (Web access from inside DIKUs LAN only) > > > > > > > > > > > > > > -- > > Nicolas Palix > > http://sardes.inrialpes.fr/~npalix/ > > > _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
