summaryrefslogtreecommitdiff
path: root/gcc/ada/adaint.c
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2009-07-13 11:17:10 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2009-07-13 11:17:10 +0200
commit223eab977a61c48f62cb0cbb9c009afefa6f6cbc (patch)
tree1857f720afceceaca3d3c5a224ab66303e3e682d /gcc/ada/adaint.c
parentfdd7e7bb1d01de50a07ba1b7f9bf6235b7e89da3 (diff)
downloadgcc-223eab977a61c48f62cb0cbb9c009afefa6f6cbc.tar.gz
[multiple changes]
2009-07-13 Thomas Quinot <quinot@adacore.com> * g-socthi-vxworks.adb (C_Sendto): VxWorks does not support the standard sendto(2) interface for connected sockets (passing a null destination address). Use send(2) instead for that case. 2009-07-13 Pascal Obry <obry@adacore.com> * adaint.c: Fix __gnat_stat() with Win32 UNC paths. From-SVN: r149559
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r--gcc/ada/adaint.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index fd7b1b31ff9..f8ef6b189a4 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -1655,10 +1655,14 @@ __gnat_stat (char *name, STRUCT_STAT *statbuf)
{
#ifdef __MINGW32__
/* Under Windows the directory name for the stat function must not be
- terminated by a directory separator except if just after a drive name. */
+ terminated by a directory separator except if just after a drive name
+ or with UNC path without directory (only the name of the shared
+ resource), for example: \\computer\share\ */
+
TCHAR wname [GNAT_MAX_PATH_LEN + 2];
- int name_len;
+ int name_len, k;
TCHAR last_char;
+ int dirsep_count = 0;
S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
name_len = _tcslen (wname);
@@ -1675,9 +1679,17 @@ __gnat_stat (char *name, STRUCT_STAT *statbuf)
last_char = wname[name_len - 1];
}
+ /* Count back-slashes. */
+
+ for (k=0; k<name_len; k++)
+ if (wname[k] == _T('\\') || wname[k] == _T('/'))
+ dirsep_count++;
+
/* Only a drive letter followed by ':', we must add a directory separator
for the stat routine to work properly. */
- if (name_len == 2 && wname[1] == _T(':'))
+ if ((name_len == 2 && wname[1] == _T(':'))
+ || (name_len > 3 && wname[0] == _T('\\') && wname[1] == _T('\\')
+ && dirsep_count == 3))
_tcscat (wname, _T("\\"));
return _tstat (wname, (struct _stat *)statbuf);