On Sun, 29 Nov 2020, Markus Elfring wrote:
> >> @Replacement@
> >> expression action, input1, input2, input3, target;
> >> identifier gs;
> >> @@
> >> -\( g_string_assign@gs \| g_string_append@gs \| g_string_append_c@gs \)
> >> (target, input1);
> >> action (
> >> + gs (
> >> target
> >> + , input1)
> >> ,
> >> ( input2, input3
> >> | input2
> >> ) );
> >
> > I find this way of writing disjunctions really unreadable.
>
> I am using different coding styles for SmPL disjunctions because of specific
> reasons.
>
>
> > You are saving some precious whitespace characters at the cost of making
> > any distinction between what is obligatory and what is optional.
>
> I tend to increase such distinction possibilities.
>
>
> >> The implementation of a function like “format_column_declaration” contains
> >> the following statements.
> >> https://gitlab.gnome.org/GNOME/evolution-data-server/-/blob/3de7ea5fdb5d5db4a097a4d888d77bd2778c1c30/src/addressbook/libedata-book/e-book-sqlite.c#L1898
> >>
> >> g_string_append (string, info->name);
> >> g_string_append_c (string, ' ');
> >>
> >> g_string_append (string, info->type);
> >>
> >> if (info->extra) {
> >> g_string_append_c (string, ' ');
> >> g_string_append (string, info->extra);
> >> }
> >
> > The rule matches for example on the first line and on the second line.
>
> Yes. - The transformation approach should work so in principle.
>
>
> > The match on the first line makes a change in the second line. The match
> > on the second line removes the second line. This is a conflict,
> > as reported.
>
> I imagine that the error message can be improved somehow.
>
>
> > The problem would be solved in this case by making two separate rules.
>
> I find this suggestion unclear at the moment.
A rule for each of the functions you have in the big disjunction you have
on the first line of your rule. But it only helps in your case because in
your C code, the first two lines have different function names.
>
> Two changes should be performed in combination for a code replacement.
> How should a separation help then?
>
> Can the shown change pattern be applied recursively?
You can follow the example in demos/iteration.cocci.
julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci