diff options
author | stfn <stfnmd@gmail.com> | 2014-05-07 13:07:59 +0200 |
---|---|---|
committer | stfn <stfnmd@gmail.com> | 2014-05-07 13:07:59 +0200 |
commit | cc03a85744ccb5fcae78b98b94bccb29b7bec929 (patch) | |
tree | a300cd537ad43b31d55aff526ef205c4b006c295 /src/gui | |
parent | bbea2940b70026a779b82f5991095f879681bbfa (diff) | |
download | weechat-cc03a85744ccb5fcae78b98b94bccb29b7bec929.zip |
core: add support for negated tags in filters (closes #72)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-line.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 174c94a06..ad0647200 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -597,7 +597,7 @@ int gui_line_match_tags (struct t_gui_line_data *line_data, int tags_count, char ***tags_array) { - int i, j, k, match, tag_found; + int i, j, k, match, tag_found, tag_negated; if (!line_data) return 0; @@ -611,17 +611,24 @@ gui_line_match_tags (struct t_gui_line_data *line_data, for (j = 0; tags_array[i][j]; j++) { tag_found = 0; + tag_negated = 0; + + /* check if tag is negated (prefixed with a '!') */ + if (tags_array[i][j][0] == '!' && tags_array[i][j][1]) + tag_negated = 1; + for (k = 0; k < line_data->tags_count; k++) { if (string_match (line_data->tags_array[k], - tags_array[i][j], + tag_negated ? + tags_array[i][j] + 1 : tags_array[i][j], 0)) { tag_found = 1; break; } } - if (!tag_found) + if ((!tag_found && !tag_negated) || (tag_found && tag_negated)) { match = 0; break; |