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
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to