summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNikola Pajkovsky <npajkovs@redhat.com>2011-04-05 10:39:33 +0200
committerNikola Pajkovsky <npajkovs@redhat.com>2011-04-05 10:39:33 +0200
commitc1169b2a8292db34d99c327c6aeb315116cf0e00 (patch)
tree14cae822bfa85352c37d21e30057dba3e7078546 /src/lib
parent98445ec1f011601cfe650ef9a36bdada6cb058cb (diff)
parent90fe3a9d0cd766d18d1142d8d6981193a5715643 (diff)
downloadabrt-c1169b2a8292db34d99c327c6aeb315116cf0e00.tar.gz
abrt-c1169b2a8292db34d99c327c6aeb315116cf0e00.tar.xz
abrt-c1169b2a8292db34d99c327c6aeb315116cf0e00.zip
Merge branch 'daemon/blacklist'
* daemon/blacklist: rhbz#692465 - Blacklist doesn't work
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/strbuf.c23
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));