[Commits] [SCM] claws branch, gtk3, updated. 4.0.0-351-g7eb44fab0
mones at claws-mail.org
mones at claws-mail.org
Sat Nov 6 14:06:09 UTC 2021
The branch, gtk3 has been updated
via 7eb44fab06cca53ccd8af89b00e75ed2e8e41f8d (commit)
from da970984adaeb7b5c31dd5b025bd4d3c0ca455b1 (commit)
Summary of changes:
src/common/utils.c | 15 +++++++++++++++
src/common/utils.h | 1 +
src/mainwindow.c | 8 ++------
src/plugins/vcalendar/vcal_folder.c | 11 +----------
4 files changed, 19 insertions(+), 16 deletions(-)
- Log -----------------------------------------------------------------
commit 7eb44fab06cca53ccd8af89b00e75ed2e8e41f8d
Author: Ricardo Mones <ricardo at mones.org>
Date: Sat Nov 6 15:04:58 2021 +0100
Refactor CRLF-truncation into a function
diff --git a/src/common/utils.c b/src/common/utils.c
index 47c56cbb7..4dc6339a3 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -284,6 +284,21 @@ gchar *strcrchomp(gchar *str)
return str;
}
+/* truncates string at first CR (carriage return) or LF (line feed) */
+gchar *strcrlftrunc(gchar *str)
+{
+ gchar *p = NULL;
+
+ if ((str == NULL) || (!*str)) return str;
+
+ if ((p = strstr(str, "\r")) != NULL)
+ *p = '\0';
+ if ((p = strstr(str, "\n")) != NULL)
+ *p = '\0';
+
+ return str;
+}
+
#ifndef HAVE_STRCASESTR
/* Similar to `strstr' but this function ignores the case of both strings. */
gchar *strcasestr(const gchar *haystack, const gchar *needle)
diff --git a/src/common/utils.h b/src/common/utils.h
index 98f771291..787e48f23 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -273,6 +273,7 @@ gchar *strretchomp (gchar *str);
gchar *strtailchomp (gchar *str,
gchar tail_char);
gchar *strcrchomp (gchar *str);
+gchar *strcrlftrunc (gchar *str);
#ifndef HAVE_STRCASESTR
gchar *strcasestr (const gchar *haystack,
const gchar *needle);
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 726e4345d..082f0a27d 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -5429,7 +5429,6 @@ void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
void mainwindow_jump_to(const gchar *target, gboolean popup)
{
gchar *tmp = NULL;
- gchar *p = NULL;
FolderItem *item = NULL;
gchar *msg = NULL;
MainWindow *mainwin = mainwindow_get_mainwindow();
@@ -5446,11 +5445,8 @@ void mainwindow_jump_to(const gchar *target, gboolean popup)
tmp = from_uri;
else
tmp = g_strdup(target);
-
- if ((p = strstr(tmp, "\r")) != NULL)
- *p = '\0';
- if ((p = strstr(tmp, "\n")) != NULL)
- *p = '\0';
+
+ strcrlftrunc(tmp);
if ((item = folder_find_item_from_identifier(tmp))) {
g_print("selecting folder '%s'\n", tmp);
diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c
index e8a34e405..cebfa392a 100644
--- a/src/plugins/vcalendar/vcal_folder.c
+++ b/src/plugins/vcalendar/vcal_folder.c
@@ -1789,19 +1789,10 @@ static gchar *feed_get_title(const gchar *str)
gchar *title = NULL;
if (strstr(str, "X-WR-CALNAME:")) {
title = g_strdup(strstr(str, "X-WR-CALNAME:")+strlen("X-WR-CALNAME:"));
- if (strstr(title, "\n"))
- *(strstr(title, "\n")) = '\0';
- if (strstr(title, "\r"))
- *(strstr(title, "\r")) = '\0';
} else if (strstr(str, "X-WR-CALDESC:")) {
title = g_strdup(strstr(str, "X-WR-CALDESC:")+strlen("X-WR-CALDESC:"));
- if (strstr(title, "\n"))
- *(strstr(title, "\n")) = '\0';
- if (strstr(title, "\r"))
- *(strstr(title, "\r")) = '\0';
}
-
- return title;
+ return strcrlftrunc(title);
}
static void update_subscription_finish(const gchar *uri, gchar *feed, gboolean verbose, gchar *error)
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list