On Mon, 3 Jun 2019, Christoph Böhmwalder wrote:
> Hi,
>
> Consider the following C code and cocci patch:
>
> #include <stdio.h>
>
> int x;
>
> int main(int argc, char **argv)
> {
> if (y)
> do_something(x);
> }
>
>
> @@
> identifier x;
> @@
> - do_something(x);
> + if (x)
> + do_one_thing();
> + else
> + do_another_thing();
>
>
> For this input, spatch produces the following output:
>
>
> $ spatch --sp-file test.cocci test.c
> init_defs_builtins: /usr/lib/coccinelle/standard.h
> HANDLING: test.c
> diff =
> --- test.c
> +++ /tmp/cocci-output-18011-a28e99-test.c
> @@ -5,5 +5,8 @@ int x;
> int main(int argc, char **argv)
> {
> if (y)
> - do_something(x);
> + if (x)
> + do_one_thing();
> + else
> + do_another_thing();
> }
>
>
> Obviously it gets the indentation wrong there. Is this a bug?
>
> Adding curly braces around the outer if (in the C code) yields the correct
> indentation, while adding the braces around the inner if (in the cocci patch)
> does not.
>
> Adding an else branch to the outer if also produces the wrong indentation.
This is surely a bug. Thank you for the report.
julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci