On Thu, 14 Jul 2022, Ævar Arnfjörð Bjarmason wrote: > How do I stop coccinelle from turning my "{ 0 };\n" into > "{\n\t\t0\n\t};\n"? > > I haven't been able to find in the docs how to disable formatting on the > "+"-side of a rule. I have a rule like: > > @@ > type T; > identifier I; > @@ > - T I; > + T I = { 0 }; > ... when != \( I \| &I \) > - memset(&I, 0, ...); > > Which produces the expected results as far as the patch is concerned: > > diff -u -p a/builtin/for-each-ref.c b/builtin/for-each-ref.c > --- a/builtin/for-each-ref.c > +++ b/builtin/for-each-ref.c > @@ -20,7 +20,9 @@ int cmd_for_each_ref(int argc, const cha > struct ref_sorting *sorting; > struct string_list sorting_options = STRING_LIST_INIT_DUP; > int maxcount = 0, icase = 0; > - struct ref_array array; > + struct ref_array array = { > + 0 > + }; > struct ref_filter filter; > struct ref_format format = REF_FORMAT_INIT; > struct strbuf output = STRBUF_INIT; > @@ -52,7 +54,6 @@ int cmd_for_each_ref(int argc, const cha > OPT_END(), > }; > > - memset(&array, 0, sizeof(array)); > memset(&filter, 0, sizeof(filter)); > > format.format = "%(objectname) %(objecttype)\t%(refname)"; > > But I'd like for that to be e.g.: > > struct ref_array array = { 0 }; > > Which is a common idiom both in this codebase (git) and elsewhere. > > Usually I can find an answer in one of the coccinelle.git's *.cocci > files, the man page, or the grammar PDF, but in this case I've come up > blank... Try --smpl-spacing. I'm not sure whether it affects newlines, though. julia