char *getenv(const char *name)
{
char **env;
- char *str;
+ char *env_str;
int len;
if(!_envp) return NULL;
if(!name) return NULL;
-
len = strlen((char*)name);
env = _envp;
- while(*env) {
- str = *env;
- if(str[len] == '=' && strncmp((char*)name, str, len) == 0) {
- return str+len+1;
+ while(*env)
+ {
+ env_str = *env;
+ if(strncmp(name, env_str, len) == 0 && env_str[len] == '=') {
+ return env_str+len+1;
}
env ++;
}
*/
EXPORT int strncmp(const char *s1, const char *s2, size_t n)
{
- if( n == 0 ) return 0;
- while(n -- && *s1 == *s2 && *s1 != '\0' && *s2 != '\0') {
+ while(n && *s1 == *s2 && *s1 != '\0' && *s2 != '\0')
+ {
s1++; s2++;
+ n --;
}
- return (int)*s1 - (int)*s2;
+ if( n == 0 )
+ return 0;
+ else
+ return (int)*s1 - (int)*s2;
}
EXPORT int strcasecmp(const char *s1, const char *s2)
{\r
// Init for env.c\r
_envp = envp;\r
+\r
+ #if 0 \r
+ {\r
+ int i = 0;\r
+ char **tmp;\r
+ _SysDebug("envp = %p", envp);\r
+ for(tmp = envp; *tmp; tmp++,i++)\r
+ {\r
+ _SysDebug("envp[%i] = '%s'", i, *tmp);\r
+ }\r
+ }\r
+ #endif\r
\r
// Init FileIO Pointers\r
stdin = &_iob[0];\r