Hello,

is there a way to capture in a statement list the comments and empty
lines between statements?

I've got asked for scripting help to merge a ton of helper functions
into their only caller.

Of course it is trivial to do with coccinelle. But the comments and
empty lines get lost in the process:

  spatch merge.cocci -D func=foo_base merge.c > merge.diff


It is not a big issue, only about 55 functions to merge. So I can either
use the above script and add the comments and newlines back. Or copy the
stuff manually.

thanks
bye
        michael


@base@
identifier virtual.func;
statement list body;
type T;
@@
- T func(...) { body }


@@
identifier virtual.func;
statement list base.body;
@@
- return func(...);
+ body
int foo_base(int i, int j)
{
    i++;
    /* Now increment j too */
    j++;

    return i + j;
}

int foo(int i, int j)
{
    return foo_base(i, j);
}
--- /tmp/merge.c
+++ /tmp/cocci-output-18706-5610a6-merge.c
@@ -1,13 +1,8 @@
-int foo_base(int i, int j)
-{
-    i++;
-    /* Now increment j too */
-    j++;
 
-    return i + j;
-}
 
 int foo(int i, int j)
 {
-    return foo_base(i, j);
+    i++;
+    j++;
+    return i + j;
 }
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to