Hi, The following should work.
@@ @@ +#include <foo.h> #include <...> On Fri, Jul 1, 2011 at 9:08 PM, Ajay Panyala <[email protected]> wrote: > Hello, > > The example from demos/first.cocci which inserts a header file include > right before the first function that appears in the code. > @initialize:python@ > > first = 0 > > @first_fct@ > type T; > identifier f; > position p; > @@ > > T f@p (...) {...} > > @script:python@ > p << first_fct.p; > @@ > > if p[0].line > first and first == 0: > first = p[0].line > else: > cocci.include_match(False) > > @@ > type T; > identifier f; > position first_fct.p; > @@ > > +#include <foo.h> > > T f@p (...) {...} > > How can this be modified to insert the header foo.h > right before the 1st header include (instead of right > before the 1st function) that appears in the > program i.e > before > ---------- > #include <something.h> > .. > .. > #include<somethingN.h> > > > after > ------ > #include <foo.h> > #include <something.h> > .. > .. > #include<somethingN.h> > > Thanks > Ajay > > _______________________________________________ > Cocci mailing list > [email protected] > http://lists.diku.dk/mailman/listinfo/cocci > (Web access from inside DIKUs LAN only) > > -- Nicolas Palix http://sardes.inrialpes.fr/~npalix/ _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
