From 5c545fc9dcd170c54b51ce6add50f71ed35439a2 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 5 Jun 2023 11:52:47 -0700 Subject: [PATCH 1/2] tests: Add a test for an escaped space --- Makefile.am | 1 + tests/lib1/escaped-space.pc | 4 ++++ tests/parser.sh | 8 ++++++++ 3 files changed, 13 insertions(+) create mode 100644 tests/lib1/escaped-space.pc diff --git a/Makefile.am b/Makefile.am index 8fdd145..b5ba3eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -95,6 +95,7 @@ EXTRA_DIST = pkg.m4 \ tests/lib1/metapackage-2.pc \ tests/lib1/explicit-sysroot.pc \ tests/lib1/escaped-backslash.pc \ + tests/lib1/escaped-space.pc \ tests/lib1/cflags-internal.pc \ tests/lib1/requires-internal.pc \ tests/lib1/requires-internal-2.pc \ diff --git a/tests/lib1/escaped-space.pc b/tests/lib1/escaped-space.pc new file mode 100644 index 0000000..1546e6b --- /dev/null +++ b/tests/lib1/escaped-space.pc @@ -0,0 +1,4 @@ +Name: escaped-space +Version: 1 +Description: test package for backslash escape of spaces +Cflags: -IC:\\A\ space diff --git a/tests/parser.sh b/tests/parser.sh index c83c60c..8eb9b8e 100755 --- a/tests/parser.sh +++ b/tests/parser.sh @@ -138,6 +138,14 @@ escaped_backslash_body() pkgconf --with-path=${selfdir}/lib1 --cflags escaped-backslash } +escaped_space_body() +{ + atf_check \ + -e ignore \ + -o inline:"-IC:\\\\\\\\A space\n" \ + pkgconf --with-path=${selfdir}/lib1 --cflags escaped-space +} + quoted_body() { export PKG_CONFIG_PATH="${selfdir}/lib1" -- 2.41.0 From 68e3f24000726b72757ff19bef5a7837f4c08d94 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 5 Jun 2023 14:39:27 -0700 Subject: [PATCH 2/2] fragment: Mingw needs to use POSIX handling for `\\` Otherwise it won't correctly escape things like spaces, and can print out the `\` literal escaping nothing, which causes most shell lexers to choke. Fixes: #238 --- libpkgconf/fragment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c index c015e4f..cec75ff 100644 --- a/libpkgconf/fragment.c +++ b/libpkgconf/fragment.c @@ -438,7 +438,7 @@ fragment_quote(const pkgconf_fragment_t *frag) (*src > ':' && *src < '=') || (*src > '=' && *src < '@') || (*src > 'Z' && *src < '\\') || -#ifndef _WIN32 +#ifndef _MSC_VER (*src == '\\') || #endif (*src > '\\' && *src < '^') || -- 2.41.0