aboutsummaryrefslogtreecommitdiffstats
path: root/cparser/ErrorReports.ml
diff options
context:
space:
mode:
authorJacques-Henri Jourdan <jacques-henri.jourdan@inria.fr>2015-11-07 16:06:33 +0100
committerJacques-Henri Jourdan <jacques-henri.jourdan@inria.fr>2015-11-07 16:06:33 +0100
commit99761d109a799f6ca62471058463b5713f37eddc (patch)
treef8038305ef9596629eb6084ff64044451fac1656 /cparser/ErrorReports.ml
parent15e6fc9861641d03ac32ae9ac03b9a6fa68036e9 (diff)
parentd0049e3b6bafb3aa88e173c10183b564918de115 (diff)
downloadcompcert-kvx-99761d109a799f6ca62471058463b5713f37eddc.tar.gz
compcert-kvx-99761d109a799f6ca62471058463b5713f37eddc.zip
Merge remote-tracking branch 'origin/master' into parser_fix
Diffstat (limited to 'cparser/ErrorReports.ml')
-rw-r--r--cparser/ErrorReports.ml10
1 files changed, 9 insertions, 1 deletions
diff --git a/cparser/ErrorReports.ml b/cparser/ErrorReports.ml
index 4bbf3ded..a8976e42 100644
--- a/cparser/ErrorReports.ml
+++ b/cparser/ErrorReports.ml
@@ -92,6 +92,14 @@ let extract text (pos1, pos2) : string =
(* -------------------------------------------------------------------------- *)
+(* [compress text] replaces every run of at least one whitespace character
+ with exactly one space character. *)
+
+let compress text =
+ Str.global_replace (Str.regexp "[ \t\n\r]+") " " text
+
+(* -------------------------------------------------------------------------- *)
+
(* [sanitize text] eliminates any special characters from the text [text].
They are (arbitrarily) replaced with a single dot character. *)
@@ -182,7 +190,7 @@ let range text (e : element) : string =
(* Get the underlying source text fragment. *)
let fragment = extract text (pos1, pos2) in
(* Sanitize it and limit its length. Enclose it in single quotes. *)
- "'" ^ shorten width (sanitize fragment) ^ "'"
+ "'" ^ shorten width (sanitize (compress fragment)) ^ "'"
(* -------------------------------------------------------------------------- *)