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...


>
> julia
>
>> 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)
>>
>



-- 
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)

Reply via email to