aboutsummaryrefslogtreecommitdiffhomepage
path: root/library/loadpath.ml
diff options
context:
space:
mode:
authorGravatar Guillaume Melquiond <guillaume.melquiond@inria.fr>2015-12-22 14:10:31 +0100
committerGravatar Guillaume Melquiond <guillaume.melquiond@inria.fr>2015-12-22 14:10:31 +0100
commitd55676344c8dc0d9a87b2ef12ec2348281db4bf5 (patch)
treecce2b3c479ec4f9498e246b05c4b02a353fe5588 /library/loadpath.ml
parentafb9c9a65097dd901df18c443ca13ad4bf394985 (diff)
Move the From logic to Loadpath.expand_path.
Diffstat (limited to 'library/loadpath.ml')
-rw-r--r--library/loadpath.ml21
1 files changed, 11 insertions, 10 deletions
diff --git a/library/loadpath.ml b/library/loadpath.ml
index 622d390a2..16b419454 100644
--- a/library/loadpath.ml
+++ b/library/loadpath.ml
@@ -97,18 +97,19 @@ let filter_path f =
in
aux !load_paths
-let expand_path dir =
+let expand_path ?root dir =
let rec aux = function
| [] -> []
- | { path_physical = ph; path_logical = lg; path_implicit = implicit } :: l ->
- match implicit with
- | true ->
- (** The path is implicit, so that we only want match the logical suffix *)
- if is_dirpath_suffix_of dir lg then (ph, lg) :: aux l else aux l
- | false ->
- (** Otherwise we must match exactly *)
- if DirPath.equal dir lg then (ph, lg) :: aux l else aux l
- in
+ | { path_physical = ph; path_logical = lg; path_implicit = implicit } :: l ->
+ let success =
+ match root with
+ | None ->
+ if implicit then is_dirpath_suffix_of dir lg
+ else DirPath.equal dir lg
+ | Some root ->
+ is_dirpath_prefix_of root lg &&
+ is_dirpath_suffix_of dir (drop_dirpath_prefix root lg) in
+ if success then (ph, lg) :: aux l else aux l in
aux !load_paths
let locate_file fname =