From 6a27c57057df8c05815b4816aea78b41ae57336e Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 27 May 2010 22:23:19 +0200 Subject: [PATCH] Handle empty valued fields with newer external popt The bundled popt handled the case of Cflags or Libs with no value, but newer popt linked through --with-installed-popt chokes parsing it into a vector. This is arguably a popt bug in poptParseArgvString, but I guess they expect you not to ask it to split an empty string. --- parse.c | 52 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/parse.c b/parse.c index 918b4f1..48f6f2b 100644 --- a/parse.c +++ b/parse.c @@ -742,7 +742,7 @@ parse_libs (Package *pkg, const char *str, const char *path) char *trimmed; char **argv = NULL; - int argc; + int argc = 0; int result; if (pkg->libs_num > 0) @@ -754,15 +754,19 @@ parse_libs (Package *pkg, const char *str, const char *path) trimmed = trim_and_sub (pkg, str, path); - result = poptParseArgvString (trimmed, &argc, &argv); - - if (result < 0) + if (trimmed && *trimmed) { - verbose_error ("Couldn't parse Libs field into an argument vector: %s\n", - poptStrerror (result)); + result = poptParseArgvString (trimmed, &argc, &argv); - exit (1); + if (result < 0) + { + verbose_error ("Couldn't parse Libs field into an argument vector: %s\n", + poptStrerror (result)); + + exit (1); + } } + _do_parse_libs(pkg, argc, argv); g_free (trimmed); @@ -787,7 +791,7 @@ parse_libs_private (Package *pkg, const char *str, const char *path) char *trimmed; char **argv = NULL; - int argc; + int argc = 0; int result; if (pkg->libs_private_num > 0) @@ -799,14 +803,17 @@ parse_libs_private (Package *pkg, const char *str, const char *path) trimmed = trim_and_sub (pkg, str, path); - result = poptParseArgvString (trimmed, &argc, &argv); - - if (result < 0) + if (trimmed && *trimmed) { - verbose_error ("Couldn't parse Libs.private field into an argument vector: %s\n", - poptStrerror (result)); + result = poptParseArgvString (trimmed, &argc, &argv); - exit (1); + if (result < 0) + { + verbose_error ("Couldn't parse Libs.private field into an argument vector: %s\n", + poptStrerror (result)); + + exit (1); + } } _do_parse_libs(pkg, argc, argv); @@ -824,7 +831,7 @@ parse_cflags (Package *pkg, const char *str, const char *path) char *trimmed; char **argv = NULL; - int argc; + int argc = 0; int result; int i; @@ -837,14 +844,17 @@ parse_cflags (Package *pkg, const char *str, const char *path) trimmed = trim_and_sub (pkg, str, path); - result = poptParseArgvString (trimmed, &argc, &argv); - - if (result < 0) + if (trimmed && *trimmed) { - verbose_error ("Couldn't parse Cflags field into an argument vector: %s\n", - poptStrerror (result)); + result = poptParseArgvString (trimmed, &argc, &argv); - exit (1); + if (result < 0) + { + verbose_error ("Couldn't parse Cflags field into an argument vector: %s\n", + poptStrerror (result)); + + exit (1); + } } i = 0;