Release coccinelle-0.1.8
[bpt/coccinelle.git] / demos / python_regexp.cocci
1 @initialize:python@
2 import re
3 m = re.compile('_new$')
4
5 @r_init@
6 expression E;
7 identifier id;
8 position p;
9 @@
10
11 E = id@p();
12
13 @script:python@
14 id << r_init.id;
15 @@
16
17 print "COCCI: Analyzing %s" % id
18 if m.search(id.ident) != None:
19 print "COCCI: %s matchs '_new$'" % id
20 else:
21 print "COCCI: %s discarded" % id
22 cocci.include_match(False)
23
24
25 @r_do@
26 expression E;
27 identifier id;
28 position r_init.p;
29 @@
30
31 E = id@p();
32 + if (E == NULL)
33 + goto err;