system popt

Dan Nicholson dbn.lists at gmail.com
Mon May 24 20:46:15 PDT 2010


On Mon, May 24, 2010 at 06:34:37PM -0700, Dan Nicholson wrote:
> 
> Huh. Just tried it on F12 and it seems like the problem stems from
> gio-2.0 for some reason.
> 
> $ pkg-config --exists --print-errors gio-2.0
> $ echo $?
> 0
> $ ./pkg-config --exists --print-errors gio-2.0
> Couldn't parse Cflags field into an argument vector: missing argument
> $ echo $?
> 1
> 
> And now looking at gio-2.0.pc, I see there's no argument for Cflags:
> 
> $ cat /usr/lib64/pkgconfig/gio-2.0.pc
> prefix=/usr
> exec_prefix=/usr
> libdir=/usr/lib64
> includedir=/usr/include
> 
> giomoduledir=${libdir}/gio/modules
> 
> Name: GIO
> Description: glib I/O library
> Version: 2.22.5
> Requires: glib-2.0,gobject-2.0,gmodule-no-export-2.0
> Libs: -L${libdir} -lgio-2.0
> Cflags:
> 
> Trying it on another .pc file with empty Cflags:
> 
> $ ./pkg-config --exists --print-errors tic
> Couldn't parse Cflags field into an argument vector: missing argument
> 
> So, the answer seems to be that we need to ignore error
> POPT_ERROR_NOARG when parsing the fields since that's perfectly valid
> for our use. I don't know why the ancient builtin popt doesn't throw
> the same error.
> 
> This seems to work (you'll have to patch manually since gmail will
> almost certainly mangle the whitespace):
> 
> diff --git a/parse.c b/parse.c
> index c383c57..7e4f1e8 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -838,7 +838,7 @@ parse_cflags (Package *pkg, const char *str, const char *pat
> 
>    result = poptParseArgvString (trimmed, &argc, &argv);
> 
> -  if (result < 0)
> +  if (result < 0 && result != POPT_ERROR_NOARG)
>      {
>        verbose_error ("Couldn't parse Cflags field into an argument vector: %s\n
>                       poptStrerror (result));
> 
> $ ./pkg-config --exists --print-errors gio-2.0
> $ echo $?
> 0

Actually, you can argue that this is a bug in poptParseArgvString. It's
being passed a string of "" and not handling it graciously by setting
argc to 0. But it's easy enough to work around here. I think the patch
below is probably the right thing to do.

Dan



More information about the pkg-config mailing list