]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
windows-cygpath: Make it work with the native Windows 'git' port.
authorBruno Haible <bruno@clisp.org>
Mon, 5 May 2025 17:02:01 +0000 (19:02 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 5 May 2025 17:02:01 +0000 (19:02 +0200)
* lib/windows-cygpath.c (windows_cygpath_w): When we don't invoke
cygpath, still convert slashes to backslashes.

ChangeLog
lib/windows-cygpath.c

index 94388f5497bf4be099dd0614db40b4271a2ccbde..adf06a2645f0205b4ac3265281000111358ac2ca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-05-05  Bruno Haible  <bruno@clisp.org>
+
+       windows-cygpath: Make it work with the native Windows 'git' port.
+       * lib/windows-cygpath.c (windows_cygpath_w): When we don't invoke
+       cygpath, still convert slashes to backslashes.
+
 2025-05-05  Bruno Haible  <bruno@clisp.org>
 
        vc-mtime: Another fix for native Windows.
index f0f1a887cea3964539ea3a1f44e8e836f1d103d2..8b11898e3d228f921a951445d190333dcaf81550 100644 (file)
@@ -121,9 +121,16 @@ windows_cygpath_w (const char *filename)
       return line;
     }
   else
-    /* It's a relative file name, or an absolute native Windows file name.
-       No conversion is needed.  */
-    return xstrdup (filename);
+    {
+      /* It's a relative file name, or an absolute native Windows file name.
+         All we need to do is to convert slashes to backslahes, e.g.
+         'C:/Users' -> 'C:\Users'.  */
+      size_t len = strlen (filename) + 1;
+      char *copy = XNMALLOC (len, char);
+      for (size_t i = 0; i < len; i++)
+        copy[i] = (filename[i] == '/' ? '\\' : filename[i]);
+      return copy;
+    }
 }
 
 #else