From: Bruno Haible Date: Tue, 28 Apr 2026 14:49:45 +0000 (+0200) Subject: windows-cygpath: Handle UNC file names on Cygwin correctly. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfd387d2e1b27f185cfd45ef8b5a9b3625c6f961;p=thirdparty%2Fgnulib.git windows-cygpath: Handle UNC file names on Cygwin correctly. Reported and initial patch by Vaclav Slavik in . * lib/windows-cygpath.c (windows_cygpath_w): Treat file names that start with '//' like absolute native Windows file names. --- diff --git a/ChangeLog b/ChangeLog index 8d9da78d46..a2bca1ce98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2026-04-28 Bruno Haible + + windows-cygpath: Handle UNC file names on Cygwin correctly. + Reported and initial patch by Vaclav Slavik in + . + * lib/windows-cygpath.c (windows_cygpath_w): Treat file names that start + with '//' like absolute native Windows file names. + 2026-04-28 Bruno Haible idx: Remove redundant #include. diff --git a/lib/windows-cygpath.c b/lib/windows-cygpath.c index 11cc9a65a9..8cb34d48b7 100644 --- a/lib/windows-cygpath.c +++ b/lib/windows-cygpath.c @@ -98,9 +98,9 @@ execute_and_read_line (const char *progname, char * windows_cygpath_w (const char *filename) { - if (filename[0] == '/') + if (filename[0] == '/' && filename[1] != '/') { - /* It's an absolute POSIX-style file name. */ + /* It's an absolute POSIX-style file name, e.g. '/path/to/file'. */ const char *argv[4]; argv[0] = "cygpath"; argv[1] = "-w"; @@ -114,9 +114,14 @@ windows_cygpath_w (const char *filename) } else { - /* It's a relative file name, or an absolute native Windows file name. + /* It's a relative file name, or either + an absolute native Windows file name (e.g. 'C:/path/to/file') or + a native Windows UNC file name ('//server/share/path/to/file'), see + and + . All we need to do is to convert slashes to backslahes, e.g. - 'C:/Users' -> 'C:\Users'. */ + 'C:/Users' -> 'C:\Users' + '//server/share/path/to/file' -> '\\server\share\path\to\file'. */ size_t len = strlen (filename) + 1; char *copy = XNMALLOC (len, char); for (size_t i = 0; i < len; i++)