stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r706515 - /stdcxx/branches/4.2.x/tests/src/file.cpp
Date Tue, 21 Oct 2008 04:54:35 GMT
Author: sebor
Date: Mon Oct 20 21:54:34 2008
New Revision: 706515

URL: http://svn.apache.org/viewvc?rev=706515&view=rev
Log:
2008-10-20  Scott Zhong  <scottz@roguewave.com>

	STDCXX-401
	* tests/src/file.cpp (rw_tmpnam): use TMPDIR variable from environment
	if defined.
-This line, and those below, will be ignored--

M    file.cpp

Modified:
    stdcxx/branches/4.2.x/tests/src/file.cpp

Modified: stdcxx/branches/4.2.x/tests/src/file.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/file.cpp?rev=706515&r1=706514&r2=706515&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/file.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/file.cpp Mon Oct 20 21:54:34 2008
@@ -208,8 +208,13 @@
 #ifndef _RWSTD_NO_MKSTEMP
 #  define TMP_TEMPLATE      "tmpfile-XXXXXX"
 
+    const char *tmpdir = getenv ("TMPDIR");
+    if (tmpdir == NULL) { 
+        tmpdir = P_tmpdir;
+    }
+
     if (!buf) {
-        static char fname_buf [sizeof (P_tmpdir) + sizeof (TMP_TEMPLATE)];
+        static char fname_buf [PATH_MAX];
 
         buf = fname_buf;
         *buf = '\0';
@@ -217,13 +222,13 @@
 
     if ('\0' == *buf) {
         // copy the template to the buffer; make sure there is exactly
-        // one path separator character between P_tmpdir and the file
+        // one path separator character between tmpdir and the file
         // name template (it doesn't really matter how many there are
         // as long as it's at least one, but one looks better than two
         // in diagnostic messages)
-        size_t len = sizeof (P_tmpdir) - 1;
+        size_t len = strlen (tmpdir) - 1;
 
-        memcpy (buf, P_tmpdir, len);
+        memcpy (buf, tmpdir, len);
         if (_RWSTD_PATH_SEP != buf [len - 1])
             buf [len++] = _RWSTD_PATH_SEP;
 
@@ -251,7 +256,7 @@
 #  ifdef _WIN32
 
     // create a temporary file name
-    char* fname = tempnam (P_tmpdir, ".rwtest-tmp");
+    char* fname = tempnam (tmpdir, ".rwtest-tmp");
 
     if (fname) {
 
@@ -272,7 +277,7 @@
     else {
         fprintf (stderr, "%s:%d: tempnam(\"%s\", \"%s\") failed: %s\n",
                  __FILE__, __LINE__,
-                 P_tmpdir, ".rwtest-tmp", strerror (errno));
+                 tmpdir, ".rwtest-tmp", strerror (errno));
     }
 
 #  else



Mime
View raw message