Scott Zhong wrote:
Changelog:
util/memchk.cpp (memchk): use TMPDIR variable from environment if
defined.
here is the patch:
Scott, this patch is also malformed. I get:
patching file stdcxx-4.2.x/util/memchk.cpp
patch: malformed patch at line 47: if (fd 0) {
Can you please resend a good patch? You might want to attach it
instead of pasting it inline (make sure you use a good mailer
and not something like Outlook otherwise the attachment might
get stripped). Alternatively, attach the patch to the issue.
Martin
Index: util/memchk.cpp
===
--- util/memchk.cpp (revision 702657)
+++ util/memchk.cpp (working copy)
@@ -67,6 +67,9 @@
# endif
#endif // P_tmpdir
+#ifndef PATH_MAX
+# define PATH_MAX 1024
+#endif
#if defined (_RWSTD_EDG_ECCP) !defined (_WIN32)
@@ -116,9 +119,14 @@
// operation away (as SunOS does, for instance)
// fd = open (/dev/null, O_WRONLY);
+const char *tmpdir = getenv (TMPDIR);
+if (tmpdir == NULL) {
+tmpdir = P_tmpdir;
+}
+
#ifdef _WIN32
-char* const fname = tempnam (P_tmpdir, .rwmemchk.tmp);
+char* const fname = tempnam (tmpdir, .rwmemchk.tmp);
if (!fname)
return size_t (-1);
@@ -137,10 +145,13 @@
#else // !_WIN32
-# define TMP_TEMPLATE P_tmpdir /rwmemchk-XX
+char fname_buf [PATH_MAX];
-char fname_buf [] = TMP_TEMPLATE;
+size_t len = strlen (tmpdir) - 1;
+memcpy (fname_buf, tmpdir, len);
+memcpy (fname_buf+len, /rwmemchk-XX, sizeof
+ (/rwmemchk-XX));
+
fd = mkstemp (fname_buf);
if (fd 0) {