+2026-04-28 Bruno Haible <bruno@clisp.org>
+
+ windows-cygpath: Handle UNC file names on Cygwin correctly.
+ Reported and initial patch by Vaclav Slavik <vaclav@slavik.io> in
+ <https://savannah.gnu.org/bugs/?68291>.
+ * lib/windows-cygpath.c (windows_cygpath_w): Treat file names that start
+ with '//' like absolute native Windows file names.
+
2026-04-28 Bruno Haible <bruno@clisp.org>
idx: Remove redundant #include.
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";
}
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
+ <https://cygwin.com/cygwin-ug-net/using.html#unc-paths> and
+ <https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file>.
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++)