Hi.
I've problem replacing parameterized #define using spatch.
For example, in test.c I have following defines:
...
#define old_junk(a, b, c) if (c) \
printf(a); \
else \
{ printf(b); }
#define new_stuff(a, b, b) my_func(a, b, c)
I would like to replace all the entries of old_junk(x, y, z); with
new_stuff(x, y, z);
I've tried following spatch:
@@
identifier old_junk, new_stuff, abort;
identifier a, b, c;
@@
- old_junk(a, b, c);
+ if (new_stuff(a, b, c))
+ abort();
Which used as "spatch --in-place --sp-file my.spatch tests/test.c"
Unfortunately all I got is "metavariable new_stuff not used in the - or
context code".
I've tried using "function new_stuff" instead and got another failure:
"MetaFunc, need more semantic info about id".
Which is the right way to make this sort of replacements?
I'd be happy to get points to the docs which clarify this part as I was
unable to find anything relevant on
http://coccinelle.lip6.fr/documentation.php
I went over tutorial slides as well and it feels like I'm missing
something obvious in here.
I'm using spatch 1.0.4 in latest ubuntu.
--
- Max Suraev <[email protected]> http://www.sysmocom.de/
=======================================================================
* sysmocom - systems for mobile communications GmbH
* Alt-Moabit 93
* 10559 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschaeftsfuehrer / Managing Directors: Harald Welte
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci