From 3ab9cd58e17ee221ef440781dba5c22d19c7e631 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 5 Feb 2018 08:56:01 -0600 Subject: [PATCH] with compat >= 4.02, use `Format.pp_print_text` directly --- src/core/CCFormat.ml | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/core/CCFormat.ml b/src/core/CCFormat.ml index 965ff9ed..5698c57b 100644 --- a/src/core/CCFormat.ml +++ b/src/core/CCFormat.ml @@ -46,35 +46,7 @@ let newline = Format.pp_force_newline let substring out (s,i,len): unit = string out (String.sub s i len) -let text out (s:string): unit = - let len = String.length s in - let i = ref 0 in - let search_ c = - try Some (String.index_from s !i c) with Not_found -> None - in - while !i < len do - let j_newline = search_ '\n' in - let j_space = search_ ' ' in - let on_newline j = - substring out (s, !i, j - !i); - newline out (); - i := j + 1 - and on_space j = - substring out (s, !i, j - !i); - Format.pp_print_space out (); - i := j + 1 - in - begin match j_newline, j_space with - | None, None -> - (* done *) - substring out (s, !i, len - !i); - i := len - | Some j, None -> on_newline j - | None, Some j -> on_space j - | Some j1, Some j2 -> - if j1CCFormat.sprintf "%S" s) "a\nb\nc" (sprintf_no_color "@[%a@]%!" text "a b c")