Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 44912 invoked from network); 20 Oct 2008 22:09:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Oct 2008 22:09:07 -0000 Received: (qmail 91276 invoked by uid 500); 20 Oct 2008 22:09:09 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 91256 invoked by uid 500); 20 Oct 2008 22:09:09 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 91245 invoked by uid 99); 20 Oct 2008 22:09:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Oct 2008 15:09:09 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Oct 2008 22:08:00 +0000 Received: from exchmail01.Blue.Roguewave.Com (exchmail01.blue.roguewave.com [10.22.129.22]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m9KM6RSF000826 for ; Mon, 20 Oct 2008 22:06:27 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: [PATCH] STDCXX-1020 memchk in utility should honor TMPDIR variable Date: Mon, 20 Oct 2008 16:05:47 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] STDCXX-1020 memchk in utility should honor TMPDIR variable Thread-Index: Acky//Twq134SzzJTUuB8xzFpd4rqQ== From: "Scott Zhong" To: X-Virus-Checked: Checked by ClamAV on apache.org Changelog: util/memchk.cpp (memchk): use TMPDIR variable from environment if defined. here is the patch: Index: util/memchk.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- util/memchk.cpp (revision 702657) +++ util/memchk.cpp (working copy) @@ -67,6 +67,9 @@ # endif #endif // P_tmpdir =20 +#ifndef PATH_MAX +# define PATH_MAX 1024 +#endif =20 #if defined (_RWSTD_EDG_ECCP) && !defined (_WIN32) =20 @@ -116,9 +119,14 @@ // operation away (as SunOS does, for instance) // fd =3D open ("/dev/null", O_WRONLY); =20 + const char *tmpdir =3D getenv ("TMPDIR"); + if (tmpdir =3D=3D NULL) {=20 + tmpdir =3D P_tmpdir; + } + #ifdef _WIN32 =20 - char* const fname =3D tempnam (P_tmpdir, ".rwmemchk.tmp"); + char* const fname =3D tempnam (tmpdir, ".rwmemchk.tmp"); =20 if (!fname) return size_t (-1); @@ -137,10 +145,13 @@ =20 #else // !_WIN32 =20 -# define TMP_TEMPLATE P_tmpdir "/rwmemchk-XXXXXX" + char fname_buf [PATH_MAX]; =20 - char fname_buf [] =3D TMP_TEMPLATE; + size_t len =3D strlen (tmpdir) - 1; =20 + memcpy (fname_buf, tmpdir, len); + memcpy (fname_buf+len, "/rwmemchk-XXXXXX", sizeof=20 + ("/rwmemchk-XXXXXX")); + fd =3D mkstemp (fname_buf); =20 if (fd < 0) {