On Tue, 28 Oct 2014, Jean-Sébastien Pédron wrote:
> On 28.10.2014 20:10, SF Markus Elfring wrote:
> >> Ok, then I must have a problem with my semantic patch, because it
> >> doesn't change anything :) I thought it was because of the parsing error.
> >
> > Would you like to show your SmPL approach here so that we could help you
> > more
> > eventually?
>
> Sure! I wanted to add a #define just above a function prototype or the
> function itself.
>
> Example #1:
> int foo();
>
> should become:
> #define foo BAR(foo)
> int foo();
>
> Example #2:
> int foo() { /* ... */ }
>
> should become:
> #define foo BAR(foo)
> int foo() { /* ... */ }
>
> Here's the script I used, which worked with example #1:
>
> ---8<---
> @rule1@
> identifier func;
> @@
>
> -#define func BAR(func)
>
> @rule2@
> identifier func;
> type ret;
> @@
>
> +#define func BAR(func)
> ret func(...);
> ---8<---
>
> I can handle example #2 with this one:
>
> ---8<---
> @rule1@
> identifier func;
> @@
>
> -#define func BAR(func)
>
> @rule2@
> identifier func;
> type ret;
> @@
>
> +#define func BAR(func)
> ret func(...) { ... }
> ---8<---
>
> However, I fail to assemble those two patches in a single concise one.
It is not possible. You need two rules.
julia
>
> Thank you for offering your help :)
>
> --
> Jean-Sébastien Pédron
>
> _______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci