scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

getenv.c (283B)


      1 #include <stdlib.h>
      2 #include <string.h>
      3 
      4 #undef getenv
      5 
      6 extern char **_environ;
      7 
      8 char *
      9 getenv(const char *name)
     10 {
     11 	char **p, *s;
     12 	size_t len = strlen(name);
     13 
     14 	for (p = _environ; s = *p; ++p) {
     15 		if (!strncmp(name, s, len) && s[len] == '=')
     16 			return s + len + 1;
     17 	}
     18 	return NULL;
     19 }