source: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/env/unsetenv.c@ 337

Last change on this file since 337 was 337, checked in by coas-nagasima, 6 years ago

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 638 bytes
Line 
1#include <stdlib.h>
2#include <string.h>
3#include <errno.h>
4#include "libc.h"
5
6char *__strchrnul(const char *, int);
7
8#ifndef __c2__
9static void dummy(char *old, char *new) {}
10weak_alias(dummy, __env_rm_add);
11#else
12extern void __env_rm_add(char *old, char *new);
13#endif
14
15int unsetenv(const char *name)
16{
17 size_t l = __strchrnul(name, '=') - name;
18 if (!l || name[l]) {
19 errno = EINVAL;
20 return -1;
21 }
22 if (__environ) {
23 char **e = __environ, **eo = e;
24 for (; *e; e++)
25 if (!strncmp(name, *e, l) && l[*e] == '=')
26 __env_rm_add(*e, 0);
27 else if (eo != e)
28 *eo++ = *e;
29 else
30 eo++;
31 if (eo != e) *eo = 0;
32 }
33 return 0;
34}
Note: See TracBrowser for help on using the repository browser.