summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2013-05-31 05:48:01 -0700
committerDan Nicholson <dbn.lists@gmail.com>2013-05-31 05:53:47 -0700
commitf26a505826acec6b1e1af8d1efdf959913421c3a (patch)
treee8666b316aeb9c1d85ee36c15f71a8ff904ae51a
parentdbf1b7cd093562b282c51ce89b8c5c978783153b (diff)
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.
-rw-r--r--pkg.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg.c b/pkg.c
index f9ab34a..66cd515 100644
--- a/pkg.c
+++ b/pkg.c
@@ -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);
}