Hi,

I have a semantic patch that inserts a new variable definition into a
function. I would like it if that variable definition is the only one
in the function, then it should add a new line to separate the
definition from following statements (Linux code formatting style).

I thought that doing this in two steps might be easier, i.e., add the
definition, then check and add a newline if a statement follows:

@@
identifier x;
identifier func;
statement S;
@@
func(...)
 {
struct kvm_cpu_context *x = ...;
+ newline;
S
...
 }

The above works as expected, and it adds "newline;" after the
definition of x. The thing is, is it possible to add an actual new
line, as opposed to a non-whitespace string? I tried just using a +
but that didn't work.

Thanks!
/fuad
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to