Browse Source

Disabled fancy error messages for stdin for now

Taddeus Kroes 12 years ago
parent
commit
7762f6851a
1 changed files with 19 additions and 1 deletions
  1. 19 1
      util.ml

+ 19 - 1
util.ml

@@ -316,6 +316,22 @@ let const_type = function
     | IntVal _   -> Int
     | FloatVal _ -> Float
 
+(*
+let get_line str n =
+    let rec find_start from = function
+        | n when n < 1 -> raise (Invalid_argument "n")
+        | 1 -> from
+        | n -> find_start ((String.index_from str from '\n') + 1) (n - 1)
+    in
+    let linestart = find_start 0 n in
+    let len = String.length str in
+    let lineend =
+        try String.index_from str linestart '\n'
+        with Not_found -> len
+    in
+    String.sub str linestart (lineend - linestart)
+*)
+
 let prerr_loc (fname, ystart, yend, xstart, xend) =
     let file = open_in fname in
 
@@ -353,7 +369,9 @@ let prerr_loc_msg loc msg =
         );
         eprintf "%s\n" msg;
 
-        if args.verbose >= 1 && loc != noloc then prerr_loc loc
+        if args.verbose >= 1 && loc != noloc then
+            try prerr_loc loc
+            with Sys_error _ -> ()
     );
     ()