summaryrefslogtreecommitdiff
path: root/coccinelle/strempty.cocci
blob: 7901da3652ce7bb4c9d023e2ffaf7cb84b15ac5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@@
/* Avoid running this transformation on the strempty function itself */
position p : script:python() { p[0].current_element != "strempty" };
expression s;
@@
(
- s@p ?: ""
+ strempty(s)
|
- s@p ? s : ""
+ strempty(s)
)

@@
position p : script:python() { p[0].current_element != "strempty" };
expression s;
@@
- if (!s@p)
-         s = "";
+ s = strempty(s);

@@
position p : script:python() { p[0].current_element != "strnull" };
expression s;
@@
(
- s@p ?: "(null)"
+ strnull(s)
|
- s@p ? s : "(null)"
+ strnull(s)
)

@@
position p : script:python() { p[0].current_element != "strnull" };
expression s;
@@
- if (!s@p)
-         s = "(null)";
+ s = strnull(s);

@@
position p : script:python() { p[0].current_element != "strna" };
expression s;
@@
(
- s@p ?: "n/a"
+ strna(s)
|
- s@p ? s : "n/a"
+ strna(s)
)

@@
position p : script:python() { p[0].current_element != "strna" };
expression s;
@@
- if (!s@p)
-         s = "n/a";
+ s = strna(s);