On 6 August 2012 22:49, ron minnich <[email protected]> wrote:
> This sounds wonderful but I don't feel smart enough to fill in the
> blanks yet :-)
>
> if you have some good examples I'd love it :-)
Here is what I came up with:
$ cat label.c
void divide(int i)
{
if (i == 0)
goto end;
printf("%f\n", 1.0/i);
end:
}
void dummy(void)
{
printf("dummy\n");
end:
}
$ cat label.cocci
@jumped_to@
identifier l;
position p;
@@
goto l;
...
l@p:
@@
identifier l;
position p != jumped_to.p;
@@
-l@p:
$ spatch -sp_file label.cocci label.c
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: label.c
diff =
--- label.c
+++ /tmp/cocci-output-11332-a5a94d-label.c
@@ -10,6 +10,5 @@ end:
void dummy(void)
{
printf("dummy\n");
-end:
}
$
BR Håkon Løvdal
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)