Hello,

Le vendredi 13 juillet 2012 à 16:01 +0200, Julia Lawall a écrit :
> > > > #ifdef UNITTESTS
> > > > ...
> > > > #endif
> > > >
> > > > I would like to be able to not do matches on this part of the code. Is
> > > > their an easy way to do so ?
> > >
> > > No.  The matching process doesn't see the ifdefs.  There is a notion of
> > > skipping code that is under #if 0.  It could indeed be nice to generalize
> > > that to other constants.  Ideally, we would do partial evaluations as
> > > well, ie if we know that X is undefined, then perhaps X && Y is also
> > > undefined.  I can look into it.
> >
> > That could be great. I'm sure it could help in a lot of situation for
> > example changing API for a single OS on a complex project.
> 
> Attached is a patch that works for #ifdef and #ifndef.  In your case, you
> would give spatch the argument --undefined UNITTESTS.  It should then
> ignode the code under #ifdef UNITTESTS.  You can also specify several
> names, eg --defined FOO,BAR,XXX.  The names should be separated by commas,
> but not spaces.

That's just awesome. It works perfectly! Thanks a lot!

Do you plan to add it to the git tree ?

BR,
-- 
Eric Leblond 
Blog: http://home.regit.org/ - Portfolio: http://regit.500px.com/

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to