Mercurial > hg > octave-kai > gnulib-hg
annotate lib/putenv.c @ 17463:203c036eb0c6
bootstrap: support checksum utils without a --status option
* build-aux/bootstrap: Only look for sha1sum if updating po files.
Add sha1 to the list of supported checksum utils since it's now
supported through adjustments below.
(update_po_files): Remove the use of --status
in a way that will suppress all error messages, but since this is
only used to minimize updates, it shouldn't cause an issue.
Exit early if there is a problem updating the po file checksums.
(find_tool): Remove the check for --version support as this
is optional as per commit 86186b17. Don't even check for the
presence of the command as if that is needed, it's supported
through configuring prerequisites in bootstrap.conf.
Prompt that when a tool isn't found, one can define an environment
variable to add to the hardcoded search list.
author | Pádraig Brady <P@draigBrady.com> |
---|---|
date | Thu, 08 Aug 2013 11:08:49 +0100 (2013-08-08) |
parents | 2a9ec0103b3c |
children |
rev | line source |
---|---|
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16235
diff
changeset
|
1 /* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2013 Free Software |
12518
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
2 Foundation, Inc. |
363
ec4b36233380
Get putenv.c from /copies (derived from glibc).
Jim Meyering <jim@meyering.net>
parents:
311
diff
changeset
|
3 |
882 | 4 NOTE: The canonical source of this file is maintained with the GNU C |
5 Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. | |
363
ec4b36233380
Get putenv.c from /copies (derived from glibc).
Jim Meyering <jim@meyering.net>
parents:
311
diff
changeset
|
6 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8234
diff
changeset
|
7 This program is free software: you can redistribute it and/or modify it |
882 | 8 under the terms of the GNU General Public License as published by the |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8234
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or any |
882 | 10 later version. |
311 | 11 |
882 | 12 This program is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
9 | 16 |
882 | 17 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8234
diff
changeset
|
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
363
ec4b36233380
Get putenv.c from /copies (derived from glibc).
Jim Meyering <jim@meyering.net>
parents:
311
diff
changeset
|
19 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6275
diff
changeset
|
20 #include <config.h> |
311 | 21 |
9434
b839560eec9f
Define the putenv substitute in <stdlib.h> rather than in <config.h>.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
22 /* Specification. */ |
b839560eec9f
Define the putenv substitute in <stdlib.h> rather than in <config.h>.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
23 #include <stdlib.h> |
8214
822e9380142e
Minor fixups to port to Solaris 10 with Sun C 5.8.
Paul Eggert <eggert@cs.ucla.edu>
parents:
7302
diff
changeset
|
24 |
4347
df44e79ce676
.h files should stand alone, but we shouldn't include <sys/types.h>
Paul Eggert <eggert@cs.ucla.edu>
parents:
2411
diff
changeset
|
25 #include <stddef.h> |
1229
ed51f6d45a14
(sys/types.h): Include to get size_t on some systems.
Jim Meyering <jim@meyering.net>
parents:
959
diff
changeset
|
26 |
2411
90a1662ba7ec
Move inclusion of errno.h so it follows that of sys/types.h,
Jim Meyering <jim@meyering.net>
parents:
1570
diff
changeset
|
27 /* Include errno.h *after* sys/types.h to work around header problems |
90a1662ba7ec
Move inclusion of errno.h so it follows that of sys/types.h,
Jim Meyering <jim@meyering.net>
parents:
1570
diff
changeset
|
28 on AIX 3.2.5. */ |
90a1662ba7ec
Move inclusion of errno.h so it follows that of sys/types.h,
Jim Meyering <jim@meyering.net>
parents:
1570
diff
changeset
|
29 #include <errno.h> |
5159 | 30 #ifndef __set_errno |
4364 | 31 # define __set_errno(ev) ((errno) = (ev)) |
32 #endif | |
2411
90a1662ba7ec
Move inclusion of errno.h so it follows that of sys/types.h,
Jim Meyering <jim@meyering.net>
parents:
1570
diff
changeset
|
33 |
4672 | 34 #include <string.h> |
6275 | 35 #include <unistd.h> |
311 | 36 |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
37 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
38 # define WIN32_LEAN_AND_MEAN |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
39 # include <windows.h> |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
40 #endif |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
41 |
15639 | 42 #if _LIBC |
43 # if HAVE_GNU_LD | |
16020
af314a807a78
putenv: indent #definition of "environ" to placate cppi
Jim Meyering <meyering@redhat.com>
parents:
15639
diff
changeset
|
44 # define environ __environ |
15639 | 45 # else |
311 | 46 extern char **environ; |
15639 | 47 # endif |
363
ec4b36233380
Get putenv.c from /copies (derived from glibc).
Jim Meyering <jim@meyering.net>
parents:
311
diff
changeset
|
48 #endif |
ec4b36233380
Get putenv.c from /copies (derived from glibc).
Jim Meyering <jim@meyering.net>
parents:
311
diff
changeset
|
49 |
4364 | 50 #if _LIBC |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
51 /* This lock protects against simultaneous modifications of 'environ'. */ |
4364 | 52 # include <bits/libc-lock.h> |
53 __libc_lock_define_initialized (static, envlock) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
54 # define LOCK __libc_lock_lock (envlock) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
55 # define UNLOCK __libc_lock_unlock (envlock) |
4364 | 56 #else |
57 # define LOCK | |
58 # define UNLOCK | |
59 #endif | |
60 | |
61 static int | |
8234
e488ab5dfa4f
Avoid conflicting types for 'unsetenv' on FreeBSD.
Jim Meyering <jim@meyering.net>
parents:
8214
diff
changeset
|
62 _unsetenv (const char *name) |
4364 | 63 { |
64 size_t len; | |
17370
2a9ec0103b3c
putenv: port to Solaris 10
Paul Eggert <eggert@cs.ucla.edu>
parents:
17365
diff
changeset
|
65 #if !HAVE_DECL__PUTENV |
4364 | 66 char **ep; |
17365
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
67 #endif |
311 | 68 |
4364 | 69 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) |
70 { | |
71 __set_errno (EINVAL); | |
72 return -1; | |
73 } | |
74 | |
75 len = strlen (name); | |
76 | |
17370
2a9ec0103b3c
putenv: port to Solaris 10
Paul Eggert <eggert@cs.ucla.edu>
parents:
17365
diff
changeset
|
77 #if HAVE_DECL__PUTENV |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
78 { |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
79 int putenv_result, putenv_errno; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
80 char *name_ = malloc (len + 2); |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
81 memcpy (name_, name, len); |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
82 name_[len] = '='; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
83 name_[len + 1] = 0; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
84 putenv_result = _putenv (name_); |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
85 putenv_errno = errno; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
86 free (name_); |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
87 __set_errno (putenv_errno); |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
88 return putenv_result; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
89 } |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
90 #else |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
91 |
4364 | 92 LOCK; |
93 | |
94 ep = environ; | |
95 while (*ep != NULL) | |
96 if (!strncmp (*ep, name, len) && (*ep)[len] == '=') | |
97 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
98 /* Found it. Remove this pointer by moving later ones back. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
99 char **dp = ep; |
4364 | 100 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
101 do |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
102 dp[0] = dp[1]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
103 while (*dp++); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
104 /* Continue the loop in case NAME appears again. */ |
4364 | 105 } |
106 else | |
107 ++ep; | |
108 | |
109 UNLOCK; | |
110 | |
111 return 0; | |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
112 #endif |
4364 | 113 } |
114 | |
115 | |
116 /* Put STRING, which is of the form "NAME=VALUE", in the environment. | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
117 If STRING contains no '=', then remove STRING from the environment. */ |
9 | 118 int |
9434
b839560eec9f
Define the putenv substitute in <stdlib.h> rather than in <config.h>.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
119 putenv (char *string) |
9 | 120 { |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
121 const char *name_end = strchr (string, '='); |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
122 char **ep; |
9 | 123 |
124 if (name_end == NULL) | |
125 { | |
126 /* Remove the variable from the environment. */ | |
8234
e488ab5dfa4f
Avoid conflicting types for 'unsetenv' on FreeBSD.
Jim Meyering <jim@meyering.net>
parents:
8214
diff
changeset
|
127 return _unsetenv (string); |
9 | 128 } |
129 | |
17370
2a9ec0103b3c
putenv: port to Solaris 10
Paul Eggert <eggert@cs.ucla.edu>
parents:
17365
diff
changeset
|
130 #if HAVE_DECL__PUTENV |
17365
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
131 /* Rely on _putenv to allocate the new environment. If other |
17370
2a9ec0103b3c
putenv: port to Solaris 10
Paul Eggert <eggert@cs.ucla.edu>
parents:
17365
diff
changeset
|
132 parts of the application use _putenv, the !HAVE_DECL__PUTENV code |
17365
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
133 would fight over who owns the environ vector, causing a crash. */ |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
134 if (name_end[1]) |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
135 return _putenv (string); |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
136 else |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
137 { |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
138 /* _putenv ("NAME=") unsets NAME, so invoke _putenv ("NAME= ") |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
139 to allocate the environ vector and then replace the new |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
140 entry with "NAME=". */ |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
141 int putenv_result, putenv_errno; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
142 char *name_x = malloc (name_end - string + sizeof "= "); |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
143 if (!name_x) |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
144 return -1; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
145 memcpy (name_x, string, name_end - string + 1); |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
146 name_x[name_end - string + 1] = ' '; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
147 name_x[name_end - string + 2] = 0; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
148 putenv_result = _putenv (name_x); |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
149 putenv_errno = errno; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
150 for (ep = environ; *ep; ep++) |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
151 if (strcmp (*ep, name_x) == 0) |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
152 { |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
153 *ep = string; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
154 break; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
155 } |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
156 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
157 if (putenv_result == 0) |
17337
a72ac603a92f
putenv: fix heap corruption with mixed putenv/_putenv
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
158 { |
17365
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
159 /* _putenv propagated "NAME= " into the subprocess environment; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
160 fix that by calling SetEnvironmentVariable directly. */ |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
161 name_x[name_end - string] = 0; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
162 putenv_result = SetEnvironmentVariable (name_x, "") ? 0 : -1; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
163 putenv_errno = ENOMEM; /* ENOMEM is the only way to fail. */ |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
164 } |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
165 # endif |
17365
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
166 free (name_x); |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
167 __set_errno (putenv_errno); |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
168 return putenv_result; |
a154fccd3b21
putenv: avoid compilation warning on mingw
Eric Blake <eblake@redhat.com>
parents:
17347
diff
changeset
|
169 } |
17337
a72ac603a92f
putenv: fix heap corruption with mixed putenv/_putenv
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
170 #else |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
171 for (ep = environ; *ep; ep++) |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
172 if (strncmp (*ep, string, name_end - string) == 0 |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
173 && (*ep)[name_end - string] == '=') |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
174 break; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
175 |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
176 if (*ep) |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
177 *ep = string; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
178 else |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
179 { |
9 | 180 static char **last_environ = NULL; |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
181 size_t size = ep - environ; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
182 char **new_environ = malloc ((size + 2) * sizeof *new_environ); |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
183 if (! new_environ) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10384
diff
changeset
|
184 return -1; |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
185 new_environ[0] = string; |
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
186 memcpy (new_environ + 1, environ, (size + 1) * sizeof *new_environ); |
9749
daf5ba9fe2d9
Remove useless "if" tests before free. Deprecate "free" module.
Jim Meyering <meyering@redhat.com>
parents:
9434
diff
changeset
|
187 free (last_environ); |
9 | 188 last_environ = new_environ; |
311 | 189 environ = new_environ; |
17347
cec099cbf54f
putenv: port better to native Windows
Paul Eggert <eggert@cs.ucla.edu>
parents:
17337
diff
changeset
|
190 } |
9 | 191 |
192 return 0; | |
17370
2a9ec0103b3c
putenv: port to Solaris 10
Paul Eggert <eggert@cs.ucla.edu>
parents:
17365
diff
changeset
|
193 #endif |
9 | 194 } |