nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | libc of DJGPP 2.03 does not offer function unsetenv, |
||
3 | so this version from DJGPP 2.04 CVS tree is supplied. |
||
4 | This file will become superflous and will be removed |
||
5 | from the distribution as soon as DJGPP 2.04 has been |
||
6 | released. |
||
7 | */ |
||
8 | |||
9 | /* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */ |
||
10 | |||
11 | #include <libc/stubs.h> |
||
12 | #include <libc/unconst.h> |
||
13 | #include <errno.h> |
||
14 | #include <stdlib.h> |
||
15 | #include <string.h> |
||
16 | |||
17 | extern char **environ; |
||
18 | |||
19 | int |
||
20 | unsetenv(const char *name) |
||
21 | { |
||
22 | /* No environment == success */ |
||
23 | if (environ == 0) |
||
24 | return 0; |
||
25 | |||
26 | /* Check for the failure conditions */ |
||
27 | if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) |
||
28 | { |
||
29 | errno = EINVAL; |
||
30 | return -1; |
||
31 | } |
||
32 | |||
33 | /* Let putenv() do the work |
||
34 | * Note that we can just pass name directly as our putenv() treats |
||
35 | * this the same as passing 'name='. */ |
||
36 | /* The cast is needed because POSIX specifies putenv() to take a non-const |
||
37 | * parameter. Our putenv is well-behaved, so this is OK. */ |
||
38 | putenv (unconst (name, char*)); |
||
39 | |||
40 | return 0; |
||
41 | } |