cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: "Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Remove entire multidecl
Date: Thu, 8 Aug 2019 13:01:51 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1908081259010.2995@hadrien> (raw)
In-Reply-To: <7e131616-a0c6-5b59-78b8-a92b569cda27@linbit.com>

[-- Attachment #1: Type: text/plain, Size: 1642 bytes --]



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
> Cocci@systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
>

[-- Attachment #2: Type: text/plain, Size: 136 bytes --]

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

  reply	other threads:[~2019-08-08 11:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 10:51 [Cocci] Remove entire multidecl Christoph Böhmwalder
2019-08-08 11:01 ` Julia Lawall [this message]
2019-08-09  6:33   ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.1908081259010.2995@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=christoph.boehmwalder@linbit.com \
    --cc=cocci@systeme.lip6.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).