permit multiline comments and strings in macros
[bpt/coccinelle.git] / demos / sgrep / null.sgrep
1 @@
2 expression x;
3 type T1, T2, T3;
4 expression e1, e2;
5 expression f;
6 identifier fld;
7 @@
8 x = (T1) kmalloc(...)
9 ... when != x = e1
10 if(x == NULL) {
11 ... when != x = e2
12 (
13 *x
14 |
15 *((T2)x)
16 |
17 x->fld
18 |
19 (x)->fld
20 |
21 f(...,x,...)
22 |
23 f(...,(T3)x,...)
24 )
25 ...
26 }
27
28 @@
29 expression x;
30 type T1, T2, T3;
31 expression e1, e2;
32 expression f;
33 identifier fld;
34 statement S;
35 @@
36 x = (T1) kmalloc(...)
37 ... when != x = e1
38 if(x != NULL) S else {
39 ... when != x = e2
40 (
41 *x
42 |
43 *((T2)x)
44 |
45 x->fld
46 |
47 (x)->fld
48 |
49 f(...,x,...)
50 |
51 f(...,(T3)x,...)
52 )
53 ...
54 }
55
56 // for some "good" reason, isomorphisms don't apply to whencode
57 @@
58 expression x;
59 type T1, T2, T3;
60 expression e;
61 expression f;
62 identifier fld;
63 statement S;
64 @@
65 x = (T1) kmalloc(...);
66 ... when != \( if(\(x == NULL\|NULL == x\|!x\)) { ... \(return;\|return e;\) } \| if(\(x == NULL\|NULL == x\|!x\)) \(return;\|return e;\) \| if(\(x != NULL\|NULL != x\|x\)) S else { ... \(return;\|return e;\) } \| if(\(x != NULL\|NULL != x\|x\)) S else \(return;\|return e;\) \| x = e; \)
67 (
68 *x
69 |
70 *((T2)x)
71 |
72 x->fld
73 |
74 (x)->fld
75 |
76 f(...,x,...)
77 |
78 f(...,(T3)x,...)
79 )
80
81 @@
82 expression x;
83 type T1;
84 expression e1, e2;
85 @@
86 x = (T1) kmalloc(...)
87 ... when != x = e1
88 if(x == NULL) {
89 ... when != x = e2
90 return x;
91 }
92
93 // for some "good" reason, isomorphisms don't apply to whencode
94 @@
95 expression x;
96 type T1;
97 expression e;
98 @@
99 x = (T1) kmalloc(...);
100 ... when != \( if(\(x == NULL\|NULL == x\|!x\)) { ... \(return;\|return e;\) } \| if(\(x == NULL\|NULL == x\|!x\)) \(return;\|return e;\) \| x = e; \)
101 return x;