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
master
Xavier Leroy 1996-02-22 12:51:45 +00:00
parent 43108e0938
commit c3223fadf8
2 changed files with 45 additions and 13 deletions

View File

@ -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

View File

@ -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)) return fullname;
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) break;
strcpy(p, ".exe");
if (stat(fullname, &st) == 0) break;
if (*path == 0) return 0;
path++;
}
return fullname;
}
#endif