Strip trailing space from --cflags/--libs output

pkg-config leaves a trailing space on the flags output as it may have to
do multiple iterations to collect all output and adding the space makes
concatenation simple. However, this leaves a trailing space on the full
returned string unless it's empty. Strip the trailing space after all
the processing is complete.
This commit is contained in:
Dan Nicholson 2013-05-31 05:48:01 -07:00
parent dbf1b7cd09
commit f26a505826

4
pkg.c
View file

@ -989,6 +989,10 @@ packages_get_flags (GList *pkgs, FlagType flags)
g_free (cur);
}
/* Strip trailing space. */
if (str->len > 0 && str->str[str->len - 1] == ' ')
g_string_truncate (str, str->len - 1);
debug_spew ("returning flags string \"%s\"\n", str->str);
return g_string_free (str, FALSE);
}