diff options
author | DJ Delorie <dj@redhat.com> | 2000-08-02 16:28:18 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2000-08-02 16:28:18 +0000 |
commit | 4c8d72ded51ac22172d4f2d0250ada6b0dd624ff (patch) | |
tree | 4573a70b613646456bd4fed93293c6355566c678 /winsup/cygwin/environ.cc | |
parent | ad8dea13f05b51769c9bef7e414f654588971c10 (diff) | |
download | newlib-4c8d72ded51ac22172d4f2d0250ada6b0dd624ff.zip newlib-4c8d72ded51ac22172d4f2d0250ada6b0dd624ff.tar.gz newlib-4c8d72ded51ac22172d4f2d0250ada6b0dd624ff.tar.bz2 |
* winsup.h: take out protections of environ, errno, allow C use
* *.cc: put winsup.h before other headers (for __INSIDE_CYGWIN__);
use cur_environ() instead of just environ
* times.cc: remove import protections
* glob.c: add winsup.h
* localtime.c: ditto
* smallprint.c: ditto
* Makefile.in: don't __INSIDE_CYGWIN__ as it messes up profiling.
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r-- | winsup/cygwin/environ.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index d834160..c081b70 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -7,9 +7,9 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ +#include "winsup.h" #include <errno.h> #include <stdlib.h> -#include "winsup.h" #include <stddef.h> #include <ctype.h> #include <fcntl.h> @@ -83,7 +83,7 @@ getwinenv (const char *env, const char *in_posix) { win_env *we = conv_envvars + i; const char *val; - if (!environ || !(val = in_posix ?: getenv(we->name))) + if (!cur_environ () || !(val = in_posix ?: getenv(we->name))) debug_printf ("can't set native for %s since no environ yet", we->name); else if (!envcache || !we->posix || strcmp (val, we->posix)) @@ -146,11 +146,11 @@ my_findenv (const char *name, int *offset) len++; } - for (p = environ; *p; ++p) + for (p = cur_environ (); *p; ++p) if (!strncmp (*p, name, len)) if (*(c = *p + len) == '=') { - *offset = p - environ; + *offset = p - cur_environ (); return (char *) (++c); } return NULL; @@ -199,13 +199,13 @@ _addenv (const char *name, const char *value, int overwrite) char **env; /* Search for the end of the environment. */ - for (env = environ; *env; env++) + for (env = cur_environ (); *env; env++) continue; - offset = env - environ; /* Number of elements currently in environ. */ + offset = env - cur_environ (); /* Number of elements currently in environ. */ /* Allocate space for additional element plus terminating NULL. */ - __cygwin_environ = (char **) realloc (environ, (sizeof (char *) * + __cygwin_environ = (char **) realloc (cur_environ (), (sizeof (char *) * (offset + 2))); if (!__cygwin_environ) return -1; /* Oops. No more memory. */ @@ -216,7 +216,7 @@ _addenv (const char *name, const char *value, int overwrite) char *envhere; if (!issetenv) - envhere = environ[offset] = (char *) name; /* Not setenv. Just + envhere = cur_environ ()[offset] = (char *) name; /* Not setenv. Just overwrite existing. */ else { /* setenv */ @@ -226,7 +226,7 @@ _addenv (const char *name, const char *value, int overwrite) int namelen = p - name; /* Length of name. */ /* Allocate enough space for name + '=' + value + '\0' */ - envhere = environ[offset] = (char *) malloc (namelen + valuelen + 2); + envhere = cur_environ ()[offset] = (char *) malloc (namelen + valuelen + 2); if (!envhere) return -1; /* Oops. No more memory. */ @@ -308,7 +308,7 @@ unsetenv (const char *name) while (my_findenv (name, &offset)) /* if set multiple times */ /* Move up the rest of the array */ - for (e = environ + offset; ; e++) + for (e = cur_environ () + offset; ; e++) if (!(*e = *(e + 1))) break; } |