Coccinelle release 1.0.0-rc4
[bpt/coccinelle.git] / tests / incpos1.cocci
1 @initialize:python@
2
3 first = 0
4 second = 0
5
6 @first_hdr@
7 position p;
8 @@
9
10 #include <...>@p
11
12 @script:python@
13 p << first_hdr.p;
14 @@
15
16 if first == 0:
17 print "keeping first hdr %s" % (p[0].line)
18 first = int(p[0].line)
19 else:
20 print "dropping first hdr"
21 cocci.include_match(False)
22
23 @second_hdr@
24 position p;
25 @@
26
27 #include "..."@p
28
29 @script:python@
30 p << second_hdr.p;
31 @@
32
33 if int(p[0].line) > first and first != 0:
34 print "dropping second hdr"
35 cocci.include_match(False)
36 else:
37 if second == 0:
38 print "keeping second hdr %s because of %d" % (p[0].line,first)
39 second = int(p[0].line)
40 else:
41 print "dropping second hdr"
42 cocci.include_match(False)
43
44 @done@
45 position second_hdr.p;
46 @@
47
48 +#include <foo.h>
49 #include "..."@p
50
51 @depends on never done@
52 @@
53
54 +#include <foo.h>
55 #include <...>