Setenv/putenv changes break existing code.
Cristian Gafton
gafton@redhat.com
Tue Aug 3 16:08:00 GMT 1999
On 2 Aug 1999, Ulrich Drepper wrote:
> You are quoting the standard and still don't see that your argument is
> wrong? The putenv() code as it is now is correct.
Yes, the change might be correct, but it breaks existing binary code, and
again we have symbol versioning and again we are not using it...
I think attached patch should help this...
1999-08-03 Cristian Gafton <gafton@redhat.com>
* sysdeps/generic/putenv.c (__new_putenv): rename from putenv and default for
GLIBC_2.1.2
(_old_putenv): new function
* stdlib/Versions: add putenv to new GLIBC 2.1.2
--- glibc-2.1/stdlib/Versions.gafton Tue Aug 3 18:59:48 1999
+++ glibc-2.1/stdlib/Versions Tue Aug 3 19:00:30 1999
@@ -90,4 +90,8 @@
# i*
imaxabs; imaxdiv;
}
+ GLIBC_2.1.2 {
+ # p*
+ putenv;
+ }
}
--- glibc-2.1/sysdeps/generic/putenv.c.gafton Mon Aug 2 14:55:35 1999
+++ glibc-2.1/sysdeps/generic/putenv.c Tue Aug 3 18:59:02 1999
@@ -50,7 +50,7 @@
/* Put STRING, which is of the form "NAME=VALUE", in the environment. */
int
-putenv (string)
+__new_putenv (string)
const char *string;
{
const char *const name_end = strchr (string, '=');
@@ -70,3 +70,32 @@
__unsetenv (string);
return 0;
}
+
+/* Put STRING, which is of the form "NAME=VALUE", in the environment. */
+int
+_old_putenv (string)
+ const char *string;
+{
+ const char *const name_end = strchr (string, '=');
+
+ if (name_end != NULL) {
+ char *name = alloca (name_end - string + 1);
+ memcpy (name, string, name_end - string);
+ name[name_end - string] = '\0';
+ return __add_to_environ (name, name_end + 1, NULL, 1);
+ }
+
+ __unsetenv (string);
+ return 0;
+}
+
+#if defined PIC && DO_VERSIONING
+default_symbol_version (__new_putenv, putenv, GLIBC_2.1.2);
+symbol_version (__old_putenv, putenv, GLIBC_2.0);
+#else
+# ifdef weak_alias
+weak_alias (__new_putenv, putenv)
+# endif
+#endif
+
+
Cristian
--
----------------------------------------------------------------------
Cristian Gafton -- gafton@redhat.com -- Red Hat, Inc.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UNIX is user friendly. It's just selective about who its friends are.
More information about the Libc-hacker
mailing list