|
|
@@ -1,4 +1,5 @@
|
|
|
open Printf
|
|
|
+open Str
|
|
|
open Lexing
|
|
|
open Types
|
|
|
|
|
|
@@ -336,6 +337,18 @@ let get_line str n =
|
|
|
String.sub str linestart (lineend - linestart)
|
|
|
*)
|
|
|
|
|
|
+let count_tabs str upto =
|
|
|
+ let rec count n = function
|
|
|
+ | 0 -> n
|
|
|
+ | i -> count (if String.get str (i - 1) = '\t' then n + 1 else n) (i - 1)
|
|
|
+ in count 0 upto
|
|
|
+
|
|
|
+let tabwidth = 4
|
|
|
+
|
|
|
+let retab str = global_replace (regexp "\t") (repeat " " tabwidth) str
|
|
|
+
|
|
|
+let indent n = repeat (repeat " " (tabwidth - 1)) n
|
|
|
+
|
|
|
let prerr_loc (fname, ystart, yend, xstart, xend) =
|
|
|
let file = open_in fname in
|
|
|
|
|
|
@@ -349,7 +362,8 @@ let prerr_loc (fname, ystart, yend, xstart, xend) =
|
|
|
let left = if l = ystart then xstart else 1 in
|
|
|
let right = if l = yend then xend else linewidth in
|
|
|
if linewidth > 0 then (
|
|
|
- prerr_endline line;
|
|
|
+ prerr_endline (retab line);
|
|
|
+ prerr_string (indent (count_tabs line right));
|
|
|
for i = 1 to left - 1 do prerr_char ' ' done;
|
|
|
for i = left to right do prerr_char '^' done;
|
|
|
prerr_endline "";
|