There are some hardcoded patterns in the C parser used by coccinelle to not process code under #if 0 #endif
The reason is that at least in the linux kernel, the code under such ifdef is often not valid C code. You can bypass with the -noif0_passing command line flag to spatch. On Fri, May 14, 2010 at 10:38 AM, Arnaud Lacombe <[email protected]> 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. > _______________________________________________ > Cocci mailing list > [email protected] > http://lists.diku.dk/mailman/listinfo/cocci > (Web access from inside DIKUs LAN only) > _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
