On Fri, 14 May 2010, Arnaud Lacombe wrote:
> Hi,
>
> I'm meeting some an unwanted behavior with coccinelle-0.2.2.
> Considering the following block of code:
>
> #define ZERO 0
>
> extern int old;
>
> int main()
> {
>
> if (1
> #if 0
> && old
> #endif
> #if ZERO
> && old
> #endif
> #if 1 && 0
> && old
> #endif
> )
> return 0;
>
> return 1;
> }
>
> and the following spatch:
>
> @@
> @@
>
> - old
> + new
>
> Coccinelle gives me the following output:
>
> --- main.c 2010-05-14 13:15:49.000000000 -0400
> +++ /tmp/cocci-output-20786-66dc36-main.c 2010-05-14
> 13:18:49.000000000 -0400
> @@ -10,10 +10,10 @@ int main()
> && old
> #endif
> #if ZERO
> - && old
> + && new
> #endif
> #if 1 && 0
> - && old
> + && new
> #endif
> )
> return 0;
>
> As you can see, the first block is ignored while the two next are
> processed. From my point of view, I'd have expected all the three
> block to be matched and replaced. Am I missing anything ?
>
> Thanks,
> - Arnaud
>
> ps: how the `should old be a metavariable?' warning should be dealt
> with ? The documentation is unclear to me about this.
If you really intend to match only the identifier "old", then you can just
ignore the warning. Normally, one doesn't want to match explicit variable
names, and so the warning is helpful.
julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)