In certain cases, there is no space added after the Pointer type.
Examples of such cases are * const, * __attr and * const *.

In the Pointer case of pp_type_with_ident_rest and pp_type_left, if
the * is followed by anything within the type, add a space after the
printing.

Signed-off-by: Jaskaran Singh <jaskaransingh7654...@gmail.com>
---
 parsing_c/pretty_print_c.ml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/parsing_c/pretty_print_c.ml b/parsing_c/pretty_print_c.ml
index ccf8214d..a2e35588 100644
--- a/parsing_c/pretty_print_c.ml
+++ b/parsing_c/pretty_print_c.ml
@@ -806,6 +806,8 @@ and pp_string_format (e,ii) =
           (* bug: pp_type_with_ident_rest None t;      print_ident ident *)
           pr_elem i;
           iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
+          if iiqu <> [] || get_comments_after i <> []
+          then pr_space();
           pp_type_with_ident_rest ident t attrs Ast_c.noattr;
 
       (* ugly special case ... todo? maybe sufficient in practice *)
@@ -885,6 +887,8 @@ and pp_string_format (e,ii) =
       | (Pointer t, [i]) ->
           pr_elem i;
           iiqu +> List.iter pr_elem; (* le const est forcement apres le '*' *)
+          if iiqu <> [] || get_comments_after i <> []
+          then pr_space();
           pp_type_left t
 
       | (Array (eopt, t), [i1;i2]) -> pp_type_left t
-- 
2.21.1

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to