> Basically, I intend to replace alls "%s" called with "mydata->name" by "%m" with "mydata" or "&mydata"
How far would you get the desired source code transformation based on
software extensions around a search pattern like the following.
..........
Which algorithm will become sufficient for your data processing needs
around the usage of functions with variadic arguments because of format strings?
Actually, I really didn't get why you're asking about that. because we are talking about X and you're asking for Y. but, either way. that is not the point. the point is because I am studying about the Coccinelle and I am just trying to figure out if the tool could detect "%s" called with "mydata->name" and then replace by "%m" and remove the "->name"
e.g: Once if we have:
int foo() {
int id;
struct mydata h1, *h2, s1, *s2;
char *city = "Hello";
my_printf("%s", s2->name);
my_printf("hi hi %s gggg",
h1.name);
my_printf("1234 %d
%s @ %d
%s |
%s -> city=%s", id,
s1.name, 12,
(*h2).name,
h2->name, city);
my_printf("aaaa %s hhhhh", h2->name);
my_printf("%s", city);
}
Then, replace by:
int foo() {
int id;
struct mydata h1, *h2, s1, *s2;
char *city = "Hello";
my_printf("%m", s2); my_printf("hi hi %s gggg", &h1); my_printf("1234 %d
%m @ %d
%m |
%m -> city=%s", id,
s1.name, 12,
(*h2).name,
h2->name, city);
my_printf("aaaa %s hhhhh", h2); my_printf("%s", city);
}
But, I've read again the other samples and the documentation. therefore, I didn't figure out how it should be. btw, thank you Julia for the suggestion performing the Ocalm/make_expr/replace. (Due to something wrong with the Coccinelle distributed by Brew/Osx. I just rewrote your sample using Python and the result was the same. But, I can't just replace all "%s" by "%m". As I said, it should be only if the "%s" was declared to use "mydata->name".
so, I still fighting yet. thanks in Advance.
Regards,
Markus