]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - coccinelle/strempty.cocci
fix(journal-gatewayd): use relative urls (not starting with '/')
[thirdparty/systemd.git] / coccinelle / strempty.cocci
index 13ceb338f199dad900efa29f5f94d97db762a5e3..7901da3652ce7bb4c9d023e2ffaf7cb84b15ac5d 100644 (file)
@@ -1,48 +1,60 @@
 @@
+/* Avoid running this transformation on the strempty function itself */
+position p : script:python() { p[0].current_element != "strempty" };
 expression s;
 @@
-- s ?: ""
+(
+- s@p ?: ""
 + strempty(s)
-@@
-expression s;
-@@
-- s ? s : ""
+|
+- s@p ? s : ""
 + strempty(s)
+)
+
 @@
+position p : script:python() { p[0].current_element != "strempty" };
 expression s;
 @@
-- if (!s)
+- if (!s@p)
 -         s = "";
 + s = strempty(s);
+
 @@
+position p : script:python() { p[0].current_element != "strnull" };
 expression s;
 @@
-- s ?: "(null)"
+(
+- s@p ?: "(null)"
 + strnull(s)
-@@
-expression s;
-@@
-- s ? s : "(null)"
+|
+- s@p ? s : "(null)"
 + strnull(s)
+)
+
 @@
+position p : script:python() { p[0].current_element != "strnull" };
 expression s;
 @@
-- if (!s)
+- if (!s@p)
 -         s = "(null)";
 + s = strnull(s);
+
 @@
+position p : script:python() { p[0].current_element != "strna" };
 expression s;
 @@
-- s ?: "n/a"
+(
+- s@p ?: "n/a"
 + strna(s)
-@@
-expression s;
-@@
-- s ? s : "n/a"
+|
+- s@p ? s : "n/a"
 + strna(s)
+)
+
 @@
+position p : script:python() { p[0].current_element != "strna" };
 expression s;
 @@
-- if (!s)
+- if (!s@p)
 -         s = "n/a";
 + s = strna(s);