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