Since I am not sure if the includes would use < > or " ", I could write rules for both.
+#include <foo.h> #include "..." +#include <foo.h> #include <...> before -------- #include <bar.h> #include "abc.h" after ------- *#include <foo.h>* #include <bar.h> *#include <foo.h>* #include "abc.h" But it would end up inserting the header multiple times if there are both of those includes that use < > and " " as shown above. Is there any way to apply only one of those rules if more than one match is found ? Thanks Ajay On Fri, Jul 1, 2011 at 4:00 PM, Julia Lawall <[email protected]> wrote: > On Fri, 1 Jul 2011, Nicolas Palix wrote: > > > On Fri, Jul 1, 2011 at 9:46 PM, Julia Lawall <[email protected]> wrote: > > > On Fri, 1 Jul 2011, Nicolas Palix wrote: > > > > > >> Hi, > > >> > > >> The following should work. > > >> > > >> @@ > > >> @@ > > >> > > >> +#include <foo.h> > > >> #include <...> > > > > > > That would add it before every include. Perhaps it is possible to put > a > > > position variable somewhere on an include. I will check. > > > > That is what I was expecting but when applied to > > > > #include <first.h> > > #include <second.h> > > #include <third.h> > > > > void main() { > > } > > > > I got the following > > > > --- 1st_header.c 2011-07-01 21:34:02.805323547 +0200 > > +++ /tmp/cocci-output-23061-cb581c-1st_header.c 2011-07-01 > > 21:50:31.511432597 +0200 > > @@ -1,3 +1,4 @@ > > +#include <smthg.h> > > #include <first.h> > > #include <second.h> > > #include <third.h> > > > > > > There is thus maybe some hack for that... > > Indeed, I think that that is the case. And if you put the + code > afterwards, I think it goes after the last one. > > julia
_______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
