From 3208e22ea89c459a5a7944ad8e82511d4a5328fa Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 16 Aug 2016 16:17:20 +0200 Subject: Added raw printing of types without formatting. This avoids introducing line breaks during printing of function types. Bug 18004 --- cparser/Cprint.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'cparser/Cprint.ml') diff --git a/cparser/Cprint.ml b/cparser/Cprint.ml index e80a4c8e..2a110104 100644 --- a/cparser/Cprint.ml +++ b/cparser/Cprint.ml @@ -126,7 +126,7 @@ let name_of_fkind = function | FDouble -> "double" | FLongDouble -> "long double" -let rec dcl pp ty n = +let rec dcl ?(pp_indication=true) pp ty n = match ty with | TVoid a -> fprintf pp "void%a%t" attributes a n @@ -160,7 +160,8 @@ let rec dcl pp ty n = | [] -> n pp | _ -> fprintf pp " (%a%t)" attributes a n end; - fprintf pp "(@["; + fprintf pp "("; + if pp_indication then fprintf pp "@["; begin match args with | None -> () | Some [] -> if vararg then fprintf pp "..." else fprintf pp "void" @@ -169,7 +170,8 @@ let rec dcl pp ty n = List.iter (fun a -> fprintf pp ",@ "; param a) al; if vararg then fprintf pp ",@ ..." end; - fprintf pp "@])" in + if pp_indication then fprintf pp "@]"; + fprintf pp ")" in dcl pp tres n' | TNamed(id, a) -> fprintf pp "%a%a%t" ident id attributes a n @@ -183,6 +185,9 @@ let rec dcl pp ty n = let typ pp ty = dcl pp ty (fun _ -> ()) +let typ_raw pp ty = + dcl ~pp_indication:false pp ty (fun _ -> ()) + type associativity = LtoR | RtoL | NA let precedence = function (* H&S section 7.2 *) -- cgit