On Thu, 8 Aug 2019, Christoph Böhmwalder wrote:

> So I've looked around in the demos/ and tests/ as well as the documentation,
> but I can't seem to figure out what I'm doing wrong:
>
> test.c
> ------
> int x, y;
>
>
> test.cocci
> ----------
> @@
> identifier x, y;
> @@
> - int x, y;
>
>
> Should be pretty straightforward, but the rule does not match. Is there
> another syntax to use here? In my real use case, I'm trying the same thing
> within a function, and that doesn't match either.
>
> Also, while playing around with it, I found this weird behaviour:
>
> @@
> identifier x, y;
> @@
> - int x;
>
> Yields:
>
> --- test.c
> +++ /tmp/cocci-output-6916-8bc8e1-test.c
> @@ -1 +1 @@
> -int x, y;
> +
>
>
> Not exactly what I expected...

SmPL doesn't support patterns with multiple variable declarations, because
there is really no way to tell whether they will be on one line or
multiple lines.

I'm not sure why the latter is not what you expected.  If you only
expected to remove the int x, then x should not have been an identifier
metavariable.

Basically, it is matching the pattern multiple times on the same code,
once for each variable.  If these matches cause all of the variables to go
away, the type and the ; are removed as well.

It seems that this resulted in adding a blank line.  That is indeed not
really ideal.

julia

>
> Thanks,
> --
> Christoph Böhmwalder
> LINBIT | Keeping the Digital World Running
> DRBD HA —  Disaster Recovery — Software defined Storage
> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to