Coccinelle archive on lore.kernel.org
 help / color / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: "Enrico Weigelt, metux IT consult" <lkml@metux.net>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] how to replace obsolete #ifdef's
Date: Thu, 6 Jun 2019 07:46:29 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.1906060743270.2653@hadrien> (raw)
In-Reply-To: <69c34970-8b6d-a2a3-2e8b-0b6560f78505@metux.net>



On Wed, 5 Jun 2019, Enrico Weigelt, metux IT consult wrote:

> On 05.06.19 20:52, Julia Lawall wrote:
>
> Hi,
>
> > In principle you can remove some initializations and add them back.
>
> How can I match/remote on that "#ifdef ..." ?
>
> Tried that, but got similar errors like Markus got (see his recent
> mail).
>
> It seems that spatch currently just doesn't understand preprocessor
> directives at all, just treats them as literal strings. Maybe that
> even would be fine in my case, if I only could match on that.
>
> Any way for matching just a raw text pattern (w/o being parsed),
> which includes special chars (eg. #) ?

#ifdefs are comments.  If you remove a contiguous sequence of things, the
comments between them disappear as well.  If you add those things back,
the comments are gone.  The idea is as follows:

@r@
identifier i;
expression e1;
@@

struct i2c_driver i = {
         .driver = {
-        .of_match_table=e1,
+        .of_match_table=of_match_ptr(e1),
        },
};

@@
identifier r.i;
initialiser i1,i2;
@@

struct i2c_driver i = {
          .driver = {
-         i1,i2,
+         i1,i2,
          },
};

@@
identifier r.i;
initialiser i1,i2,i3;
@@

struct i2c_driver i = {
          .driver = {
-         i1,i2,i3,
+         i1,i2,i3,
          },
};

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

  reply index

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05 16:25 Enrico Weigelt, metux IT consult
2019-06-05 19:51 ` [Cocci] How to replace obsolete #ifdef's? Markus Elfring
2019-06-05 20:52 ` [Cocci] how to replace obsolete #ifdef's Julia Lawall
2019-06-05 21:42   ` Enrico Weigelt, metux IT consult
2019-06-06  5:46     ` Julia Lawall [this message]
2019-06-06  9:30       ` [Cocci] How to replace obsolete #ifdef's? Markus Elfring
2019-06-06 10:34         ` Julia Lawall
2019-06-06 14:20           ` Markus Elfring
2019-06-06 15:34             ` David Young
2019-06-07 12:01           ` Enrico Weigelt, metux IT consult
2019-06-07 12:30             ` Julia Lawall
2019-06-06  9:15     ` Markus Elfring
2019-06-06  9:39       ` Julia Lawall
2019-06-07 12:05         ` Enrico Weigelt, metux IT consult
2019-06-07 12:32           ` Julia Lawall
2019-06-07 13:40             ` Markus Elfring
2019-06-07 16:33               ` Julia Lawall
2019-06-07 17:26                 ` Markus Elfring
2019-06-07 17:36                 ` Markus Elfring
2019-06-07 18:48 ` Markus Elfring
2019-06-07 18:59   ` Julia Lawall
2019-06-08  7:49   ` [Cocci] Handling of designated initialisers by SmPL? Markus Elfring

Reply instructions:

You may reply publically 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.1906060743270.2653@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=lkml@metux.net \
    /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

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox