Rob Hoelz
2018-01-10 02:22:47 UTC
Hi Coccinelle community,
I just discovered Coccinelle a few days ago, and already my mind is reeling with the possibilities.
I'm doing some work porting the Claws Mail mail client to GTK3, and I think Coccinelle would be a
great tool to use to accomplish this task.
One of the thing I'm trying to use Coccinelle to do is to detect and patch string concatenation via
I try this); secondly, I can't seem to get "constant char *p" to match *any* string literals. For example,
make only that 0 match, but I'd like to match the "bar" string literal, and "constant char *p" doesn't seem to
work. Is there some way I can get Coccinelle to match only string literals to a metavariable?
Another quick question: is there a way to tell Coccinelle to dump its AST so I can see which type an expression
has been assigned? Having such a tool might help me get more familiar with the tool!
Thanks,
Rob
I just discovered Coccinelle a few days ago, and already my mind is reeling with the possibilities.
I'm doing some work porting the Claws Mail mail client to GTK3, and I think Coccinelle would be a
great tool to use to accomplish this task.
One of the thing I'm trying to use Coccinelle to do is to detect and patch string concatenation via
...
GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL);
@@
constant char *stock_constant =~ "^GTK_STOCK";
@@
-"+" stock_constant
+stock_constant
For starters, Coccinelle doesn't seem to recognize string juxtaposition (spatch gives me an error whenGTK_STOCK_NO, "+" GTK_STOCK_YES, NULL);
@@
constant char *stock_constant =~ "^GTK_STOCK";
@@
-"+" stock_constant
+stock_constant
I try this); secondly, I can't seem to get "constant char *p" to match *any* string literals. For example,
int
main(void)
{
const char *p = "bar";
return 0;
}
If I just use "constant p", it'll match the 0 literal in the return statement. I can use "constant int p" tomain(void)
{
const char *p = "bar";
return 0;
}
make only that 0 match, but I'd like to match the "bar" string literal, and "constant char *p" doesn't seem to
work. Is there some way I can get Coccinelle to match only string literals to a metavariable?
Another quick question: is there a way to tell Coccinelle to dump its AST so I can see which type an expression
has been assigned? Having such a tool might help me get more familiar with the tool!
Thanks,
Rob