From 29657d5f10bd3796ba8f2cc1add48de8a02c1466 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Fri, 22 Jul 2005 16:01:13 +0000 Subject: [PATCH] Original semantics of a now almost random piece of code restored. Fixes the automatic compilation of .moos when matita is started from a directory that is not the root of a library. --- helm/matita/matitaEngine.ml | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/helm/matita/matitaEngine.ml b/helm/matita/matitaEngine.ml index 5c8a55eaf..767182bc1 100644 --- a/helm/matita/matitaEngine.ml +++ b/helm/matita/matitaEngine.ml @@ -501,21 +501,19 @@ let disambiguate_command status = function let status,obj = disambiguate_obj status obj in status, GrafiteAst.Obj (loc,obj) -let try_open_in ~f paths path = +let make_absolute paths path = let rec aux = function - | [] -> f path + | [] -> ignore (Unix.stat path); path | p :: tl -> + let path = p ^ "/" ^ path in try - f (p ^ "/" ^ path) - with Sys_error _ -> aux tl + ignore (Unix.stat path); path + with Unix.Unix_error _ -> aux tl in try aux paths - with Sys_error _ as exc -> - MatitaLog.error ("Unable to read " ^ path); - MatitaLog.error ("opts.include_paths was " ^ String.concat ":" paths); - MatitaLog.error ("current working directory is " ^ Unix.getcwd ()); - raise exc + with Unix.Unix_error _ as exc -> + command_error ("File " ^ path ^ " not found") ;; let eval_command opts status cmd = @@ -530,15 +528,15 @@ let eval_command opts status cmd = {status with moo_content_rev = (GrafiteAstPp.pp_command cmd ^ "\n") :: status.moo_content_rev} | GrafiteAst.Include (loc, path) -> - let path = MatitaMisc.obj_file_of_script path in - (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)) + let absolute_path = make_absolute opts.include_paths path in + let moopath = MatitaMisc.obj_file_of_script absolute_path in + let ic = + try open_in moopath with Sys_error _ -> raise (UnableToInclude moopath) in + let stream = Stream.of_channel ic in + let status = ref status in + !eval_from_stream_ref status stream (fun _ _ -> ()); + close_in ic; + !status | GrafiteAst.Set (loc, name, value) -> let value = if name = "baseuri" then -- 2.39.2