diff mbox

- fix handling of temporary directories on Windows

Message ID 4C3B3D11.7030501@adacore.com
State New
Headers show

Commit Message

Pascal Obry July 12, 2010, 4:04 p.m. UTC
ChangeLog:

2010-07-09  Pascal Obry  <obry@adacore.com>

   * libibery/make-temp-file.c (choose_tmpdir): When TMPDIR, TMP and TEMP
   are not set, P_tmpdir is used on Windows. This is defined as "\" in
   current MingW header. Append a dot to ensure that when concatenating
   with \dir we do not end-up with an UNC path. Fix a crash on the
   compiler.


Patch as attachment.

Comments

DJ Delorie July 12, 2010, 5:28 p.m. UTC | #1
>    * libibery/make-temp-file.c (choose_tmpdir): When TMPDIR, TMP and TEMP
>    are not set, P_tmpdir is used on Windows. This is defined as "\" in
>    current MingW header. Append a dot to ensure that when concatenating
>    with \dir we do not end-up with an UNC path. Fix a crash on the
>    compiler.

Ok.
Pascal Obry July 12, 2010, 7:16 p.m. UTC | #2
Le 12/07/2010 20:30, Florian Weimer a écrit :
> * Pascal Obry:
> 
>> ChangeLog:
>>
>> 2010-07-09  Pascal Obry  <obry@adacore.com>
>>
>>    * libibery/make-temp-file.c (choose_tmpdir): When TMPDIR, TMP and TEMP
> 
> I think it's "libiberty". 8-)

Right, good catch :) The change log should read:


2010-07-09  Pascal Obry  <obry@adacore.com>

   * libiberty/make-temp-file.c (choose_tmpdir): When TMPDIR, TMP and TEMP
   are not set, P_tmpdir is used on Windows. This is defined as "\" in
   current MingW header. Append a dot to ensure that when concatenating
   with \dir we do not end-up with an UNC path. Fix a crash on the
   compiler.
Dave Korn July 12, 2010, 11:34 p.m. UTC | #3
On 12/07/2010 20:16, Pascal Obry wrote:
> Le 12/07/2010 20:30, Florian Weimer a écrit :
>> * Pascal Obry:
>>
>>> ChangeLog:
>>>
>>> 2010-07-09  Pascal Obry  <obry@adacore.com>
>>>
>>>    * libibery/make-temp-file.c (choose_tmpdir): When TMPDIR, TMP and TEMP
>> I think it's "libiberty". 8-)
> 
> Right, good catch :) The change log should read:
> 
> 
> 2010-07-09  Pascal Obry  <obry@adacore.com>
> 
>    * libiberty/make-temp-file.c (choose_tmpdir): When TMPDIR, TMP and TEMP

  Well, if we're being pedantic, it should actually say:

>    * make-temp-file.c (choose_tmpdir): When TMPDIR, TMP and TEMP [ ... ]

... since this entry is going into libiberty/ChangeLog you discard the common
leading prefix.

    cheers,
      DaveK
diff mbox

Patch

diff libiberty/make-temp-file.c libiberty/make-temp-file.c
index 13e1925..f754b45 100644
--- libiberty/make-temp-file.c
+++ libiberty/make-temp-file.c
@@ -121,7 +121,12 @@  choose_tmpdir (void)
 #endif
       
 #ifdef P_tmpdir
-      base = try_dir (P_tmpdir, base);
+      /* We really want a directory name here as if concatenated with say \dir
+         we do not end-up with a double \\ which defines an UNC path.  */
+      if (strcmp (P_tmpdir, "\\") == 0)
+	base = try_dir ("\\.", base);
+      else
+	base = try_dir (P_tmpdir, base);
 #endif
 
       /* Try /var/tmp, /usr/tmp, then /tmp.  */