commit 606145f4a91b1c0626fc2227dbdc06438aeccdf9
parent 3f9089db78e742a8f28178382c89ad3c18513963
Author: Andrej Kacian <ticho@claws-mail.org>
Date: Mon, 13 Aug 2018 20:32:49 +0200
Return a copy of the string also when sanity checks fail.
Also, use GLib's g_return functions instead of ifs and
debug_prints.
Diffstat:
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/src/plugins/rssyl/strutils.c b/src/plugins/rssyl/strutils.c
@@ -47,20 +47,11 @@ gchar *rssyl_strreplace(gchar *source, gchar *pattern,
replacement);
*/
- if( source == NULL || pattern == NULL ) {
- debug_print("RSSyl: source or pattern is NULL!!!\n");
- return source;
- }
-
- if( !g_utf8_validate(source, -1, NULL) ) {
- debug_print("RSSyl: source is not an UTF-8 encoded text\n");
- return source;
- }
+ g_return_val_if_fail(source != NULL, g_strdup(source));
+ g_return_val_if_fail(pattern != NULL, g_strdup(source));
- if( !g_utf8_validate(pattern, -1, NULL) ) {
- debug_print("RSSyl: pattern is not an UTF-8 encoded text\n");
- return source;
- }
+ g_return_val_if_fail(g_utf8_validate(source, -1, NULL), g_strdup(source));
+ g_return_val_if_fail(g_utf8_validate(pattern, -1, NULL), g_strdup(source));
len_pattern = strlen(pattern);
len_replacement = strlen(replacement);