[Cocci] Macros and whitespace
Terry Wilson
twilson at digium.com
Fri Feb 10 22:55:55 CET 2012
I'm having trouble with Coccinelle changing the whitespace in a macro call that is un-related to the spatch. For example:
test.c
------
#define LIST(name, type) \
struct name { \
struct type *first; \
struct type *last; \
}
struct foo {
char *x;
LIST(, foo) thing;
};
test.cocci
----------
@s@
identifier x;
@@
struct foo {
...
char *x;
...
};
@@
identifier s.x;
@@
struct foo {
...
- char *x;
+ const char *x;
...
};
Produces the patch:
--- test.c
+++ /tmp/cocci-output-30072-a1d799-test.c
@@ -5,6 +5,6 @@ struct name { \
}
struct foo {
- char *x;
- LIST(, foo) thing;
+ const char *x;
+ LIST(,foo) thing;
};
Notice that the LIST macro has the space after the comma removed. A similar macro is used 100s of times throughout my codebase and I always end up having to fix it by hand when I make a change. I've tried playing around with -macro_file, etc. but no luck in keeping this from happening. Is this a bug, or is it something I should be able to work around myself?
Thanks,
Terry
More information about the Cocci
mailing list