X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fgetter%2Fhttp_getter_map.ml;h=2b61e79761c008568d9552c240cb521667e8b705;hb=0c6a5aadb1a7746681a8e26fc0b009f847c10557;hp=57ec9273639c543efafde83cac2ceeb43851f5c1;hpb=384c369d4cbf5dd6cf1013902d3a218260400e73;p=helm.git diff --git a/helm/ocaml/getter/http_getter_map.ml b/helm/ocaml/getter/http_getter_map.ml index 57ec92736..2b61e7976 100644 --- a/helm/ocaml/getter/http_getter_map.ml +++ b/helm/ocaml/getter/http_getter_map.ml @@ -38,9 +38,21 @@ class map dbname = inherit ThreadSafe.threadSafe val mutable db = open_dbm () + val index_RE = Pcre.regexp "^theory:/.*/index.theory$" (*initializer Gc.finalise Dbm.close db (* close db on GC *)*) + (* Backward compatibility code to map + theory:/path/t.theory into theory:/path/t/index.theory + when cic:/path/t/ exists *) + method private normalize_key key = + if Pcre.pmatch ~rex:index_RE key && + (try ignore (Dbm.find db key); false with Not_found -> true) + then + (* we substitute /index.theory with .theory *) + String.sub key 0 (String.length key - 13) ^ ".theory" + else key + method add key value = self#doWriter (lazy ( try @@ -62,7 +74,9 @@ class map dbname = method resolve key = self#doReader (lazy ( - try Dbm.find db key with Not_found -> raise (Key_not_found key) + try + Dbm.find db (self#normalize_key key) + with Not_found -> raise (Key_not_found key) )) method iter (f: string -> string -> unit) =