diff options
author | Nikola Pajkovsky <npajkovs@redhat.com> | 2011-04-04 12:02:27 +0200 |
---|---|---|
committer | Nikola Pajkovsky <npajkovs@redhat.com> | 2011-04-04 12:02:27 +0200 |
commit | 90fe3a9d0cd766d18d1142d8d6981193a5715643 (patch) | |
tree | 7df1a3ef2b4fd08f706345a05b78526d5837eac2 /src/lib/strbuf.c | |
parent | 2ee0754ffb52a8bb65cb718189536b715e56f8d3 (diff) | |
download | abrt-90fe3a9d0cd766d18d1142d8d6981193a5715643.tar.gz abrt-90fe3a9d0cd766d18d1142d8d6981193a5715643.tar.xz abrt-90fe3a9d0cd766d18d1142d8d6981193a5715643.zip |
rhbz#692465 - Blacklist doesn't work
parse_value() doesn't trim the string.
Lest say BlackList = coreutils, mono
the parsed list looks like -> 'coreutils', ' mono'
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
Diffstat (limited to 'src/lib/strbuf.c')
-rw-r--r-- | src/lib/strbuf.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/strbuf.c b/src/lib/strbuf.c index f56815a0..572f11cc 100644 --- a/src/lib/strbuf.c +++ b/src/lib/strbuf.c @@ -37,6 +37,29 @@ int suffixcmp(const char *str, const char *suffix) return strcmp(str + len_minus_suflen, suffix); } +/* + * Trims whitespace characters both from left and right side of a string. + * Modifies the string in-place. Returns the trimmed string. + */ +char *strtrim(char *str) +{ + if (!str) + return NULL; + + // Remove leading spaces. + overlapping_strcpy(str, skip_whitespace(str)); + + // Remove trailing spaces. + int i = strlen(str); + while (--i >= 0) + { + if (!isspace(str[i])) + break; + } + str[++i] = '\0'; + return str; +} + struct strbuf *strbuf_new(void) { struct strbuf *buf = xzalloc(sizeof(*buf)); |