Re: svn commit: r710029 - in /stdcxx/branches/4.2.x: src/file.cpp tests/src/file.cpp

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: svn commit: r710029 - in /stdcxx/branches/4.2.x: src/file.cpp tests/src/file.cpp

by Martin Sebor-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

faridz@... wrote:

> Author: faridz
> Date: Mon Nov  3 01:33:58 2008
> New Revision: 710029
>
> URL: http://svn.apache.org/viewvc?rev=710029&view=rev
> Log:
> 2008-11-03  Farid Zaripov  <faridz@...>
>
> * src/file.cpp (__rw_mkstemp): Fixed calculation of the string length.
> [_WIN32]: #define P_tmpdir with a different value on Windows. Added
> definition of the tmpdir, initialized by value of TMP instead of TMPDIR.

I suspect this was my screwup -- thanks for cleaning it up
for me!

Martin

> * tests/src/file.cpp (rw_tmpnam): Fallback to P_tmpdir if
> getenv("TMPDIR") returns empty string.
>
> Modified:
>     stdcxx/branches/4.2.x/src/file.cpp
>     stdcxx/branches/4.2.x/tests/src/file.cpp
>
> Modified: stdcxx/branches/4.2.x/src/file.cpp
> URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/src/file.cpp?rev=710029&r1=710028&r2=710029&view=diff
> ==============================================================================
> --- stdcxx/branches/4.2.x/src/file.cpp (original)
> +++ stdcxx/branches/4.2.x/src/file.cpp Mon Nov  3 01:33:58 2008
> @@ -288,7 +288,7 @@
>      char pathbuf [PATH_MAX];
>  
>      // check to see if the buffer is large enough
> -    const size_t len = strlen (tmpdir) - 1;
> +    const size_t len = strlen (tmpdir);
>      if (sizeof pathbuf < len + sizeof rwtmpXXXXXX) {
>  
>  #  ifdef ENAMETOOLONG
> @@ -319,6 +319,15 @@
>  
>  #  ifdef _WIN32
>  
> +#  ifndef P_tmpdir   // #defined in <stdio.h> by POSIX
> +#    define P_tmpdir "\\"
> +#  endif   // P_tmpdir
> +
> +    // use TMPDIR and fall back on P_tmpdir as per POSIX
> +    const char *tmpdir = getenv ("TMP");
> +    if (0 == tmpdir || '\0' == *tmpdir)
> +        tmpdir = P_tmpdir;
> +
>      // tempnam(const char *dir, const char *prefix) will generate
>      // a unique file name for a directory chosen by the following rules:
>      //
>
> 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=710029&r1=710028&r2=710029&view=diff
> ==============================================================================
> --- stdcxx/branches/4.2.x/tests/src/file.cpp (original)
> +++ stdcxx/branches/4.2.x/tests/src/file.cpp Mon Nov  3 01:33:58 2008
> @@ -213,7 +213,7 @@
>  #  define TMP_TEMPLATE      "tmpfile-XXXXXX"
>  
>      const char *tmpdir = getenv ("TMPDIR");
> -    if (!tmpdir)
> +    if (0 == tmpdir || '\0' == *tmpdir)
>          tmpdir = P_tmpdir;
>  
>      if (!buf) {
> @@ -259,7 +259,7 @@
>  #  ifdef _WIN32
>  
>      const char *tmpdir = getenv ("TMP");
> -    if (!tmpdir)
> +    if (0 == tmpdir || '\0' == *tmpdir)
>          tmpdir = P_tmpdir;
>  
>      // create a temporary file name
>
>
>