From: eck Date: Thu, 27 Sep 1990 16:52:07 +0000 (+0000) Subject: oops, _envp should have been _penvp X-Git-Tag: release-5-5~1507 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=c937359a4e0075e61555c22c33b46e87b978f4d8;p=ack.git oops, _envp should have been _penvp --- diff --git a/lang/cem/libcc.ansi/head_ac.e b/lang/cem/libcc.ansi/head_ac.e index 998112f19..3871d6a88 100644 --- a/lang/cem/libcc.ansi/head_ac.e +++ b/lang/cem/libcc.ansi/head_ac.e @@ -53,7 +53,7 @@ _penvp loc 21331 /* == 0x5353 */ bne *1 /* environ contains the magic value. Assume it's our own environ */ - lae _envp + lae _penvp loi _EM_PSIZE lae environ sti _EM_PSIZE diff --git a/lang/cem/libcc.ansi/misc/putenv.c b/lang/cem/libcc.ansi/misc/putenv.c index b7406c520..60d7d9ad0 100644 --- a/lang/cem/libcc.ansi/misc/putenv.c +++ b/lang/cem/libcc.ansi/misc/putenv.c @@ -10,18 +10,18 @@ #define ENTRY_INC 10 #define rounded(x) (((x / ENTRY_INC) + 1) * ENTRY_INC) -extern const char **_envp; -extern const char **environ; /* environ is a shadow name for _envp */ +extern const char **_penvp; +extern const char **environ; /* environ is a shadow name for _penvp */ int putenv(char *name) { - register const char **v = _envp; + register const char **v = _penvp; register char *r; static int size = 0; /* When size != 0, it contains the number of entries in the * table (including the final NULL pointer). This means that the - * last non-null entry is _envp[size - 2]. + * last non-null entry is _penvp[size - 2]. */ if (!name) return 0; @@ -48,7 +48,7 @@ putenv(char *name) } } *r = '='; - v = _envp; + v = _penvp; } if (!size) { @@ -62,18 +62,18 @@ putenv(char *name) if (!(v = malloc(rounded(i) * sizeof(char **)))) return 1; size = i; - p = _envp; - _envp = v; + p = _penvp; + _penvp = v; while (*v++ = *p++); /* copy the environment */ - v = _envp; + v = _penvp; } else if (!(size % ENTRY_INC)) { - if (!(v = realloc(_envp, rounded(size) * sizeof(char **)))) + if (!(v = realloc(_penvp, rounded(size) * sizeof(char **)))) return 1; - _envp = v; + _penvp = v; } v[size - 1] = name; v[size] = NULL; size++; - environ = _envp; + environ = _penvp; return 0; } diff --git a/lang/cem/libcc.ansi/stdlib/getenv.c b/lang/cem/libcc.ansi/stdlib/getenv.c index d9b5e7f35..ae9f0f6f7 100644 --- a/lang/cem/libcc.ansi/stdlib/getenv.c +++ b/lang/cem/libcc.ansi/stdlib/getenv.c @@ -6,12 +6,12 @@ #include -extern const char **environ; +extern const char **_penvp; char * getenv(const char *name) { - register const char **v = environ; + register const char **v = _penvp; register const char *p, *q; if (v == NULL || name == NULL) diff --git a/lang/cem/libcc.ansi/stdlib/system.c b/lang/cem/libcc.ansi/stdlib/system.c index 09d38cb91..9a786f682 100644 --- a/lang/cem/libcc.ansi/stdlib/system.c +++ b/lang/cem/libcc.ansi/stdlib/system.c @@ -10,11 +10,19 @@ extern int _fork(void); extern int _wait(int *); extern void _exit(int); -extern void _execl(char *, ...); +extern void _execve(const char *path, const char ** argv, const char ** envp); extern void _close(int); #define FAIL 127 +extern const char **_penvp; +static const char *exec_tab[] = { + "sh", /* argv[0] */ + "-c", /* argument to the shell */ + NULL, /* to be filled with user command */ + NULL /* terminating NULL */ + }; + int system(const char *str) { @@ -27,8 +35,9 @@ system(const char *str) for (i = 3; i <= 20; i++) _close(i); if (!str) str = "cd ."; /* just testing for a shell */ - _execl("/bin/sh", "sh", "-c", str, (char *) NULL); - /* get here if execl fails ... */ + exec_tab[2] = str; /* fill in command */ + _execve("/bin/sh", exec_tab, _penvp); + /* get here if execve fails ... */ _exit(FAIL); /* see manual page */ } while ((waitval = _wait(&exitstatus)) != pid) { @@ -39,7 +48,7 @@ system(const char *str) exitstatus = -1; } if (!str) { - if (exitstatus == FAIL << 8) /* execl() failed */ + if (exitstatus == FAIL << 8) /* execve() failed */ exitstatus = 0; else exitstatus = 1; /* /bin/sh exists */ }