On Wed, 29 Oct 2014, Jean-Sébastien Pédron wrote:
> On 29.10.2014 11:26, Julia Lawall wrote:
> >> I wanted to be able to re-run spatch on an already patched content. The
> >> use case is to add new function prototypes manually and run spatch to
> >> handle the associated #define automatically.
> >
> > I think that you could do the following:
> >
> > @r@
> > identifier func;
> > @@
> > #define func BAR(func)
> >
> > @s@
> > identifier r.func;
> > position p;
> > @@
> >
> > func@p(...) {...}
> >
> > @@
> > identifier func;
> > position p != s.p;
> > @@
> >
> > +#define func BAR(func)
> > func(...) { ... }
>
> I tried this semantic patch and it doesn't work: more #define are added
> with each run.
OK, I will see what is wrong.
> FWIW, the "BAR" identifier is unique in my use case: I'm sure the
> original headers won't have it. That's why I took a simple approach in
> removing all previous #define. However, I'm willing to learn the correct
> way to handle this for a future usage :)
>
> I have an additional question: If there's a comment just above the
> function declaration/implementation, the #define is added above the
> comment. Is there a way to put it between the comment and the function?
No. It assumes that the comment is very attached to the function
definition.
julia_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci