1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

trigger: do not create the trigger with /trigger add if the regex is invalid

This commit is contained in:
Sebastien Helleu
2014-03-02 08:32:05 +01:00
parent 8f0294f8d0
commit ddf3e9043b
16 changed files with 394 additions and 93 deletions
+24 -2
View File
@@ -186,8 +186,30 @@ trigger_config_change_trigger_regex (void *data, struct t_config_option *option)
if (!ptr_trigger)
return;
trigger_split_regex (ptr_trigger->name, weechat_config_string (option),
&ptr_trigger->regex_count, &ptr_trigger->regex);
switch (trigger_regex_split (weechat_config_string (option),
&ptr_trigger->regex_count,
&ptr_trigger->regex))
{
case 0: /* OK */
break;
case -1: /* format error */
weechat_printf (NULL,
_("%sError: invalid format for option \"regex\", "
"see /help trigger.trigger.%s.regex"),
weechat_prefix ("error"), ptr_trigger->name);
break;
case -2: /* regex compilation error */
weechat_printf (NULL,
_("%sError: invalid regular expression in option "
"\"regex\", see /help trigger.trigger.%s.regex"),
weechat_prefix ("error"), ptr_trigger->name);
break;
case -3: /* memory error */
weechat_printf (NULL,
_("%s%s: not enough memory"),
weechat_prefix ("error"), TRIGGER_PLUGIN_NAME);
break;
}
}
/*