summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Stephane Glondu <steph@glondu.net>2011-04-19 16:44:20 +0200
committerGravatar Stephane Glondu <steph@glondu.net>2011-04-19 16:44:20 +0200
commit9d27ae09786866b6e3d7b79d1fa7667e5e2aa309 (patch)
treea418d1edb3d53cdb4185b9719b7a70822cf5a24d /lib
parent6b691bbd2101fd39395c0d2135fd7c06a8915e14 (diff)
Imported Upstream version 8.3.pl2upstream/8.3.pl2
Diffstat (limited to 'lib')
-rw-r--r--lib/envars.ml7
-rw-r--r--lib/system.ml15
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/envars.ml b/lib/envars.ml
index efb2d3fa..b0db1a50 100644
--- a/lib/envars.ml
+++ b/lib/envars.ml
@@ -14,6 +14,13 @@ let coqbin () =
then Filename.concat Coq_config.coqsrc "bin"
else System.canonical_path_name (Filename.dirname Sys.executable_name)
+(* On win32, we add coqbin to the PATH at launch-time (this used to be
+ done in a .bat script). *)
+
+let _ =
+ if Coq_config.arch = "win32" then
+ Unix.putenv "PATH" (coqbin() ^ ";" ^ System.getenv_else "PATH" "")
+
let guess_coqlib () =
let file = "states/initial.coq" in
if Sys.file_exists (Filename.concat Coq_config.coqlib file)
diff --git a/lib/system.ml b/lib/system.ml
index 17d211f8..7744a79b 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -6,7 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-(* $Id: system.ml 13323 2010-07-24 15:57:30Z herbelin $ *)
+(* $Id: system.ml 13750 2010-12-24 09:55:54Z letouzey $ *)
open Pp
open Util
@@ -19,12 +19,21 @@ let safe_getenv_def var def =
Sys.getenv var
with Not_found ->
warning ("Environment variable "^var^" not found: using '"^def^"' .");
- flush Pervasives.stdout;
+ flush_all ();
def
let getenv_else s dft = try Sys.getenv s with Not_found -> dft
-let home = (safe_getenv_def "HOME" ".")
+(* On win32, the home directory is probably not in $HOME, but in
+ some other environment variable *)
+
+let home =
+ try Sys.getenv "HOME" with Not_found ->
+ try (Sys.getenv "HOMEDRIVE")^(Sys.getenv "HOMEPATH") with Not_found ->
+ try Sys.getenv "USERPROFILE" with Not_found ->
+ warning ("Cannot determine user home directory, using '.' .");
+ flush_all ();
+ "."
let safe_getenv n = safe_getenv_def n ("$"^n)