cocci: simplify check for trivial format strings

353d84c537 (coccicheck: make transformation for strbuf_addf(sb, "...") more precise) added a check to avoid transforming calls with format strings which contain percent signs, as that would change the result. It uses embedded Python code for that. Simplify this rule by using the regular expression matching operator instead. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Feb 1, 2018 at 19:56 UTC ae239fc8e57a5758e9db63c0bceaca933d217f81
1 file changed +1 -16
contrib/coccinelle/strbuf.cocci
+1 -16
@@ -1,21 +1,6 @@
1 @ strbuf_addf_with_format_only @
2 expression E;
3 -constant fmt;
4 -@@
5 - strbuf_addf(E,
6 -(
7 - fmt
8 -|
9 - _(fmt)
10 -)
11 - );
12 -
13 -@ script:python @
14 -fmt << strbuf_addf_with_format_only.fmt;
15 -@@
16 -cocci.include_match("%" not in fmt)
17 -
18 -@ extends strbuf_addf_with_format_only @
3 +constant fmt !~ "%";
4 @@
5 - strbuf_addf
6 + strbuf_addstr