diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1996-02-22 12:51:45 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1996-02-22 12:51:45 +0000 |
commit | c3223fadf86b307256773b6356af2062fce1e86f (patch) | |
tree | f38ecb283f7f74642813053722291ba531ec48c7 | |
parent | 43108e093800386fef09aefd93aa23cb9444b430 (diff) |
Makefile.nt: Nettoyages divers.
sys.c: adaptation de searchpath pour NT.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@654 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | byterun/Makefile.nt | 6 | ||||
-rw-r--r-- | byterun/sys.c | 52 |
2 files changed, 45 insertions, 13 deletions
diff --git a/byterun/Makefile.nt b/byterun/Makefile.nt index 73f6c38d2..179438526 100644 --- a/byterun/Makefile.nt +++ b/byterun/Makefile.nt @@ -23,10 +23,10 @@ install: $(MKLIB)$(LIBDIR)\libcamlrun.lib $(OBJS) if not exist $(LIBDIR)\caml mkdir $(LIBDIR)\caml cp mlvalues.h alloc.h misc.h $(LIBDIR)\caml - sed -e "/#include .*\/m.h\r ..\config\m.h" \ - -e "/#include .*\/s.h\r ..\config\s.h" \ + sed -e "/#include .*\/m.h/r ..\config\m.h" \ + -e "/#include .*\/s.h/r ..\config\s.h" \ -e "/#include /d" config.h > $(LIBDIR)\caml\config.h - sed -e "/#include .*gc\.h"/d" \ + sed -e "/#include .*gc\.h/d" \ -e "/#define Alloc_small/,/^}/d" \ -e "/Modify/,/^}/d" memory.h > $(LIBDIR)\caml\memory.h diff --git a/byterun/sys.c b/byterun/sys.c index 957885fad..d6a79e0aa 100644 --- a/byterun/sys.c +++ b/byterun/sys.c @@ -190,6 +190,8 @@ value sys_system_command(command) /* ML */ /* Search path function */ +#ifndef _WIN32 + #ifndef S_ISREG #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) #endif @@ -197,7 +199,7 @@ value sys_system_command(command) /* ML */ char * searchpath(name) char * name; { - static char fullname[512]; + char * fullname; char * path; char * p; char * q; @@ -208,19 +210,49 @@ char * searchpath(name) } path = getenv("PATH"); if (path == NULL) return 0; + fullname = stat_alloc(strlen(filename) + strlen(path) + 2); while(1) { - p = fullname; - while (*path != 0 && *path != ':') { - *p++ = *path++; - } + for (p = fullname; *path != 0 && *path != ':'; p++, path++) *p = *path; if (p != fullname) *p++ = '/'; - q = name; - while (*q != 0) { - *p++ = *q++; - } + for (q = name; *q != 0; p++, q++) *p = *q; + *p = 0; + if (stat(fullname, &st) == 0 && S_ISREG(st.st_mode)) break; + if (*path == 0) return 0; + path++; + } + return fullname; +} + +#else + +char * searchpath(name) + char * name; +{ + char * fullname; + char * path; + char * p; + char * q; + struct stat st; + + for (p = name; *p != 0; p++) { + if (*p == '/' || *p == '\\' || *p == ':') return name; + } + if (stat(name, &st) == 0) return name; + path = getenv("PATH"); + if (path == NULL) return 0; + fullname = stat_alloc(strlen(name) + strlen(path) + 6); + while(1) { + for (p = fullname; *path != 0 && *path != ';'; p++, path++) *p = *path; + if (p != fullname) *p++ = '\\'; + for (q = name; *q != 0; p++, q++) *p = *q; *p = 0; - if (stat(fullname, &st) == 0 && S_ISREG(st.st_mode)) return fullname; + if (stat(fullname, &st) == 0) break; + strcpy(p, ".exe"); + if (stat(fullname, &st) == 0) break; if (*path == 0) return 0; path++; } + return fullname; } + +#endif |