From 2a8bebf289112cc538efafc382b3bf5658e3142a Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Thu, 11 Jun 2020 18:00:56 -0600 Subject: [PATCH] libpkgconf: path: rewrite DOS paths in non-cygwin case too --- libpkgconf/path.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 3cc89f5..2d3ba64 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -17,7 +17,7 @@ #include #include -#if defined(HAVE_CYGWIN_CONV_PATH) && defined(__MSYS__) +#ifdef HAVE_CYGWIN_CONV_PATH # include #endif @@ -320,9 +320,17 @@ normpath(const char *path) bool pkgconf_path_relocate(char *buf, size_t buflen) { -#if defined(HAVE_CYGWIN_CONV_PATH) && defined(__MSYS__) +#ifdef _WIN32 + char *ti; +#endif + +#ifdef HAVE_CYGWIN_CONV_PATH + /* + * If we are on Cygwin or MSYS, then we want to convert the virtual path + * to a real DOS path, using cygwin_conv_path(). + */ ssize_t size; - char *tmpbuf, *ti; + char *tmpbuf; size = cygwin_conv_path(CCP_POSIX_TO_WIN_A, buf, NULL, 0); if (size < 0 || (size_t) size > buflen) @@ -334,13 +342,6 @@ pkgconf_path_relocate(char *buf, size_t buflen) pkgconf_strlcpy(buf, tmpbuf, buflen); free(tmpbuf); - - /* rewrite any backslash arguments for best compatibility */ - for (ti = buf; *ti != '\0'; ti++) - { - if (*ti == '\\') - *ti = '/'; - } #else char *tmpbuf; @@ -358,5 +359,18 @@ pkgconf_path_relocate(char *buf, size_t buflen) } #endif +#ifdef _WIN32 + /* + * Rewrite any backslash path delimiters for best compatibility. + * Originally, we did this in cygwin/msys case, but now we build pkgconf + * natively on Windows without cygwin/msys, so do it in all cases. + */ + for (ti = buf; *ti != '\0'; ti++) + { + if (*ti == '\\') + *ti = '/'; + } +#endif + return true; }