summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-05-29 16:57:36 -0400
committerJakob Kaivo <jkk@ung.org>2024-05-29 16:57:36 -0400
commitb321e5a295074bba7e8ba52785a63bdc40c37878 (patch)
tree0ecfae566674a1a39fff726ff913f6a373ca5b61
parent824f22a3684209b1e11c87f20e6ff17beb8e73a3 (diff)
fix getenv()
-rw-r--r--src/stdlib/_stdlib.h4
-rw-r--r--src/stdlib/getenv.c6
2 files changed, 4 insertions, 6 deletions
diff --git a/src/stdlib/_stdlib.h b/src/stdlib/_stdlib.h
index 27054543..7edb9d98 100644
--- a/src/stdlib/_stdlib.h
+++ b/src/stdlib/_stdlib.h
@@ -48,16 +48,14 @@ struct __stdlib {
} atexit, at_quick_exit;
enum { REGULAR = 1, QUICK } exit_called;
unsigned int rand;
- char **environ;
constraint_handler_t constraint_handler;
+ char **environ;
};
extern struct __stdlib __stdlib;
#ifdef _POSIX_SOURCE
extern char **environ;
-#else
-#define environ __stdlib.environ
#endif
/*
diff --git a/src/stdlib/getenv.c b/src/stdlib/getenv.c
index c85c1922..5ef8f6a9 100644
--- a/src/stdlib/getenv.c
+++ b/src/stdlib/getenv.c
@@ -17,10 +17,10 @@ char * getenv(const char * name)
}
len = strlen(name);
- for (i = 0; environ[i] != NULL; i++) {
- if (!strncmp(environ[i], name, len) && environ[i][len] == '=') {
+ for (i = 0; __stdlib.environ[i] != NULL; i++) {
+ if (!strncmp(__stdlib.environ[i], name, len) && __stdlib.environ[i][len] == '=') {
__readonly(RO_UNLOCK, variable);
- strcpy(variable, environ[i] + len + 1);
+ strcpy(variable, __stdlib.environ[i] + len + 1);
__readonly(RO_LOCK, variable);
return variable;
}