diff options
author | Roland McGrath <roland@gnu.org> | 2002-09-11 22:16:50 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2002-09-11 22:16:50 +0000 |
commit | 68b68cb3a475ed999d150376c32a30ed97bd6fe9 (patch) | |
tree | 7fc4fd1cbc7dd0d6aa6c1fc25315b139333faa2e /sysdeps/generic | |
parent | 0d35c2426d7a2682631da0433299e1c912f0ccfa (diff) | |
download | glibc-68b68cb3a475ed999d150376c32a30ed97bd6fe9.tar.gz glibc-68b68cb3a475ed999d150376c32a30ed97bd6fe9.tar.xz glibc-68b68cb3a475ed999d150376c32a30ed97bd6fe9.zip |
* sysdeps/generic/dl-environ.c (unsetenv): Redo last fix without
strncmp, keeps the code smaller for a non-performance-critical case.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/dl-environ.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/sysdeps/generic/dl-environ.c b/sysdeps/generic/dl-environ.c index 30fe5654d6..089e89e6e7 100644 --- a/sysdeps/generic/dl-environ.c +++ b/sysdeps/generic/dl-environ.c @@ -57,23 +57,30 @@ extern char **__environ attribute_hidden; int unsetenv (const char *name) { - const size_t len = strlen (name); char **ep; ep = __environ; while (*ep != NULL) - if (!strncmp (*ep, name, len) && (*ep)[len] == '=') - { - /* Found it. Remove this pointer by moving later ones back. */ - char **dp = ep; - - do - dp[0] = dp[1]; - while (*dp++); - /* Continue the loop in case NAME appears again. */ - } - else - ++ep; + { + size_t cnt = 0; + + while ((*ep)[cnt] == name[cnt] && name[cnt] != '\0') + ++cnt; + + if (name[cnt] == '\0' && (*ep)[cnt] == '=') + { + /* Found it. Remove this pointer by moving later ones to + the front. */ + char **dp = ep; + + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ + } + else + ++ep; + } return 0; } |