[Cocci] How to remove a macro...
Aaen, Andreas.Bach
andreas.bach.aaen at crisplant.com
Tue Mar 2 20:33:06 CET 2010
Thank you both. This was exactly what I was looking for.
Without "declarer name" it probably looks for identifiers.
Regards
Andreas Bach Aaen
-----Original Message-----
From: Nicolas Palix [mailto:npalix at diku.dk]
Sent: 2. marts 2010 18:58
To: Julia Lawall; Aaen, Andreas.Bach
Cc: cocci at diku.dk
Subject: Re: [Cocci] How to remove a macro...
On Tuesday 02 March 2010 16:54:50 Julia Lawall wrote:
> Try declarer name RELEASESTR; in the metavariable list.
Works for me with
@delete@
expression E;
declarer name RELEASESTR;
@@
-RELEASESTR(E);
@add@
expression delete.E;
@@
#include <std.h>
+RELEASESTR(E);
>
> julia
>
>
> On Tue, 2 Mar 2010, Nicolas Palix wrote:
>
> > On Tuesday 02 March 2010 14:55:22 Aaen, Andreas.Bach wrote:
> > > I have loads of c-files starting with:
> > >
> > > #include <std.h>
> > > RELEASESTR("$Id:$");
> > > #include <stdio.h>
> > > Now if I would like to remove the RELEASESTR statement, I would expect to do:
> > > @@
> > > expression E;
> > > @@
> > > -RELEASESTR(E);
> > > but that doens't match anything. Now what did I overlook?
> >
> > As it's a macro statement, it must be declare as such in a
> > Coccinelle macro header file. See standard.h for examples.
> > I think your macro file should contain:
> >
> > #define RELEASESTR(x) MACROSTATEMENT
> >
> >
> > Then give your macro file to spatch with the "-macro_file" option
> >
> >
> > >
> > > Actually I would like to build a litte more complex rule:
> > > ---------------
> > > @@
> > > @@
> > > -RELEASESTR("$Id:$");
> > > @r@
> > > @@
> > > #include <std.h>
> > > +RELEASESTR("$Id:$");
> > > -----------------
> > >
> > > So that I am sure that there only is one RELEASESTR in each file
> > > and that it's lpacved right after #include <std.h>
> > >
> > > Regards
> > > Andreas Bach Aaen
> > >
> >
>
--
Nicolas Palix
Tel: (+33) 1 44 27 87 25
More information about the Cocci
mailing list