summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-03-12 17:38:42 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-03-12 17:38:42 -0700
commit5615c9a9af487c19ab0bd30cb15d7bdb9af53560 (patch)
treeda5460962adeb04d0b5589f388a52a129095a41b /lib
parent84c3ab6860d2247e0da13d418545807a5f2f90fc (diff)
downloademacs-5615c9a9af487c19ab0bd30cb15d7bdb9af53560.tar.gz
Merge from gnulib.
This incorporates: 2013-03-12 mktime: fix configure typo 2013-03-11 regex: port to mingw's recent addition of undeclared alarm 2013-03-11 putenv: avoid compilation warning on mingw 2013-03-11 unistd: don't prevent Tru64 Unix from using gnulib strtod.
Diffstat (limited to 'lib')
-rw-r--r--lib/putenv.c76
-rw-r--r--lib/unistd.in.h4
2 files changed, 42 insertions, 38 deletions
diff --git a/lib/putenv.c b/lib/putenv.c
index ed666afc3bb..3813a11ece7 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -62,7 +62,9 @@ static int
_unsetenv (const char *name)
{
size_t len;
+#if !HAVE__PUTENV
char **ep;
+#endif
if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
{
@@ -126,45 +128,45 @@ putenv (char *string)
}
#if HAVE__PUTENV
- /* Rely on _putenv to allocate the new environment. If other
- parts of the application use _putenv, the !HAVE__PUTENV code
- would fight over who owns the environ vector, causing a crash. */
- if (name_end[1])
- return _putenv (string);
- else
- {
- /* _putenv ("NAME=") unsets NAME, so invoke _putenv ("NAME= ")
- to allocate the environ vector and then replace the new
- entry with "NAME=". */
- int putenv_result, putenv_errno;
- char *name_x = malloc (name_end - string + sizeof "= ");
- if (!name_x)
- return -1;
- memcpy (name_x, string, name_end - string + 1);
- name_x[name_end - string + 1] = ' ';
- name_x[name_end - string + 2] = 0;
- putenv_result = _putenv (name_x);
- putenv_errno = errno;
- for (ep = environ; *ep; ep++)
- if (strcmp (*ep, name_x) == 0)
- {
- *ep = string;
- break;
- }
+ /* Rely on _putenv to allocate the new environment. If other
+ parts of the application use _putenv, the !HAVE__PUTENV code
+ would fight over who owns the environ vector, causing a crash. */
+ if (name_end[1])
+ return _putenv (string);
+ else
+ {
+ /* _putenv ("NAME=") unsets NAME, so invoke _putenv ("NAME= ")
+ to allocate the environ vector and then replace the new
+ entry with "NAME=". */
+ int putenv_result, putenv_errno;
+ char *name_x = malloc (name_end - string + sizeof "= ");
+ if (!name_x)
+ return -1;
+ memcpy (name_x, string, name_end - string + 1);
+ name_x[name_end - string + 1] = ' ';
+ name_x[name_end - string + 2] = 0;
+ putenv_result = _putenv (name_x);
+ putenv_errno = errno;
+ for (ep = environ; *ep; ep++)
+ if (strcmp (*ep, name_x) == 0)
+ {
+ *ep = string;
+ break;
+ }
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- if (putenv_result == 0)
- {
- /* _putenv propagated "NAME= " into the subprocess environment;
- fix that by calling SetEnvironmentVariable directly. */
- name_x[name_end - string] = 0;
- putenv_result = SetEnvironmentVariable (name_x, "") ? 0 : -1;
- putenv_errno = ENOMEM; /* ENOMEM is the only way to fail. */
- }
-# endif
- free (name_x);
- __set_errno (putenv_errno);
- return putenv_result;
+ if (putenv_result == 0)
+ {
+ /* _putenv propagated "NAME= " into the subprocess environment;
+ fix that by calling SetEnvironmentVariable directly. */
+ name_x[name_end - string] = 0;
+ putenv_result = SetEnvironmentVariable (name_x, "") ? 0 : -1;
+ putenv_errno = ENOMEM; /* ENOMEM is the only way to fail. */
}
+# endif
+ free (name_x);
+ __set_errno (putenv_errno);
+ return putenv_result;
+ }
#else
for (ep = environ; *ep; ep++)
if (strncmp (*ep, string, name_end - string) == 0
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 675c7e6a552..2ea9af43652 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -61,8 +61,10 @@
/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
<unistd.h>. */
/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
+/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
+ included here. */
/* But avoid namespace pollution on glibc systems. */
-#ifndef __GLIBC__
+#if !defined __GLIBC__ && !defined __osf__
# define __need_system_stdlib_h
# include <stdlib.h>
# undef __need_system_stdlib_h