On Wed, 23 Jun 2021, Fuad Tabba wrote:
> 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.
I think that the problem is not that the change is not being made, but
that spatch doesn't think it's worth showing you the change, since the
only change is in the whitespace. Try adding the argument --force-diff
Note that you can cause this argument to always be used with your semantic
patch by putting
at the top of the file.
Cocci mailing list