diff -up pkg-config-0.24/check/check-whitespace.escape pkg-config-0.24/check/check-whitespace
--- pkg-config-0.24/check/check-whitespace.escape 2010-05-23 16:57:37.000000000 -0400
+++ pkg-config-0.24/check/check-whitespace 2010-05-26 12:37:22.879786257 -0400
@@ -1,20 +0,0 @@
-#! /bin/sh
-
-# Make sure we're POSIX
-if [ "$PKG_CONFIG_SHELL_IS_POSIX" != "1" ]; then
- PKG_CONFIG_SHELL_IS_POSIX=1 PATH=`getconf PATH` exec sh $0 "$@"
-fi
-
-set -e
-
-. ${srcdir}/common
-
-# expect cflags from whitespace
-ARGS="--cflags whitespace"
-RESULT="-I/usr/white\\ space/include -Iinclude\\ dir -Iother\\ include\\ dir"
-run_test
-
-# expect libs from whitespace
-ARGS="--libs whitespace"
-RESULT="-L/usr/white\\ space/lib -lfoo\\ bar -lbar\\ baz"
-run_test
diff -up pkg-config-0.24/check/Makefile.am.escape pkg-config-0.24/check/Makefile.am
--- pkg-config-0.24/check/Makefile.am.escape 2010-05-23 17:29:58.000000000 -0400
+++ pkg-config-0.24/check/Makefile.am 2010-05-26 12:37:46.585018199 -0400
@@ -1,10 +1,10 @@
TESTS = check-cflags check-libs check-define-variable \
check-libs-private check-requires-private check-includedir \
- check-conflicts check-missing check-idirafter check-whitespace
+ check-conflicts check-missing check-idirafter
EXTRA_DIST = $(TESTS) common simple.pc requires-test.pc public-dep.pc \
private-dep.pc includedir.pc missing-requires-private.pc \
- missing-requires.pc idirafter.pc conflicts-test.pc whitespace.pc
+ missing-requires.pc idirafter.pc conflicts-test.pc
DISTCLEANFILES = config.sh
diff -up pkg-config-0.24/check/whitespace.pc.escape pkg-config-0.24/check/whitespace.pc
--- pkg-config-0.24/check/whitespace.pc.escape 2010-05-23 16:56:50.000000000 -0400
+++ pkg-config-0.24/check/whitespace.pc 2010-05-26 12:37:22.880785838 -0400
@@ -1,11 +0,0 @@
-prefix=/usr
-exec_prefix=${prefix}
-libdir="${exec_prefix}/white space/lib"
-includedir="${prefix}/white space/include"
-
-Name: Whitespace test
-Description: Dummy pkgconfig test package for testing pkgconfig
-Version: 1.0.0
-Requires:
-Libs: -L${libdir} -lfoo\ bar "-lbar baz"
-Cflags: -I${includedir} -Iinclude\ dir "-Iother include dir"
diff -up pkg-config-0.24/parse.c.escape pkg-config-0.24/parse.c
--- pkg-config-0.24/parse.c.escape 2010-05-26 12:37:22.839019809 -0400
+++ pkg-config-0.24/parse.c 2010-05-26 12:37:22.881780670 -0400
@@ -633,31 +633,6 @@ parse_conflicts (Package *pkg, const cha
g_free (trimmed);
}
-static char *strdup_escape_shell(const char *s)
-{
- size_t r_s = strlen(s)+10, c = 0;
- char *r = g_malloc(r_s);
- while (s[0]) {
- if ((s[0] < '+') ||
- (s[0] > '9' && s[0] < '@') ||
- (s[0] > 'Z' && s[0] < '^') ||
- (s[0] == '`') ||
- (s[0] > 'z')) {
- r[c] = '\\';
- c++;
- }
- r[c] = *s;
- c++;
- if (c+2 >= r_s) {
- r_s *= 2;
- r = g_realloc(r, r_s);
- }
- s++;
- }
- r[c] = 0;
- return r;
-}
-
static void _do_parse_libs (Package *pkg, int argc, char **argv)
{
int i;
@@ -674,11 +649,12 @@ static void _do_parse_libs (Package *pkg
i = 0;
while (i < argc)
{
- char *tmp = trim_string (argv[i]);
- char *arg = strdup_escape_shell(tmp);
+ char *arg = trim_string (argv[i]);
char *p;
- p = arg;
- g_free(tmp);
+ char *start;
+
+ start = arg;
+ p = start;
if (p[0] == '-' &&
p[1] == 'l' &&
@@ -686,23 +662,43 @@ static void _do_parse_libs (Package *pkg
flag. */
(strncmp(p, "-lib:", 5) != 0))
{
+ char *libname;
+
p += 2;
while (*p && isspace ((guchar)*p))
++p;
+
+ start = p;
+ while (*p && !isspace ((guchar)*p))
+ ++p;
+ libname = g_strndup (start, p - start);
+
pkg->l_libs = g_slist_prepend (pkg->l_libs,
- g_strconcat (l_flag, p, lib_suffix, NULL));
+ g_strconcat (l_flag, libname, lib_suffix, NULL));
+ g_free (libname);
}
else if (p[0] == '-' &&
p[1] == 'L')
{
+ char *libname;
+
p += 2;
while (*p && isspace ((guchar)*p))
++p;
- pkg->L_libs = g_slist_prepend (pkg->L_libs,
- g_strconcat (L_flag, p, NULL));
- }
+
+ start = p;
+ while (*p && !isspace ((guchar)*p))
+ ++p;
+
+ libname = g_strndup (start, p - start);
+
+ pkg->L_libs = g_slist_prepend (pkg->L_libs,
+ g_strconcat (L_flag, libname, NULL));
+
+ g_free (libname);
+ }
else if (strcmp("-framework",p) == 0 && i+1 < argc)
{
/* Mac OS X has a -framework Foo which is really one option,
@@ -710,14 +706,12 @@ static void _do_parse_libs (Package *pkg
* -framework Bar being changed into -framework Foo Bar
* later
*/
- gchar *framework, *tmp = trim_string (argv[i+1]);
+ gchar *framework = trim_string (argv[i+1]);
- framework = strdup_escape_shell(tmp);
pkg->other_libs = g_slist_prepend (pkg->other_libs,
g_strconcat(arg, " ", framework, NULL));
i++;
g_free(framework);
- g_free(tmp);
}
else
{
@@ -727,7 +721,7 @@ static void _do_parse_libs (Package *pkg
}
g_free (arg);
-
+
++i;
}
@@ -762,6 +756,7 @@ parse_libs (Package *pkg, const char *st
exit (1);
}
+
_do_parse_libs(pkg, argc, argv);
g_free (trimmed);
@@ -849,30 +844,39 @@ parse_cflags (Package *pkg, const char *
i = 0;
while (i < argc)
{
- char *tmp = trim_string (argv[i]);
- char *arg = strdup_escape_shell(tmp);
- char *p = arg;
- g_free(tmp);
+ char *arg = trim_string (argv[i]);
+ char *p;
+ char *start;
+
+ start = arg;
+ p = start;
if (p[0] == '-' &&
p[1] == 'I')
{
+ char *libname;
+
p += 2;
while (*p && isspace ((guchar)*p))
++p;
+
+ start = p;
+ while (*p && !isspace ((guchar)*p))
+ ++p;
+ libname = g_strndup (start, p - start);
+
pkg->I_cflags = g_slist_prepend (pkg->I_cflags,
- g_strconcat ("-I", p, NULL));
+ g_strconcat ("-I", libname, NULL));
+ g_free (libname);
} else {
if (*arg != '\0')
pkg->other_cflags = g_slist_prepend (pkg->other_cflags,
g_strdup (arg));
if (strcmp("-idirafter", arg) == 0) {
- tmp = trim_string(argv[++i]);
- char *n = strdup_escape_shell(tmp);
+ char *n = trim_string(argv[++i]);
pkg->other_cflags = g_slist_prepend(pkg->other_cflags, n);
- g_free(tmp);
}
}