Scott Zhong wrote:
http://issues.apache.org/jira/browse/STDCXX-401

Title: test suite should honor TMPDIR

stdcxx-401 patch part 1 is in
http://mail-archives.apache.org/mod_mbox/stdcxx-dev/200803.mbox/%3cCFFDD
[EMAIL PROTECTED]

stdcxx-401 patch part 2 affects:

./src/file.cpp
./util/memchk.cpp
./bin/xbuildgen
./etc/config/makefile.rules
./etc/config/run_locale_utils.sh

Thanks Scott. I've committed your changes to the last three files.
The changes to file.cpp and memchk.cpp are outside the scope of
the issue and need some tweaking before they can be used. I'll
handle these tweaks myself but just as an FYI:

Index: src/file.cpp
===================================================================
--- src/file.cpp        (revision 634377)
+++ src/file.cpp        (working copy)
@@ -41,6 +41,7 @@
 #include <stdio.h>    // for P_tmpdir, std{err,in,out}, tmpnam()
 #include <stdlib.h>   // for mkstemp(), strtoul()
 #include <ctype.h>    // for isalpha(), isspace(), toupper()
+#include <string.h>   // for strcat()


 #if (defined (_WIN32) || defined (_WIN64)) && !defined (__CYGWIN__)
@@ -261,8 +262,17 @@
 #    define P_tmpdir "/tmp"
 #  endif   // P_tmpdir

-    char fnamebuf[] = P_tmpdir "/.rwtmpXXXXXX";
+    char* tmpdir = getenv("TMPDIR");

+    if (NULL == tmpdir)
+        tmpdir = P_tmpdir;
+
+    char fnamebuf[sizeof(tmpdir) + sizeof("/.rwtmpXXXXXX")];
                   ^^^^^^^^^^^^^^

This evaluates to the size of the tmpdir pointer, not the length
of the string pointed to by tmpdir as it should.

+
+    strcat(fnamebuf, tmpdir);

You want strcpy() here: fnamebuf hasn't been initialized yet.

+
+    strcat(fnamebuf, "/.rwtmpXXXXXX");
+

Finally, we need a space before every open parentheses :)

Martin

Reply via email to