Skip to content

Commit

Permalink
Merge branch 'fixes-for-msys2'
Browse files Browse the repository at this point in the history
We deviated a bit too much from MSYS2's patches, by amending them...
Let's put our fixes on top, maybe the MSYS2 maintainer will be in a more
collaborative and communicative mood and we might get them integrated,
at long last.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Aug 24, 2020
2 parents cb494ed + a256dcd commit 26b113a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion winsup/cygwin/msys2_path_conv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void posix_to_win32_path(const char* from, const char* to, char** dst, const cha
strncpy(one_path, from, to-from);
one_path[to-from] = '\0';

path_conv conv (one_path, 0);
path_conv conv (one_path, PC_KEEP_FINAL_SLASH);
if (conv.error)
{
set_errno(conv.error);
Expand Down
16 changes: 15 additions & 1 deletion winsup/cygwin/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1211,9 +1211,22 @@ path_conv::check (const char *src, unsigned opt,
cfree (wide_path);
wide_path = NULL;
}

if (need_directory)
{
size_t n = strlen (this->path);
/* Do not add trailing \ to UNC device names like \\.\a: */
if (this->path[n - 1] != '\\' &&
(strncmp (this->path, "\\\\.\\", 4) != 0))
{
this->modifiable_path ()[n] = '\\';
this->modifiable_path ()[n + 1] = '\0';
}
need_directory = 0;
}
}

if (need_directory)
if ((opt & PC_KEEP_FINAL_SLASH) && need_directory)
{
size_t n = strlen (this->path);
/* Do not add trailing \ to UNC device names like \\.\a: */
Expand All @@ -1223,6 +1236,7 @@ path_conv::check (const char *src, unsigned opt,
this->modifiable_path ()[n] = '\\';
this->modifiable_path ()[n + 1] = '\0';
}
need_directory = 0;
}

if (opt & PC_OPEN)
Expand Down
1 change: 1 addition & 0 deletions winsup/cygwin/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ enum pathconv_arg
PC_KEEP_HANDLE = _BIT (12), /* keep handle for later stat calls */
PC_NO_ACCESS_CHECK = _BIT (13), /* helper flag for error check */
PC_SYM_NOFOLLOW_DIR = _BIT (14), /* don't follow a trailing slash */
PC_KEEP_FINAL_SLASH = _BIT (15), /* do not remove a trailing slash */
PC_DONT_USE = _BIT (31) /* conversion to signed happens. */
};

Expand Down

0 comments on commit 26b113a

Please sign in to comment.