[Cocci] problem with transform of expression not line-wrapping as expected

Allan, Bruce W bruce.w.allan at intel.com
Mon Dec 11 23:27:26 CET 2017


I'm trying to transform the following piece of code:

int main(int argc, char **argv)
{
	pointer_to_foo = (struct long_named_struct *)
		func_foo(e1, a_long_expression_e2, (long_part_a_of_exp_3 *
						        long_part_b_of_exp_3),
			    nop_expr);
}


with the following cocci script:

@@
expression ptr,e1,e2,e3,nop;
type type;
@@
(
- ptr = (type *)func_foo(e1,e2,e3,nop);
+ ptr = long_func_bar(macro_foobar(e1),e2,e3,SOME_OTHER_DEFINE);
)

to get:

	pointer_to_foo = long_func_bar(macro_foobar(e1), a_long_expression_e2,
					(long_part_a_of_exp_3 *
					 long_part_b_of_exp_3),
					SOME_OTHER_DEFINE);

but instead end up with:

	pointer_to_foo = long_func_bar(macro_foobar(e1), a_long_expression_e2,
					(long_part_a_of_exp_3 * long_part_b_of_exp_3),
					SOME_OTHER_DEFINE);

The problem is with the (long_part_a_of_exp_3 * long_part_b_of_exp_3) which does not line wrap as I would expect and exceeds 80-columns.  Any suggestions?

Thanks,
Bruce.


More information about the Cocci mailing list