searchpath pour win32: chercher avec l'extension .exe dans le rep. courant.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@664 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 1996-02-23 13:54:09 +00:00
parent c411ad4f0c
commit 1798ab7e5e
1 changed files with 4 additions and 1 deletions

View File

@ -241,9 +241,12 @@ char * searchpath(name)
path = getenv("PATH");
if (path == NULL) return 0;
fullname = stat_alloc(strlen(name) + strlen(path) + 6);
strcpy(fullname, name);
strcat(fullname, ".exe");
if (stat(fullname, &st) == 0) return fullname;
while(1) {
for (p = fullname; *path != 0 && *path != ';'; p++, path++) *p = *path;
if (p != fullname) *p++ = '\\';
if (p != fullname && p[-1] != '\\') *p++ = '\\';
for (q = name; *q != 0; p++, q++) *p = *q;
*p = 0;
if (stat(fullname, &st) == 0) break;