cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Mansour Moufid <mansourmoufid@gmail.com>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Newline escape in preprocessor
Date: Fri, 23 Oct 2020 08:05:48 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2010230805030.2707@hadrien> (raw)
In-Reply-To: <CALogXGVr7OYtWhrsZg7gnO+czzu6eM_GGThYSCYezgUmVjwqZA@mail.gmail.com>



On Thu, 22 Oct 2020, Mansour Moufid wrote:

> Hi,
>
> I'd like to add a statement after another within a preprocessor
> expression, but spatch adds the line without an escape (backslash).
>
> x.c:
>
>     #define X(a) x(a);
>
> (I know the above is not technically correct but it's super common.)
>
> x.cocci:
>
>     @@
>     expression e;
>     @@
>         x(e);
>     +   y(e);
>
> output:
>
>     $ spatch --sp-file x.cocci x.c
>     HANDLING: x.c
>     diff =
>     --- x.c
>     +++ /tmp/cocci-output-80658-7f90b1-x.c
>     @@ -1 +1,2 @@
>      #define X(a) x(a);
>     +y(a);
>
> I can think of two solutions, if an expression is inside a
> preprocessor statement: add a backslash before every newline, or skip
> the newline.

Indeed Coccinelle is not aware that the added code is within a #define.
Maybe it is easy to add that.

Thanks for the report.

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

  reply	other threads:[~2020-10-23  6:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  3:33 [Cocci] Newline escape in preprocessor Mansour Moufid
2020-10-23  6:05 ` Julia Lawall [this message]
2020-10-23 15:00 ` [Cocci] Adjusting replacement lists with SmPL? Markus Elfring
2020-10-23 15:11   ` Julia Lawall
2020-10-25  2:04     ` Mansour Moufid

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.22.394.2010230805030.2707@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=mansourmoufid@gmail.com \
    /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).