+ Hashtbl.replace objs basepart (oldflags ++ newflags)
+ in
+ (* Variables used in backward compatibility code to map
+ theory:/path/t.theory into theory:/path/t/index.theory
+ when cic:/path/t/ exists *)
+ let the_candidate_for_remapping =
+ (* CSC: Here I am making a strong assumption: the pattern
+ can be only of the form [^:]*:/path where path is
+ NOT a regular expression *)
+ "theory:" ^ Pcre.replace ~rex:(Pcre.regexp "[^:]*:") pat
+ in
+ let index_not_generated_yet = ref true in
+ let valid_candidates = ref [] in
+ let candidates_found = ref [] in
+
+ (*(Lazy.force cic_map) # iter*)
+
+ (* depending on prefetch *)
+ let if_prefetch if_is if_not =
+ if is_prefetch_on() then if_is else if_not
+ in
+
+ let iter_on_right_thing = if_prefetch
+ (fun f -> List.iter (fun k -> f k "")
+ (Tree.ls_path regexp (deref_if_some uri_tree)))
+ (fun f -> (Lazy.force cic_map) # iter f)
+ in
+ let calculate_localpart = if_prefetch
+ (fun uri -> uri)
+ (fun uri -> Pcre.replace ~rex:dir_RE uri)
+ in
+ let check_if_x_RE = if_prefetch
+ (fun x_RE uri -> true)
+ (fun x_RE uri -> Pcre.pmatch ~rex:x_RE uri)
+ in
+ let check_if_dir_RE = check_if_x_RE dir_RE in
+ let check_if_obj_RE = check_if_x_RE obj_RE in
+
+ iter_on_right_thing
+ (fun key _ ->
+ (* we work in two ways:
+ * 1 iteration on the whole map
+ * 2 tree visit
+ *
+ * Since in the first case 'key' is a complete uri, while
+ * in the second case it is only the subtree rooted in the
+ * query regex, we must relay only on the localpath.
+ *
+ * example:
+ * query::= cic:/aaa/bbb/
+ *
+ * answer1 ::= the whole map
+ *
+ * aswer2 ::= [ "ccc/"; "c1.something"] where
+ * cic:/aaa/bbb/ccc/ and cic:/aaa/bbb/c1.something
+ * are the (partials) uri that matched query
+ *
+ * after the localpath extracion we have more uris in the first case,
+ * but at least the are all rooted in the same node.
+ *
+ * the Tree.get_frontier may be changed to return the same stuff as
+ * the map iteration+localpath extraction does, but I hope it is not
+ * necessary
+ *)
+ match key with
+ | uri when looking_for_dir && check_if_dir_RE uri ->
+ (* directory hit *)
+ let localpart = calculate_localpart uri in
+ if Pcre.pmatch ~rex:no_slashes_RE localpart then
+ begin
+ (* Backward compatibility code to map
+ theory:/path/t.theory into theory:/path/t/index.theory
+ when cic:/path/t/ exists *)
+ if Pcre.pmatch ~rex:theory_RE localpart then
+ candidates_found := localpart :: !candidates_found