let status,obj = disambiguate_obj status obj in
status, GrafiteAst.Obj (loc,obj)
-let try_open_in paths path =
+let try_open_in ~f paths path =
let rec aux = function
- | [] -> open_in path
+ | [] -> f path
| p :: tl ->
try
- open_in (p ^ "/" ^ path)
+ f (p ^ "/" ^ path)
with Sys_error _ -> aux tl
in
try
(GrafiteAstPp.pp_command cmd ^ "\n") :: status.moo_content_rev}
| GrafiteAst.Include (loc, path) ->
let path = MatitaMisc.obj_file_of_script path in
- let stream =
- try
- Stream.of_channel (try_open_in opts.include_paths path)
- with Sys_error _ -> raise (UnableToInclude path)
- in
- let status = ref status in
- !eval_from_stream_ref status stream (fun _ _ -> ());
- !status
+ (try
+ let ic = try_open_in ~f:open_in opts.include_paths path in
+ let stream = Stream.of_channel ic in
+ let status = ref status in
+ !eval_from_stream_ref status stream (fun _ _ -> ());
+ close_in ic;
+ !status
+ with Sys_error _ -> raise (UnableToInclude path))
| GrafiteAst.Set (loc, name, value) ->
let value =
if name = "baseuri" then