scc

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

getenv.c (276B)


      1 #include <sys.h>
      2 
      3 #include <stdlib.h>
      4 #include <string.h>
      5 
      6 #undef getenv
      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 }