diff options
author | dequis <dx@dxzone.com.ar> | 2015-11-27 20:42:00 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-11-27 20:42:00 -0300 |
commit | 47ab9a9c9411f14bb95da9bfb97a943e1c531c48 (patch) | |
tree | 3f87a8e20d4dfea898d0db4683a89d42d42fc867 /lib/misc.c | |
parent | d088ee8bc50cfe13130da745791f533705acd35e (diff) |
misc.c: Add a str_reject_chars function, use it in otr_filter_colors
Diffstat (limited to 'lib/misc.c')
-rw-r--r-- | lib/misc.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; +} |