[Commits] [SCM] claws branch, master, updated. 4.1.1-86-g3ad43ddd0

wwp at claws-mail.org wwp at claws-mail.org
Thu Sep 21 12:32:56 UTC 2023


The branch, master has been updated
       via  3ad43ddd0d3325f2e3d6d4a4dbd6492a6b103a27 (commit)
      from  8ad2efdef6d1434f4ce1cf5530ef8e5a7edf3213 (commit)

Summary of changes:
 src/advsearch.c       | 111 ++++++++++++++++++++++++++++++--------------------
 src/gtk/quicksearch.c |   3 +-
 2 files changed, 68 insertions(+), 46 deletions(-)


- Log -----------------------------------------------------------------
commit 3ad43ddd0d3325f2e3d6d4a4dbd6492a6b103a27
Author: wwp <subscript at free.fr>
Date:   Thu Sep 21 14:32:02 2023 +0200

    fix bug 4700, 'Add v H V search shortcut'
    
    patch by Thomas Orgis

diff --git a/src/advsearch.c b/src/advsearch.c
index 120a595fb..73cc7acf5 100644
--- a/src/advsearch.c
+++ b/src/advsearch.c
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 2012-2014 the Claws Mail team
+ * Copyright (C) 2012-2023 the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -130,11 +129,68 @@ void advsearch_abort(AdvancedSearch *search)
 	search->search_aborted = TRUE;
 }
 
+
+static void advsearch_extract_param(GString *matcherstr, gchar **cmd_start_, gchar **cmd_end_, gboolean quotes, gboolean qualifier, gboolean casesens, gboolean regex)
+{
+	gchar *cmd_start, *cmd_end;
+	gchar term_char, save_char;
+
+	cmd_start = *cmd_start_;
+	cmd_end   = *cmd_end_;
+
+	/* extract a parameter, allow quotes */
+	while (*cmd_end && isspace((guchar)*cmd_end))
+		cmd_end++;
+
+	cmd_start = cmd_end;
+	if (*cmd_start == '"') {
+		term_char = '"';
+		cmd_end++;
+	}
+	else
+		term_char = ' ';
+
+	/* extract actual parameter */
+	while ((*cmd_end) && (*cmd_end != term_char))
+		cmd_end++;
+
+	if (*cmd_end == '"')
+		cmd_end++;
+
+	save_char = *cmd_end;
+	*cmd_end = '\0';
+
+	if (qualifier) {
+		if (casesens)
+			g_string_append(matcherstr, regex ? "regexp " : "match ");
+		else
+			g_string_append(matcherstr, regex ? "regexpcase " : "matchcase ");
+	}
+
+	/* do we need to add quotes ? */
+	if (quotes && term_char != '"')
+		g_string_append(matcherstr, "\"");
+
+	/* copy actual parameter */
+	g_string_append(matcherstr, cmd_start);
+
+	/* do we need to add quotes ? */
+	if (quotes && term_char != '"')
+		g_string_append(matcherstr, "\"");
+
+	/* restore original character */
+	*cmd_end = save_char;
+
+	*cmd_end_   = cmd_end;
+	*cmd_start_ = cmd_start;
+	return;
+}
+
 gchar *advsearch_expand_search_string(const gchar *search_string)
 {
 	int i = 0;
-	gchar term_char, save_char;
 	gchar *cmd_start, *cmd_end;
+	gchar save_char;
 	GString *matcherstr;
 	gchar *returnstr = NULL;
 	gchar *copy_str;
@@ -190,6 +246,7 @@ gchar *advsearch_expand_search_string(const gchar *search_string)
 		{ "x",	"references",			1,	TRUE,	TRUE  },
 		{ "X",  "test",				1,	FALSE,  FALSE },
 		{ "y",	"header \"X-Label\"",		1,	TRUE,	TRUE  },
+		{ "v",	"header",			2,	TRUE,	TRUE  },
 		{ "&",	"&",				0,	FALSE,	FALSE },
 		{ "|",	"|",				0,	FALSE,	FALSE },
 		{ "p",	"partial",			0,	FALSE, 	FALSE },
@@ -258,49 +315,13 @@ gchar *advsearch_expand_search_string(const gchar *search_string)
 				if (cmds[i].numparams == 0)
 					break;
 
-				/* extract a parameter, allow quotes */
-				while (*cmd_end && isspace((guchar)*cmd_end))
-					cmd_end++;
-
-				cmd_start = cmd_end;
-				if (*cmd_start == '"') {
-					term_char = '"';
-					cmd_end++;
-				}
-				else
-					term_char = ' ';
-
-				/* extract actual parameter */
-				while ((*cmd_end) && (*cmd_end != term_char))
-					cmd_end++;
-
-				if (*cmd_end == '"')
-					cmd_end++;
-
-				save_char = *cmd_end;
-				*cmd_end = '\0';
-
-				if (cmds[i].qualifier) {
-					if (casesens)
-						g_string_append(matcherstr, regex ? "regexp " : "match ");
-					else
-						g_string_append(matcherstr, regex ? "regexpcase " : "matchcase ");
+				/* extract a first parameter before the final matched one */
+				if (cmds[i].numparams == 2)
+				{
+					advsearch_extract_param(matcherstr, &cmd_start, &cmd_end, cmds[i].quotes, FALSE, casesens, regex);
+					g_string_append(matcherstr, " ");
 				}
-
-				/* do we need to add quotes ? */
-				if (cmds[i].quotes && term_char != '"')
-					g_string_append(matcherstr, "\"");
-
-				/* copy actual parameter */
-				g_string_append(matcherstr, cmd_start);
-
-				/* do we need to add quotes ? */
-				if (cmds[i].quotes && term_char != '"')
-					g_string_append(matcherstr, "\"");
-
-				/* restore original character */
-				*cmd_end = save_char;
-
+				advsearch_extract_param(matcherstr, &cmd_start, &cmd_end, cmds[i].quotes, cmds[i].qualifier, casesens, regex);
 				break;
 			}
 		}
diff --git a/src/gtk/quicksearch.c b/src/gtk/quicksearch.c
index eb899102f..3bef5159c 100644
--- a/src/gtk/quicksearch.c
+++ b/src/gtk/quicksearch.c
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2022 the Claws Mail team and Colin Leroy
+ * Copyright (C) 1999-2023 the Claws Mail team and Colin Leroy
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -447,6 +447,7 @@ static gchar *search_descr_strings[] = {
 	"tagged",N_("messages which have tag(s)"),
 	"T",	 N_("marked messages"),
 	"U",	 N_("unread messages"),
+	"v H V", N_("messages which contain V in header H"),
 	"x S",	 N_("messages which contain S in References header"),
 	"X \"cmd args\"", N_("messages returning 0 when passed to command - %F is message file"),
 	"y S",	 N_("messages which contain S in X-Label header"),

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list