diff options
| author | Alain Frisch <alain@frisch.fr> | 2012-01-18 08:31:11 +0000 |
|---|---|---|
| committer | Alain Frisch <alain@frisch.fr> | 2012-01-18 08:31:11 +0000 |
| commit | c45bcb892d78f3182acb2805aef7ec6e23cce42a (patch) | |
| tree | b92b5d6becb9e67a198bc2e070d748eeef62bc3d /toplevel/opttoploop.ml | |
| parent | cdbb84ec682704379bac21a633cbd2b9e93b35a8 (diff) | |
| parent | 869feeb00704e0640c45ffe6aee6cc13e4077f79 (diff) | |
| download | ocaml-unused_declarations.tar.gz | |
Synchronize with trunk.unused_declarations
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unused_declarations@12034 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
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 |
