diff options
Diffstat (limited to 'toplevel/opttoploop.ml')
| -rw-r--r-- | toplevel/opttoploop.ml | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/toplevel/opttoploop.ml b/toplevel/opttoploop.ml index a34e231aaf..1fa5a3fd08 100644 --- a/toplevel/opttoploop.ml +++ b/toplevel/opttoploop.ml @@ -300,8 +300,15 @@ let use_print_results = ref true let use_file ppf name = try - let filename = find_in_path !Config.load_path name in - let ic = open_in_bin filename in + let (filename, ic, must_close) = + if name = "" then + ("(stdin)", stdin, false) + else begin + let filename = find_in_path !Config.load_path name in + let ic = open_in_bin filename in + (filename, ic, true) + end + in let lb = Lexing.from_channel ic in Location.init lb filename; (* Skip initial #! line if any *) @@ -319,7 +326,7 @@ let use_file ppf name = | Exit -> false | Sys.Break -> fprintf ppf "Interrupted.@."; false | x -> Opterrors.report_error ppf x; false) in - close_in ic; + if must_close then close_in ic; success with Not_found -> fprintf ppf "Cannot find file %s.@." name; false |
