diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-05-30 23:16:54 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-25 16:35:27 +0200 |
commit | a680e9b32ec7ba382c294695de142639f8730b62 (patch) | |
tree | dd37ae9b17f93fa36f90429a715f9adca445930f /src/plugins | |
parent | 21d448f5f5cf20a886e78ec319746a10a2a6046a (diff) | |
download | weechat-a680e9b32ec7ba382c294695de142639f8730b62.zip |
fset: allow mask (with "*") as filter
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/fset/fset-option.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/plugins/fset/fset-option.c b/src/plugins/fset/fset-option.c index fd1345167..14c73df63 100644 --- a/src/plugins/fset/fset-option.c +++ b/src/plugins/fset/fset-option.c @@ -175,6 +175,27 @@ fset_option_set_value_string (struct t_config_option *option, } /* + * Checks if a string matches a mask. + * + * If mask has no "*" inside, it just checks if "mask" is inside the "string". + * If mask has at least one "*" inside, the function weechat_string_match is + * used. + * + * Returns: + * 1: string matches mask + * 0: string does not match mask + */ + +int +fset_option_string_match (const char *string, const char *mask) +{ + if (strchr (mask, '*')) + return weechat_string_match (string, mask, 0); + else + return (weechat_strcasestr (string, mask)) ? 1 : 0; +} + +/* * Checks if an option is matching current filter(s). * * Returns: @@ -213,7 +234,7 @@ fset_option_match_filters (const char *config_name, const char *section_name, /* filter by modified values, value */ if (!fset_option_value_different_from_default (fset_option)) return 0; - return (weechat_strcasestr ( + return (fset_option_string_match ( (fset_option->value) ? fset_option->value : FSET_OPTION_VALUE_NULL, fset_option_filter + 2)) ? 1 : 0; } @@ -223,7 +244,7 @@ fset_option_match_filters (const char *config_name, const char *section_name, if (!fset_option_value_different_from_default (fset_option)) return 0; if (fset_option_filter[2] - && !weechat_strcasestr (fset_option->name, fset_option_filter + 2)) + && !fset_option_string_match (fset_option->name, fset_option_filter + 2)) { return 0; } @@ -239,14 +260,14 @@ fset_option_match_filters (const char *config_name, const char *section_name, else if (fset_option_filter[0] == '=') { /* filter by value */ - return (weechat_strcasestr ( + return (fset_option_string_match ( (fset_option->value) ? fset_option->value : FSET_OPTION_VALUE_NULL, fset_option_filter + 1)) ? 1 : 0; } else { /* filter by option name */ - return (weechat_strcasestr (fset_option->name, fset_option_filter)) ? 1 : 0; + return (fset_option_string_match (fset_option->name, fset_option_filter)) ? 1 : 0; } } |