oops, _envp should have been _penvp
authoreck <none@none>
Thu, 27 Sep 1990 16:52:07 +0000 (16:52 +0000)
committereck <none@none>
Thu, 27 Sep 1990 16:52:07 +0000 (16:52 +0000)
lang/cem/libcc.ansi/head_ac.e
lang/cem/libcc.ansi/misc/putenv.c
lang/cem/libcc.ansi/stdlib/getenv.c
lang/cem/libcc.ansi/stdlib/system.c

index 998112f..3871d6a 100644 (file)
@@ -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
index b7406c5..60d7d9a 100644 (file)
 #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;
 }
index d9b5e7f..ae9f0f6 100644 (file)
@@ -6,12 +6,12 @@
 
 #include       <stdlib.h>
 
-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)
index 09d38cb..9a786f6 100644 (file)
 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 */
        }