On 08/03/2012 04:50 PM, Peter Senna Tschudin wrote:
> Dear list,
> 
> There is a patch that removes a semicolon after a switch:
> http://patchwork.linuxtv.org/patch/12987/
> 
> It can be described as:
> 
> @@
> @@
> switch (...) { }
> -;
> 
> There are 230 hits of this on recent Kernel. But I was wondering that
> every semicolon after curly braces may be style error. So I'm thinking
> on a semantic patch for removing semicolon after curly braces. The
> semantic patch:
> 
> @@
> statement S;
> @@
> S
> -;
> 
> works but there are many false positives for empty statements like:
> for (...)
>    ; /* <-- I do not want to remove this */
> 
> How can I avoid empty statements ending on ';'? Any ideas?
> 
> My first attempt, that do not work, was:
> @@
> @@
> {
> - };
> + }
> 
> []'s
> 
> Peter

Hi,

I think a lone ';' will match empty statement case, so something like this
should work:

@@
statement S;
@@
(
 ;
|
 S
-;
)

- Lars
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to