Last change
on this file was 400, checked in by coas-nagasima, 5 years ago |
ファイルヘッダーの更新
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
562 bytes
|
Rev | Line | |
---|
[352] | 1 | #include <stdlib.h>
|
---|
| 2 | #include <string.h>
|
---|
| 3 | #include <errno.h>
|
---|
| 4 | #include "libc.h"
|
---|
| 5 |
|
---|
| 6 | char *__strchrnul(const char *, int);
|
---|
| 7 |
|
---|
| 8 | static void dummy(char *old, char *new) {}
|
---|
| 9 | weak_alias(dummy, __env_rm_add);
|
---|
| 10 |
|
---|
| 11 | int unsetenv(const char *name)
|
---|
| 12 | {
|
---|
| 13 | size_t l = __strchrnul(name, '=') - name;
|
---|
| 14 | if (!l || name[l]) {
|
---|
| 15 | errno = EINVAL;
|
---|
| 16 | return -1;
|
---|
| 17 | }
|
---|
| 18 | if (__environ) {
|
---|
| 19 | char **e = __environ, **eo = e;
|
---|
| 20 | for (; *e; e++)
|
---|
| 21 | if (!strncmp(name, *e, l) && l[*e] == '=')
|
---|
| 22 | __env_rm_add(*e, 0);
|
---|
| 23 | else if (eo != e)
|
---|
| 24 | *eo++ = *e;
|
---|
| 25 | else
|
---|
| 26 | eo++;
|
---|
| 27 | if (eo != e) *eo = 0;
|
---|
| 28 | }
|
---|
| 29 | return 0;
|
---|
| 30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.