mescc: Mes C Library: Prepare for M2-Planet: getenv.

* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-20 19:28:51 +02:00
parent b03046b370
commit 65e545d589
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 10 additions and 4 deletions

View File

@ -27,11 +27,17 @@ getenv (char const *s)
{
char **p = environ;
int length = strlen (s);
while (*p)
while (p[0] != 0)
{
if (!strncmp (s, *p, length) && *(*p + length) == '=')
return (*p + length + 1);
p++;
if (strncmp (s, p[0], length) == 0)
{
char *q = p[0] + length;
if (q[0] == '=')
return q + 1;
}
p = p + 1;
}
return 0;
}