You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Scott Zhong <Sc...@roguewave.com> on 2008/03/11 21:00:06 UTC

[PATCH] STDCXX-401 part 2

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
219128FD94FB4F92B99F52D0A499A2BA0@exchmail01.Blue.Roguewave.Com%3e

stdcxx-401 patch part 2 affects:

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

Patch link:

http://www.fileden.com/files/2008/1/30/1729926/patch.stdcxx-401.diff


Re: [PATCH] STDCXX-401 part 2

Posted by Martin Sebor <se...@roguewave.com>.
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
> 219128FD94FB4F92B99F52D0A499A2BA0@exchmail01.Blue.Roguewave.Com%3e
> 
> 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