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;
struct kvm_cpu_context *x = ...;
+ newline;

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.

Cocci mailing list

Reply via email to