~kaniini/pkgconf

[patch] fix missing backslashes in paths on Windows

Details
Message ID
<CAMq1adrMR_SZFp1AXCSp3sjeS2-uTCkKb6Lgbrf_RFKFuG2AEA@mail.gmail.com>
DKIM signature
missing
Download raw message
patch below :



From fa8edb1aac72252dcb14e0be6f3971793ac9fae1 Mon Sep 17 00:00:00 2001
From: Vincent Torri <vincent.torri@gmail.com>
Date: Fri, 29 May 2020 21:18:17 +0200
Subject: [PATCH] Current code removes backslash from paths on Windows.
 According to

https://docs.microsoft.com/fr-fr/windows/win32/fileio/naming-a-file

backslashes (with slashes) are a path separator, hence must no be
considered as an escape code.

The first fix, in argvsplit.c, disables this. But because of fragment_quote(),
the backslashes are doubled. Hence the second fix in fragment.c

With this pc file :


prefix=C:/Documents/msys2/opt/efl_64
libdir=${prefix}/lib
includedir=${prefix}/include

Name: eina
Description: efl: eina
Version: 1.24.99
Requires.private: iconv
Libs: -L${libdir} -leina -pthread -levil
Libs.private: -lpsapi -lole32 -lws2_32 -lsecur32 -luuid -lregex -lm
Cflags:-I${includedir}/eina-1 -I${includedir}/efl-1
-I${includedir}/eina-1/eina -pthread


pkgconf.exe --cflags eina

returns :

-IC:\Documents\msys2\opt\efl_64/include/eina-1
-IC:\Documents\msys2\opt\efl_64/include/efl-1
-IC:\Documents\msys2\opt\efl_64/include/eina-1/eina -pthread
-DWINICONV_CONST= -IC:\Documents\msys2\opt\ewpi_64/include
---
 libpkgconf/argvsplit.c | 2 ++
 libpkgconf/fragment.c  | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libpkgconf/argvsplit.c b/libpkgconf/argvsplit.c
index 02ce1a3..aaba858 100644
--- a/libpkgconf/argvsplit.c
+++ b/libpkgconf/argvsplit.c
@@ -118,9 +118,11 @@ pkgconf_argv_split(const char *src, int *argc,
char ***argv)
         }
         else switch(*src_iter)
         {
+#ifndef _WIN32
             case '\\':
                 escaped = true;
                 break;
+#endif

             case '\"':
             case '\'':
diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c
index 37830c8..1937f33 100644
--- a/libpkgconf/fragment.c
+++ b/libpkgconf/fragment.c
@@ -433,7 +433,11 @@ fragment_quote(const pkgconf_fragment_t *frag)
             (*src > ')' && *src < '+') ||
             (*src > ':' && *src < '=') ||
             (*src > '=' && *src < '@') ||
-            (*src > 'Z' && *src < '^') ||
+            (*src > 'Z' && *src < '\\') ||
+#ifndef _WIN32
+            (*src == '\\') ||
+#endif
+            (*src > '\\' && *src < '^') ||
             (*src == '`') ||
             (*src > 'z' && *src < '~') ||
             (*src > '~')))
-- 
2.26.2
Reply to thread Export thread (mbox)