summaryrefslogtreecommitdiff
path: root/src/gui/gui-filter.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-08-07 21:50:04 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-08-12 20:30:13 +0200
commit12a6f74ec01d9daa2e23dce5ab15b1ee3ce09006 (patch)
treeacf40a6fdbe99a8192c29408f130bdf900f12d2e /src/gui/gui-filter.c
parentd699ae89aa0ff818b6264ad17f62377f1753999d (diff)
downloadweechat-12a6f74ec01d9daa2e23dce5ab15b1ee3ce09006.zip
core: fix check of tags in lines
All changes: - fix check of tags in lines: check lines without tags, fix check of tags with negation ("!tag") - add string functions string_split_tags and string_free_split_tags - add tests on function gui_line_match_tags
Diffstat (limited to 'src/gui/gui-filter.c')
-rw-r--r--src/gui/gui-filter.c38
1 files changed, 5 insertions, 33 deletions
diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c
index ed2de8259..0ef5edb97 100644
--- a/src/gui/gui-filter.c
+++ b/src/gui/gui-filter.c
@@ -281,9 +281,9 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
{
struct t_gui_filter *new_filter;
regex_t *regex1, *regex2;
- char *pos_tab, *regex_prefix, **tags_array, buf[512], str_error[512];
+ char *pos_tab, *regex_prefix, buf[512], str_error[512];
const char *ptr_start_regex, *pos_regex_message;
- int i, rc;
+ int rc;
if (!name || !buffer_name || !tags || !regex)
{
@@ -389,28 +389,8 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
",", 0, 0,
&new_filter->num_buffers);
new_filter->tags = (tags) ? strdup (tags) : NULL;
- new_filter->tags_count = 0;
- new_filter->tags_array = NULL;
- if (new_filter->tags)
- {
- tags_array = string_split (new_filter->tags, ",", 0, 0,
- &new_filter->tags_count);
- if (tags_array)
- {
- new_filter->tags_array = malloc (new_filter->tags_count *
- sizeof (*new_filter->tags_array));
- if (new_filter->tags_array)
- {
- for (i = 0; i < new_filter->tags_count; i++)
- {
- new_filter->tags_array[i] = string_split (tags_array[i],
- "+", 0, 0,
- NULL);
- }
- }
- string_free_split (tags_array);
- }
- }
+ new_filter->tags_array = string_split_tags (new_filter->tags,
+ &new_filter->tags_count);
new_filter->regex = strdup (regex);
new_filter->regex_prefix = regex1;
new_filter->regex_message = regex2;
@@ -465,8 +445,6 @@ gui_filter_rename (struct t_gui_filter *filter, const char *new_name)
void
gui_filter_free (struct t_gui_filter *filter)
{
- int i;
-
if (!filter)
return;
@@ -483,13 +461,7 @@ gui_filter_free (struct t_gui_filter *filter)
if (filter->tags)
free (filter->tags);
if (filter->tags_array)
- {
- for (i = 0; i < filter->tags_count; i++)
- {
- string_free_split (filter->tags_array[i]);
- }
- free (filter->tags_array);
- }
+ string_free_split_tags (filter->tags_array);
if (filter->regex)
free (filter->regex);
if (filter->regex_prefix)