Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 63541 invoked from network); 9 Oct 2008 15:33:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Oct 2008 15:33:44 -0000 Received: (qmail 24982 invoked by uid 500); 9 Oct 2008 15:33:43 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 24956 invoked by uid 500); 9 Oct 2008 15:33:43 -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 24945 invoked by uid 99); 9 Oct 2008 15:33:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Oct 2008 08:33:43 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=DNS_FROM_SECURITYSAGE,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; Thu, 09 Oct 2008 15:32:40 +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 m99FVDNv019939 for ; Thu, 9 Oct 2008 15:31:13 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: RE: [PATCH] STDCXX-401 test suite should honor TMPDIR Date: Thu, 9 Oct 2008 09:30:51 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] STDCXX-401 test suite should honor TMPDIR Thread-Index: Ackp59r55oFV6Q6UTbCcUUHfpj9cTwAOxqZgAAA229A= References: From: "Scott Zhong" To: X-Virus-Checked: Checked by ClamAV on apache.org That const_cast isn't suppose to be there. Here is the correct version: Index: tests/src/file.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 --- tests/src/file.cpp (revision 702657) +++ tests/src/file.cpp (working copy) @@ -208,8 +208,13 @@ #ifndef _RWSTD_NO_MKSTEMP # define TMP_TEMPLATE "tmpfile-XXXXXX" =20 + const char *tmpdir =3D getenv ("TMPDIR"); + if (tmpdir =3D=3D NULL) {=20 + tmpdir =3D P_tmpdir; + } + if (!buf) { - static char fname_buf [sizeof (P_tmpdir) + sizeof (TMP_TEMPLATE)]; + static char fname_buf [strlen (tmpdir) + sizeof (TMP_TEMPLATE)]; =20 buf =3D fname_buf; *buf =3D '\0'; @@ -217,13 +222,13 @@ =20 if ('\0' =3D=3D *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 =3D sizeof (P_tmpdir) - 1; + size_t len =3D strlen (tmpdir) - 1; =20 - memcpy (buf, P_tmpdir, len); + memcpy (buf, tmpdir, len); if (_RWSTD_PATH_SEP !=3D buf [len - 1]) buf [len++] =3D _RWSTD_PATH_SEP; =20 @@ -251,7 +256,7 @@ # ifdef _WIN32 =20 // create a temporary file name - char* fname =3D tempnam (P_tmpdir, ".rwtest-tmp"); + char* fname =3D tempnam (tmpdir, ".rwtest-tmp"); =20 if (fname) { =20 @@ -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)); } =20 # else > -----Original Message----- > From: Scott Zhong [mailto:Scott.Zhong@roguewave.com] > Sent: Thursday, October 09, 2008 9:25 AM > To: dev@stdcxx.apache.org > Subject: RE: [PATCH] STDCXX-401 test suite should honor TMPDIR >=20 > Hi Farid, thanks for the quick response, here is the new version with > the changes suggested. >=20 > Index: tests/src/file.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 > --- tests/src/file.cpp (revision 702657) > +++ tests/src/file.cpp (working copy) > @@ -208,8 +208,13 @@ > #ifndef _RWSTD_NO_MKSTEMP > # define TMP_TEMPLATE "tmpfile-XXXXXX" >=20 > + const char *tmpdir =3D getenv ("TMPDIR"); > + if (tmpdir =3D=3D NULL) { > + tmpdir =3D const_cast(P_tmpdir); > + } > + > if (!buf) { > - static char fname_buf [sizeof (P_tmpdir) + sizeof > (TMP_TEMPLATE)]; > + static char fname_buf [strlen (tmpdir) + sizeof > (TMP_TEMPLATE)]; >=20 > buf =3D fname_buf; > *buf =3D '\0'; > @@ -217,13 +222,13 @@ >=20 > if ('\0' =3D=3D *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 =3D sizeof (P_tmpdir) - 1; > + size_t len =3D strlen (tmpdir) - 1; >=20 > - memcpy (buf, P_tmpdir, len); > + memcpy (buf, tmpdir, len); > if (_RWSTD_PATH_SEP !=3D buf [len - 1]) > buf [len++] =3D _RWSTD_PATH_SEP; >=20 > @@ -251,7 +256,7 @@ > # ifdef _WIN32 >=20 > // create a temporary file name > - char* fname =3D tempnam (P_tmpdir, ".rwtest-tmp"); > + char* fname =3D tempnam (tmpdir, ".rwtest-tmp"); >=20 > if (fname) { >=20 > @@ -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)); > } >=20 > # else >=20 > > -----Original Message----- > > From: Farid Zaripov [mailto:Farid_Zaripov@epam.com] > > Sent: Thursday, October 09, 2008 2:20 AM > > To: dev@stdcxx.apache.org > > Subject: Re: [PATCH] STDCXX-401 test suite should honor TMPDIR > > > > Hi Scott. > > > > > Index: file.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 > > > --- file.cpp (revision 702657) > > > +++ file.cpp (working copy) > > > @@ -208,8 +208,10 @@ > > > #ifndef _RWSTD_NO_MKSTEMP > > > # define TMP_TEMPLATE "tmpfile-XXXXXX" > > > > > > + char *tmpdir =3D getenv ("TMPDIR") =3D=3D NULL ? P_tmpdir : = getenv > > ("TMPDIR"); > > > > tmpdir might be const char*. And why getenv("TMPDIR") is called > twice? > > > > > + > > > if (!buf) { > > > - static char fname_buf [sizeof (P_tmpdir) + sizeof > > (TMP_TEMPLATE)]; > > > + static char fname_buf [sizeof (tmpdir) + sizeof > > (TMP_TEMPLATE)]; > > > > Here sizeof (tmpdir) !=3D strlen (tmpdir). I think that using here > > PATH_MAX is ok. > > > > [...] > > > - size_t len =3D sizeof (P_tmpdir) - 1; > > > + size_t len =3D sizeof (tmpdir) - 1; > > > > Same. > > > > Farid.