summaryrefslogtreecommitdiffstats
path: root/unix/configure.in
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2002-08-28 22:48:10 (GMT)
committerdavygrvy <davygrvy@pobox.com>2002-08-28 22:48:10 (GMT)
commit278f7c88ca3a17fed8af94c6ec45b4f5dda49861 (patch)
tree9276aaf344a0938ea3d864552a3843ba199c4540 /unix/configure.in
parent3932d4560e1130460563ce7f09cbdc6e8e5fe204 (diff)
downloadtcl-278f7c88ca3a17fed8af94c6ec45b4f5dda49861.zip
tcl-278f7c88ca3a17fed8af94c6ec45b4f5dda49861.tar.gz
tcl-278f7c88ca3a17fed8af94c6ec45b4f5dda49861.tar.bz2
* generic/tclEnv.c:
* unix/configure.in: * win/tclWinPort.h: putenv() on some systems copies the buffer rather than taking reference to it. This causes memory leaks and is know to effect mswindows (msvcrt) and NetBSD 1.5.2 . This patch tests for this behavior and turns on -DHAVE_PUTENV_THAT_COPIES=1 when approriate. Thanks to David Welton for assistance. [Bug 414910] * unix/configure: regen'd
Diffstat (limited to 'unix/configure.in')
-rw-r--r--unix/configure.in36
1 files changed, 35 insertions, 1 deletions
diff --git a/unix/configure.in b/unix/configure.in
index e141949..b1d6918 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tcl installation
dnl to configure the system for the local environment.
#
-# RCS: @(#) $Id: configure.in,v 1.99 2002/08/28 08:47:47 dkf Exp $
+# RCS: @(#) $Id: configure.in,v 1.100 2002/08/28 22:48:39 davygrvy Exp $
AC_INIT(../generic/tcl.h)
AC_PREREQ(2.13)
@@ -373,6 +373,40 @@ if test $tcl_cv_char_signed = yes; then
fi
#--------------------------------------------------------------------
+# Does putenv() copy or not? We need to know to avoid memory leaks.
+#--------------------------------------------------------------------
+
+AC_MSG_CHECKING([for a putenv() that copies the buffer])
+AC_CACHE_VAL(tcl_cv_putenv_copy,
+ AC_TRY_RUN([
+ #include <stdlib.h>
+ #define OURVAR "havecopy=yes"
+ int main (int argc, char *argv[])
+ {
+ char *foo, *bar;
+ foo = (char *)strdup(OURVAR);
+ putenv(foo);
+ strcpy((char *)(strchr(foo, '=') + 1), "no");
+ bar = getenv("havecopy");
+ if (!strcmp(bar, "no")) {
+ /* doesn't copy */
+ return 0;
+ } else {
+ /* does copy */
+ return 1;
+ }
+ }
+ ],
+ tcl_cv_putenv_copy=no,
+ tcl_cv_putenv_copy=yes,
+ tcl_cv_putenv_copy=no)
+)
+AC_MSG_RESULT($tcl_cv_putenv_copy)
+if test $tcl_cv_putenv_copy = yes; then
+ AC_DEFINE(HAVE_PUTENV_THAT_COPIES)
+fi
+
+#--------------------------------------------------------------------
# Check for support of nl_langinfo function
#--------------------------------------------------------------------