cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] Newline escape in preprocessor
@ 2020-10-23  3:33 Mansour Moufid
  2020-10-23  6:05 ` Julia Lawall
  2020-10-23 15:00 ` [Cocci] Adjusting replacement lists with SmPL? Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: Mansour Moufid @ 2020-10-23  3:33 UTC (permalink / raw)
  To: cocci

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-25  2:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23  3:33 [Cocci] Newline escape in preprocessor Mansour Moufid
2020-10-23  6:05 ` Julia Lawall
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

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).