A correction regarding UNC file names on Cygwin. Seen via the 'vc-mtime'
module (used by GNU xgettext).


2026-04-28  Bruno Haible  <[email protected]>

        windows-cygpath: Handle UNC file names on Cygwin correctly.
        Reported and initial patch by Vaclav Slavik <[email protected]> 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.

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
+         <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++)




Reply via email to