From ce53cbc1fc2edb02c00331efed51221880a3129e Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 24 Dec 2009 15:49:52 -0500 Subject: Convenience libifying; allow more NULLs with globals --- src/compiler.sml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/compiler.sml') diff --git a/src/compiler.sml b/src/compiler.sml index fc764205..b793ab60 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -270,9 +270,13 @@ structure M = BinaryMapFn(struct val compare = String.compare end) +val pathmap = ref (M.insert (M.empty, "", Config.libUr)) + +fun addPath (k, v) = pathmap := M.insert (!pathmap, k, v) + fun parseUrp' accLibs fname = let - val pathmap = ref (M.insert (M.empty, "", Config.libUr)) + val pathmap = ref (!pathmap) val bigLibs = ref [] fun pu filename = @@ -304,6 +308,20 @@ fun parseUrp' accLibs fname = handle OS.Path.Path => fname end + fun libify path = + (if Posix.FileSys.access (path ^ ".urp", []) then + path + else + path ^ "/lib") + handle SysErr => path + + fun libify' path = + (if Posix.FileSys.access (relify path ^ ".urp", []) then + path + else + path ^ "/lib") + handle SysErr => path + val absDir = OS.Path.mkAbsolute {path = dir, relativeTo = OS.FileSys.getDir ()} fun relifyA fname = @@ -559,9 +577,9 @@ fun parseUrp' accLibs fname = end | _ => ErrorMsg.error "Bad 'deny' syntax") | "library" => if accLibs then - libs := pu (relify arg) :: !libs + libs := pu (libify (relify arg)) :: !libs else - bigLibs := arg :: !bigLibs + bigLibs := libify' arg :: !bigLibs | "path" => (case String.fields (fn ch => ch = #"=") arg of [n, v] => pathmap := M.insert (!pathmap, n, v) -- cgit v1.2.3