aboutsummaryrefslogtreecommitdiffstats
path: root/lib/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/misc.c')
-rw-r--r--lib/misc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/misc.c b/lib/misc.c
index 9384ac4c..1c93f65a 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -770,3 +770,19 @@ gboolean parse_int64(char *string, int base, guint64 *number)
return TRUE;
}
+/* Filters all the characters in 'blacklist' replacing them with 'replacement'.
+ * Modifies the string in-place and returns the string itself.
+ * For the opposite, use g_strcanon() */
+char *str_reject_chars(char *string, const char *reject, char replacement)
+{
+ char *c = string;
+
+ while (*c) {
+ c += strcspn(c, reject);
+ if (*c) {
+ *c = replacement;
+ }
+ }
+
+ return string;
+}