OLD | NEW |
1 #include <stdlib.h> | 1 #include <stdlib.h> |
2 #include <string.h> | 2 #include <string.h> |
3 #include "libc.h" | 3 #include "libc.h" |
4 | 4 |
5 char *getenv(const char *name) | 5 char* getenv(const char* name) { |
6 { | 6 int i; |
7 » int i; | 7 size_t l = strlen(name); |
8 » size_t l = strlen(name); | 8 if (!__environ || !*name || strchr(name, '=')) |
9 » if (!__environ || !*name || strchr(name, '=')) return NULL; | 9 return NULL; |
10 » for (i=0; __environ[i] && (strncmp(name, __environ[i], l) | 10 for (i = 0; __environ[i] && |
11 » » || __environ[i][l] != '='); i++); | 11 (strncmp(name, __environ[i], l) || __environ[i][l] != '='); |
12 » if (__environ[i]) return __environ[i] + l+1; | 12 i++) |
13 » return NULL; | 13 ; |
| 14 if (__environ[i]) |
| 15 return __environ[i] + l + 1; |
| 16 return NULL; |
14 } | 17 } |
OLD | NEW |