On Sun, 19 Aug 2012, Lars-Peter Clausen wrote:

Hi,

When a iterator, which has been defined with 'iterator name ...', is pretty
printed there are spaces missing between the different comma separated 
arguments.

E.g. the following in a cocci file

@@
iterator name for_each_set_bit;
@@
...
+for_each_set_bit(bit, bitmap, size)
...

results in a patch with
...
+for_each_set_bit(bit,bitmap,size)
...


I came up with the following patch

--- a/parsing_c/unparse_cocci.ml
+++ b/parsing_c/unparse_cocci.ml
@@ -826,7 +826,7 @@ and rule_elem arity re =
  | Ast.IteratorHeader(nm,lp,args,rp) ->
      pr_arity arity;
      ident nm; pr_space(); mcode print_string_box lp;
-      dots (function _ -> ()) expression args; close_box();
+      dots (function _ -> ()) arg_expression args; close_box();
      mcode print_string rp

  | Ast.SwitchHeader(switch,lp,exp,rp) ->

Thanks for the patch :)

Which seems to do the trick for some cases. But if the iterator is not followed by a statement in the cocci file, i.e. there is no body, it is not parsed as a iterator, but just as MetaId + ExprDotsTag and again it is printed without the spaces.

I'm not sure what you mean by there being no body. Could you give a concrete example? Do you mean when there is no change in the body?

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

Reply via email to