fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / sys / sysvi386 / exec.c
blob6587d50a7cc8786699e6da7a464fa6b2a8449774
1 #include <sys/unistd.h>
2 #include <errno.h>
4 extern char **environ;
6 int
7 execv (const char *path, char * const *args) {
8 extern int execve (const char *, char * const *, char * const*);
9 return execve (path, args, environ);
12 int
13 execl(const char *path, const char *arg1, ...) {
14 return execv (path, &arg1);
18 * Copy string, until c or <nul> is encountered.
19 * NUL-terminate the destination string (s1).
22 static char *
23 strccpy (char *s1, char *s2, char c) {
24 char *dest = s1;
25 while (*s2 && *s2 != c) {
26 *s1++ = *s2++;
28 *s1 = 0;
29 return dest;
32 int
33 execvp(const char *file, char * const *args) {
34 extern char *getenv (const char *);
35 char *path = getenv ("PATH");
36 char buf[MAXNAMLEN];
38 if (file[0] == '/') { /* absolute pathname -- easy out */
39 return execv (file, args);
42 buf[0] = 0; /* lots of initialization here 8-) */
43 while (*path) {
44 strccpy (buf, path, ':');
45 strcat (buf, "/");
46 strcat (buf, file);
47 execv (buf, args);
48 if (errno != ENOENT)
49 return -1;
50 while (*path && *path != ':')
51 path++;
53 return -1;