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 authored and Git for Windows Build Agent committed Apr 30, 2019
2 parents 5fc4cec + 9dcd6bb commit 47a0530
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
21 changes: 16 additions & 5 deletions winsup/cygwin/msys2_path_conv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ const char* convert(char *dst, size_t dstlen, const char *src) {
}

sub_convert(&srcbeg, &srcit, &dstit, dstend, &in_string);
if (!*srcit) {
*dstit = '\0';
return dst;
}
srcbeg = srcit + 1;
for (; *srcit != '\0'; ++srcit) {
continue;
Expand Down Expand Up @@ -441,7 +445,7 @@ path_type find_path_start_and_type(const char** src, int recurse, const char* en
return find_path_start_and_type(src, true, end);
}

if (ch == ':') {
if (ch == ':' && it2 + 1 != end) {
it2 += 1;
ch = *it2;
if (ch == '/' || ch == ':' || ch == '.') {
Expand Down Expand Up @@ -536,7 +540,7 @@ void url_convert(const char** from, const char* to, char** dst, const char* dste

void subp_convert(const char** from, const char* end, int is_url, char** dst, const char* dstend) {
const char* begin = *from;
path_type type = find_path_start_and_type(from, 0, end);
path_type type = is_url ? URL : find_path_start_and_type(from, 0, end);
copy_to_dst(begin, *from, dst, dstend);

if (type == NONE) {
Expand Down Expand Up @@ -566,9 +570,16 @@ void ppl_convert(const char** from, const char* to, char** dst, const char* dste
if (prev_was_simc) {
continue;
}
if (*(it + 1) == '/' && *(it + 2) == '/') {
if (*(it + 1) == '/' && *(it + 2) == '/' && isalpha(*beg)) {
is_url = 1;
continue;
/* double-check: protocol must be alnum (or +) */
for (const char *p = beg; p != it; ++p)
if (!isalnum(*p) && *p != '+') {
is_url = 0;
break;
}
if (is_url)
continue;
}
prev_was_simc = 1;
subp_convert(&beg, it, is_url, dst, dstend);
Expand Down Expand Up @@ -613,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 @@ -1236,9 +1236,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 @@ -1248,6 +1261,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 @@ -58,6 +58,7 @@ enum pathconv_arg
PC_SYM_NOFOLLOW_PROCFD = _BIT (11),
PC_KEEP_HANDLE = _BIT (12),
PC_NO_ACCESS_CHECK = _BIT (13),
PC_KEEP_FINAL_SLASH = _BIT (14),
PC_DONT_USE = _BIT (31) /* conversion to signed happens. */
};

Expand Down
4 changes: 2 additions & 2 deletions winsup/cygwin/syscalls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,15 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags)
}
else
{
/* Create unique filename. Start with a dot, followed by "cyg"
/* Create unique filename. Start with a dot, followed by "msys"
transposed into the Unicode low surrogate area (U+dc00) on file
systems supporting Unicode (except Samba), followed by the inode
number in hex, followed by a path hash in hex. The combination
allows to remove multiple hardlinks to the same file. */
RtlAppendUnicodeToString (&recycler,
(pc.fs_flags () & FILE_UNICODE_ON_DISK
&& !pc.fs_is_samba ())
? L".\xdc73\xdc6d\xdc79\xdc6d" : L".msys");
? L".\xdc6d\xdc73\xdc79\xdc73" : L".msys");
pfii = (PFILE_INTERNAL_INFORMATION) infobuf;
status = NtQueryInformationFile (fh, &io, pfii, sizeof *pfii,
FileInternalInformation);
Expand Down
3 changes: 2 additions & 1 deletion winsup/utils/strace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ create_child (char **argv)
flags |= CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP;

make_command_line (one_line, argv);
printf ("create_child: %s\n", one_line.buf);
if (!quiet)
printf ("create_child: %s\n", one_line.buf);

SetConsoleCtrlHandler (NULL, 0);
/* Commit message for this code was:
Expand Down

0 comments on commit 47a0530

Please sign in to comment.