From f819014eb9763816140e0bc94f6a92e598687bcf Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Wed, 22 Feb 2012 17:25:16 +0100 Subject: [PATCH] strip camlp4 error messages Ignore-this: d9cee7dccc2270054156437b92e5e57e darcs-hash:20120222162516-c41ad-b97dd13591562c7fdb96ede631b501f4d392e32b --- src/camlp4/uTop_camlp4.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/camlp4/uTop_camlp4.ml b/src/camlp4/uTop_camlp4.ml index b189c3e..8197f99 100644 --- a/src/camlp4/uTop_camlp4.ml +++ b/src/camlp4/uTop_camlp4.ml @@ -55,7 +55,16 @@ let parse_toplevel_phrase_camlp4 str eos_is_error = | exn -> ([], exn) in - UTop.Error (locs, UTop.get_message print_camlp4_error exn) + let msg = UTop.get_message print_camlp4_error exn in + (* Camlp4 sometimes generate several empty lines at the end... *) + let idx = ref (String.length msg - 1) in + while !idx > 0 && msg.[!idx] = '\n' do + decr idx + done; + if !idx + 1 < String.length msg then + UTop.Error (locs, String.sub msg 0 (!idx + 1)) + else + UTop.Error (locs, msg) let parse_toplevel_phrase str eos_is_error = match parse_toplevel_phrase_camlp4 str eos_is_error with