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.
This commit is contained in:
Dan Nicholson 2010-05-27 22:23:19 +02:00 committed by Tollef Fog Heen
parent d9077956e2
commit 6a27c57057

52
parse.c
View file

@ -742,7 +742,7 @@ parse_libs (Package *pkg, const char *str, const char *path)
char *trimmed; char *trimmed;
char **argv = NULL; char **argv = NULL;
int argc; int argc = 0;
int result; int result;
if (pkg->libs_num > 0) 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); trimmed = trim_and_sub (pkg, str, path);
result = poptParseArgvString (trimmed, &argc, &argv); if (trimmed && *trimmed)
if (result < 0)
{ {
verbose_error ("Couldn't parse Libs field into an argument vector: %s\n", result = poptParseArgvString (trimmed, &argc, &argv);
poptStrerror (result));
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); _do_parse_libs(pkg, argc, argv);
g_free (trimmed); g_free (trimmed);
@ -787,7 +791,7 @@ parse_libs_private (Package *pkg, const char *str, const char *path)
char *trimmed; char *trimmed;
char **argv = NULL; char **argv = NULL;
int argc; int argc = 0;
int result; int result;
if (pkg->libs_private_num > 0) 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); trimmed = trim_and_sub (pkg, str, path);
result = poptParseArgvString (trimmed, &argc, &argv); if (trimmed && *trimmed)
if (result < 0)
{ {
verbose_error ("Couldn't parse Libs.private field into an argument vector: %s\n", result = poptParseArgvString (trimmed, &argc, &argv);
poptStrerror (result));
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); _do_parse_libs(pkg, argc, argv);
@ -824,7 +831,7 @@ parse_cflags (Package *pkg, const char *str, const char *path)
char *trimmed; char *trimmed;
char **argv = NULL; char **argv = NULL;
int argc; int argc = 0;
int result; int result;
int i; int i;
@ -837,14 +844,17 @@ parse_cflags (Package *pkg, const char *str, const char *path)
trimmed = trim_and_sub (pkg, str, path); trimmed = trim_and_sub (pkg, str, path);
result = poptParseArgvString (trimmed, &argc, &argv); if (trimmed && *trimmed)
if (result < 0)
{ {
verbose_error ("Couldn't parse Cflags field into an argument vector: %s\n", result = poptParseArgvString (trimmed, &argc, &argv);
poptStrerror (result));
exit (1); if (result < 0)
{
verbose_error ("Couldn't parse Cflags field into an argument vector: %s\n",
poptStrerror (result));
exit (1);
}
} }
i = 0; i = 0;