You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

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