summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2005-02-02 15:41:30 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2005-02-02 15:41:30 +0000
commitafd3a748232a9597c092c90df357766ccdb500a0 (patch)
tree186d93435066507af45e7ee9cdd7facc2ca88a29
parente495eab8720ba73b60d47019b26195b6c660415a (diff)
downloadocaml-afd3a748232a9597c092c90df357766ccdb500a0.tar.gz
Revu traitement du cas ou ocaml.exe n'est pas trouve (PR#3334,3432)
git-svn-id: http://caml.inria.fr/svn/ocaml/version/3.08@6770 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--win32caml/startocaml.c78
1 files changed, 34 insertions, 44 deletions
diff --git a/win32caml/startocaml.c b/win32caml/startocaml.c
index 491fab8ca4..f1a3562d9c 100644
--- a/win32caml/startocaml.c
+++ b/win32caml/startocaml.c
@@ -138,50 +138,40 @@ Errors: Almost all system calls will be verified
------------------------------------------------------------------------*/
int GetOcamlPath(void)
{
- char path[1024], *p;
-
-again:
- if (! ReadRegistry(HKEY_CURRENT_USER,
- "Software", "Objective Caml",
- "InterpreterPath", path)
- &&
- ! ReadRegistry(HKEY_LOCAL_MACHINE,
- "Software", "Objective Caml",
- "InterpreterPath", path)) {
- /* Key doesn't exist? Ask user */
- if (!BrowseForFile("Ocaml interpreter|ocaml.exe", path)) {
- ShowDbgMsg("Impossible to find ocaml.exe. I quit");
- exit(0);
- }
- WriteRegistry(HKEY_CURRENT_USER,
- "Software", "Objective Caml",
- "InterpreterPath", path);
- }
- /* Check if file exists */
- if (_access(path, 0) != 0) {
- char *errormsg = malloc(1024);
- wsprintf(errormsg,"Incorrect path for ocaml.exe:\n%s", path);
- ShowDbgMsg(errormsg);
- free(errormsg);
- path[0] = 0;
- WriteRegistry(HKEY_CURRENT_USER,
- "Software", "Objective Caml",
- "InterpreterPath", path);
- goto again;
- }
- strcpy(OcamlPath, path);
- p = strrchr(OcamlPath,'\\');
- if (p) {
- *p = 0;
- strcpy(LibDir,OcamlPath);
- *p = '\\';
- p = strrchr(LibDir,'\\');
- if (p && !stricmp(p,"\\bin")) {
- *p = 0;
- strcat(LibDir,"\\lib");
- }
- }
- return 1;
+ char path[1024], *p;
+
+ while (( !ReadRegistry(HKEY_CURRENT_USER,
+ "Software", "Objective Caml",
+ "InterpreterPath", path)
+ &&
+ !ReadRegistry(HKEY_LOCAL_MACHINE,
+ "Software", "Objective Caml",
+ "InterpreterPath", path))
+ || _access(path, 0) != 0) {
+ /* Registry key doesn't exist or contains invalid path */
+ /* Ask user */
+ if (!BrowseForFile("Ocaml interpreter|ocaml.exe", path)) {
+ ShowDbgMsg("Impossible to find ocaml.exe. I quit");
+ exit(0);
+ }
+ WriteRegistry(HKEY_CURRENT_USER,
+ "Software", "Objective Caml",
+ "InterpreterPath", path);
+ /* Iterate to validate again */
+ }
+ strcpy(OcamlPath, path);
+ p = strrchr(OcamlPath,'\\');
+ if (p) {
+ *p = 0;
+ strcpy(LibDir,OcamlPath);
+ *p = '\\';
+ p = strrchr(LibDir,'\\');
+ if (p && !stricmp(p,"\\bin")) {
+ *p = 0;
+ strcat(LibDir,"\\lib");
+ }
+ }
+ return 1;
}
static HANDLE hChildStdinRd, hChildStdinWr,hChildStdoutRd, hChildStdoutWr;