X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Fsetenv.c;h=59f00bcc44845650cf637f1bc857ac786c95fe23;hb=daa269958ad8d50ef8154ccb65e58acaf7a6dd99;hp=d4670e5c99e8f1dffad18acc12acff60cf339833;hpb=22f1eb8bc17e5be72dd23d42d6aaa60196ac22e6;p=debian%2Ftar
diff --git a/gnu/setenv.c b/gnu/setenv.c
index d4670e5c..59f00bcc 100644
--- a/gnu/setenv.c
+++ b/gnu/setenv.c
@@ -1,6 +1,6 @@
/* -*- buffer-read-only: t -*- vi: set ro: */
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Copyright (C) 1992, 1995-2003, 2005-2010 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2003, 2005-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -17,12 +17,13 @@
along with this program. If not, see . */
#if !_LIBC
-# include
-#endif
-
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
optimizes away the name == NULL test below. */
-#define _GL_ARG_NONNULL(params)
+# define _GL_ARG_NONNULL(params)
+
+# define _GL_USE_STDLIB_ALLOC 1
+# include
+#endif
#include
@@ -50,7 +51,7 @@
#endif
#if _LIBC
-/* This lock protects against simultaneous modifications of `environ'. */
+/* This lock protects against simultaneous modifications of 'environ'. */
# include
__libc_lock_define_initialized (static, envlock)
# define LOCK __libc_lock_lock (envlock)
@@ -104,18 +105,18 @@ static void *known_values;
static char **last_environ;
-/* This function is used by `setenv' and `putenv'. The difference between
+/* This function is used by 'setenv' and 'putenv'. The difference between
the two functions is that for the former must create a new string which
- is then placed in the environment, while the argument of `putenv'
+ is then placed in the environment, while the argument of 'putenv'
must be used directly. This is all complicated by the fact that we try
- to reuse values once generated for a `setenv' call since we can never
+ to reuse values once generated for a 'setenv' call since we can never
free the strings. */
int
__add_to_environ (const char *name, const char *value, const char *combined,
int replace)
{
- register char **ep;
- register size_t size;
+ char **ep;
+ size_t size;
const size_t namelen = strlen (name);
const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
@@ -149,6 +150,9 @@ __add_to_environ (const char *name, const char *value, const char *combined,
: realloc (last_environ, (size + 2) * sizeof (char *)));
if (new_environ == NULL)
{
+ /* It's easier to set errno to ENOMEM than to rely on the
+ 'malloc-posix' and 'realloc-posix' gnulib modules. */
+ __set_errno (ENOMEM);
UNLOCK;
return -1;
}
@@ -251,7 +255,7 @@ __add_to_environ (const char *name, const char *value, const char *combined,
if (np == NULL)
#endif
{
- np = malloc (namelen + 1 + vallen);
+ np = (char *) malloc (namelen + 1 + vallen);
if (np == NULL)
{
#if defined USE_TSEARCH && !defined _LIBC
@@ -297,7 +301,7 @@ setenv (const char *name, const char *value, int replace)
return __add_to_environ (name, value, NULL, replace);
}
-/* The `clearenv' was planned to be added to POSIX.1 but probably
+/* The 'clearenv' was planned to be added to POSIX.1 but probably
never made it. Nevertheless the POSIX.9 standard (POSIX bindings
for Fortran 77) requires this function. */
int
@@ -348,6 +352,9 @@ weak_alias (__clearenv, clearenv)
#if HAVE_SETENV
# undef setenv
+# if !HAVE_DECL_SETENV
+extern int setenv (const char *, const char *, int);
+# endif
# define STREQ(a, b) (strcmp (a, b) == 0)
int