From: Enrico Tassi Date: Thu, 26 Jul 2007 13:47:07 +0000 (+0000) Subject: added development path normalization, inclusions with '../' in the path should now... X-Git-Tag: make_still_working~6120 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=cd4901e20d0702d234ab43558cc37b495cc9d499;p=helm.git added development path normalization, inclusions with '../' in the path should now be handled correclty --- diff --git a/helm/software/matita/matitaGui.ml b/helm/software/matita/matitaGui.ml index e9302d5ac..2d5d8fa0a 100644 --- a/helm/software/matita/matitaGui.ml +++ b/helm/software/matita/matitaGui.ml @@ -783,7 +783,9 @@ class gui () = notify_exn exc; unlock_world () in - worker_thread := Some (Thread.create thread_main ()) in + thread_main (); + (* worker_thread := Some (Thread.create thread_main ()) *) + in let kill_worker = (* the following lines are from Xavier Leroy: http://alan.petitepomme.net/cwn/2005.11.08.html *) let interrupt = ref None in @@ -889,6 +891,8 @@ class gui () = | None -> true | Some path -> let is_prefix_of d1 d2 = + let d1 = MatitamakeLib.normalize_path d1 in + let d2 = MatitamakeLib.normalize_path d2 in let len1 = String.length d1 in let len2 = String.length d2 in if len2 < len1 then diff --git a/helm/software/matita/matitamakeLib.ml b/helm/software/matita/matitamakeLib.ml index 0ab251ddc..ee04e7878 100644 --- a/helm/software/matita/matitamakeLib.ml +++ b/helm/software/matita/matitamakeLib.ml @@ -42,6 +42,21 @@ let developments = ref [] let pool () = Helm_registry.get "matita.basedir" ^ "/matitamake/" ;; let rootfile = "/root" ;; +(* /foo/./bar/..//baz -> /foo/baz *) +let normalize_path s = + let s = Str.global_replace (Str.regexp "//") "/" s in + let l = Str.split (Str.regexp "/") s in + let rec aux = function + | [] -> [] + | he::".."::tl -> aux tl + | he::"."::tl -> aux (he::tl) + | he::tl -> he :: aux tl + in + (if Str.string_match (Str.regexp "^/") s 0 then "/" else "") ^ + String.concat "/" (aux l) + ^ (if Str.string_match (Str.regexp "/$") s 0 then "/" else "") +;; + let ls_dir dir = try let d = Unix.opendir dir in @@ -94,6 +109,7 @@ let dot_for_development devel = (* given a dir finds a development that is radicated in it or below *) let development_for_dir dir = + let dir = normalize_path dir in let is_prefix_of d1 d2 = let len1 = String.length d1 in let len2 = String.length d2 in @@ -157,6 +173,7 @@ let rebuild_makefile_devel development = (* creates a new development if possible *) let initialize_development name dir = + let dir = normalize_path dir in let name = Pcre.replace ~pat:" " ~templ:"_" name in let dev = {name = name ; root = dir} in dump_development dev; diff --git a/helm/software/matita/matitamakeLib.mli b/helm/software/matita/matitamakeLib.mli index 89a5e3b5f..8f6fda2e4 100644 --- a/helm/software/matita/matitamakeLib.mli +++ b/helm/software/matita/matitamakeLib.mli @@ -59,3 +59,4 @@ val name_for_development : development -> string (** @return dot file for a given development, if it exists *) val dot_for_development : development -> string option +val normalize_path: string -> string