libpkgconf: argvsplit: quoting logic was simplified too much

feature/tap-sh
William Pitcock 2017-02-07 10:24:54 -06:00
parent 2dcd749601
commit d558e30ab3
5 changed files with 52 additions and 1 deletions

View File

@ -66,6 +66,8 @@ EXTRA_DIST = pkg.m4 \
tests/lib1/flag-order-3.pc \
tests/lib1/variable-whitespace.pc \
tests/lib1/fragment-quoting.pc \
tests/lib1/fragment-quoting-2.pc \
tests/lib1/fragment-quoting-3.pc \
tests/test_env.sh \
$(test_scripts) \
doc/conf.py \

View File

@ -64,6 +64,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
int argc_count = 0;
int argv_size = 5;
char quote = 0;
bool in_single_quotes = false;
src_iter = src;
dst_iter = buf;
@ -111,6 +112,16 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
}
else switch(*src_iter)
{
case '\"':
if (in_single_quotes)
*dst_iter++ = *src_iter;
break;
case '\'':
in_single_quotes ^= true;
*dst_iter++ = *src_iter;
break;
case '\\':
src_iter++;

View File

@ -0,0 +1,10 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: fragment-quoting
Description: A testing pkg-config file
Version: 1.2.3
Cflags: -fPIC -I${includedir}/foo -DQUOTED="${prefix}/share/doc"
Cflags.private: -DFOO_STATIC

View File

@ -0,0 +1,10 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: fragment-quoting
Description: A testing pkg-config file
Version: 1.2.3
Cflags: -fPIC -I${includedir}/foo -DQUOTED=\"${prefix}/share/doc\"
Cflags.private: -DFOO_STATIC

View File

@ -19,7 +19,9 @@ tests_init \
flag_order_4 \
quoted \
variable_whitespace \
fragment_quoting
fragment_quoting \
fragment_quoting_2 \
fragment_quoting_3
comments_body()
{
@ -161,3 +163,19 @@ fragment_quoting_body()
-o inline:"-fPIC -I/test/include/foo -DQUOTED='\"/test/share/doc\"' \n" \
pkgconf --cflags fragment-quoting
}
fragment_quoting_2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=/test/share/doc \n" \
pkgconf --cflags fragment-quoting-2
}
fragment_quoting_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\" \n" \
pkgconf --cflags fragment-quoting-3
}