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. 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? -- Jean-Sébastien Pédron
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
