[Cocci] What is the spatch file for this change and the corresponding spatch command line invocation

Julia Lawall julia.lawall at lip6.fr
Wed Dec 3 19:13:50 CET 2014


On Wed, 3 Dec 2014, Francois Berenger wrote:

> Hello,
>
> I give up trying to write the spatch myself:
>
> Before file:
> ---
> int i;
>
> for ( ; ; ++i ) {
>   if (1) {
>     continue;
>   }
> }
> ---
>
> After file:
> ---
> int i;
>
> for ( ; ; ) {
>   if (1) {
>     ++i;
>     continue;
>   }
>   ++i;
> }
> ---
>
> All my trials don't work, not any change in the file appears
> if I try --in-place and -o fails because
> "-o can not be applied because there are no modified files"

It's hard to know how much generality you want.  But just for the code you
have shown, the following code works fine for me:

@@
expression i;
@@

for ( ; ;
- ++i
    ) {
  if (1) {
+   ++i;
    continue;
  }
}

julia


More information about the Cocci mailing list