From: Bruno Haible Date: Mon, 5 May 2025 17:02:01 +0000 (+0200) Subject: windows-cygpath: Make it work with the native Windows 'git' port. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d7fd2084fb18f19c8cc79543ed9d73a93984877;p=thirdparty%2Fgnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 94388f5497..adf06a2645 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-05-05 Bruno Haible + + 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 vc-mtime: Another fix for native Windows. diff --git a/lib/windows-cygpath.c b/lib/windows-cygpath.c index f0f1a887ce..8b11898e3d 100644 --- a/lib/windows-cygpath.c +++ b/lib/windows-cygpath.c @@ -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