Blame SOURCES/0065-lib-add-strremovech-str-ch.patch

4b6aa8
From efcf993b68fdad24f60e3f4bfbe0a94f8ef666fe Mon Sep 17 00:00:00 2001
4b6aa8
From: Jakub Filak <jfilak@redhat.com>
4b6aa8
Date: Fri, 12 Sep 2014 14:37:45 +0200
4b6aa8
Subject: [LIBREPORT PATCH 65/93] lib: add strremovech(str, ch)
4b6aa8
4b6aa8
Related to rhbz#1140224
4b6aa8
4b6aa8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
4b6aa8
---
4b6aa8
 src/include/internal_libreport.h |  2 ++
4b6aa8
 src/lib/strbuf.c                 | 16 ++++++++++++++++
4b6aa8
 2 files changed, 18 insertions(+)
4b6aa8
4b6aa8
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
4b6aa8
index 9ff89b2..52f466f 100644
4b6aa8
--- a/src/include/internal_libreport.h
4b6aa8
+++ b/src/include/internal_libreport.h
4b6aa8
@@ -111,6 +111,8 @@ int suffixcmp(const char *str, const char *suffix);
4b6aa8
 char *strtrim(char *str);
4b6aa8
 #define strtrimch libreport_strtrimch
4b6aa8
 char *strtrimch(char *str, int ch);
4b6aa8
+#define strremovech libreport_strremovech
4b6aa8
+char *strremovech(char *str, int ch);
4b6aa8
 #define append_to_malloced_string libreport_append_to_malloced_string
4b6aa8
 char *append_to_malloced_string(char *mstr, const char *append);
4b6aa8
 #define skip_whitespace libreport_skip_whitespace
4b6aa8
diff --git a/src/lib/strbuf.c b/src/lib/strbuf.c
4b6aa8
index 8bad558..ef8bda8 100644
4b6aa8
--- a/src/lib/strbuf.c
4b6aa8
+++ b/src/lib/strbuf.c
4b6aa8
@@ -86,6 +86,22 @@ char *strtrimch(char *str, int ch)
4b6aa8
     return str;
4b6aa8
 }
4b6aa8
 
4b6aa8
+/*
4b6aa8
+ * Removes character from a string.
4b6aa8
+ * Modifies the string in-place. Returns the updated string.
4b6aa8
+ */
4b6aa8
+char *strremovech(char *str, int ch)
4b6aa8
+{
4b6aa8
+    char *ret = str;
4b6aa8
+    char *res = str;
4b6aa8
+    for ( ; *str != '\0'; ++str)
4b6aa8
+        if (*str != ch)
4b6aa8
+            *(res++) = *str;
4b6aa8
+
4b6aa8
+    *res = '\0';
4b6aa8
+    return ret;
4b6aa8
+}
4b6aa8
+
4b6aa8
 
4b6aa8
 struct strbuf *strbuf_new(void)
4b6aa8
 {
4b6aa8
-- 
4b6aa8
1.8.3.1
4b6aa8