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-0dff7051ff02master
parent
c411ad4f0c
commit
1798ab7e5e
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue