From ddf3e9043bed41a37d06bf3d5c6a104e7ddbeb79 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 2 Mar 2014 08:32:05 +0100 Subject: [PATCH] trigger: do not create the trigger with /trigger add if the regex is invalid --- po/cs.po | 29 +++++++++++--- po/de.po | 29 +++++++++++--- po/es.po | 29 +++++++++++--- po/fr.po | 35 ++++++++++++---- po/hu.po | 29 +++++++++++--- po/it.po | 29 +++++++++++--- po/ja.po | 29 +++++++++++--- po/pl.po | 29 +++++++++++--- po/pt_BR.po | 29 +++++++++++--- po/ru.po | 29 +++++++++++--- po/tr.po | 29 +++++++++++--- po/weechat.pot | 25 ++++++++++-- src/plugins/trigger/trigger-command.c | 45 ++++++++++++++++++--- src/plugins/trigger/trigger-config.c | 26 +++++++++++- src/plugins/trigger/trigger.c | 57 +++++++++++++++++---------- src/plugins/trigger/trigger.h | 9 ++--- 16 files changed, 394 insertions(+), 93 deletions(-) diff --git a/po/cs.po b/po/cs.po index 155ba71ca..0269ba981 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:24+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -9680,10 +9680,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sChyba: nemohu přejmenovat filter \"%s\" na \"%s\"" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s%s: chyba při zpracování regulárního výrazu \"%s\"" msgid "Trigger monitor" msgstr "" @@ -9756,6 +9755,14 @@ msgstr "Seznam proxy:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sChyba: nemohu napojit kalávesu \"%s\"" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "barva textu pro prefix chyby" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%s%s: \"%s\" není validní regulární výraz (%s)" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sChyba: nemohu odpojit klávesu \"%s\"" @@ -9945,6 +9952,18 @@ msgstr "výchozí příkaz:" msgid "default return codes for hook callback" msgstr "výchozí barva textu pro pole" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/de.po b/po/de.po index 6f3b6fbcb..215fe13b4 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:24+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -10821,10 +10821,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sFehler: Umbenennung des Filters von \"%s\" in \"%s\" nicht möglich" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s%s: Fehler bei der Kompilierung des regulären Ausdruckes \"%s\"" msgid "Trigger monitor" msgstr "" @@ -10897,6 +10896,14 @@ msgstr "Auflistung der Proxys:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sFehler: Tastenbelegung, \"%s\", kann nicht zuordnet werden" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "Textfarbe für Fehler-Präfix" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%sFehler im Ausdruck der verarbeitet werden soll" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sFehler: Tastenbelegung, \"%s\", kann nicht entfernt werden" @@ -11086,6 +11093,18 @@ msgstr "Standardbefehl:" msgid "default return codes for hook callback" msgstr "Standardfarbe des Infobar-Textes" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/es.po b/po/es.po index e7d8fb284..52468afac 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:25+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -9944,10 +9944,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sError: no se pudo renombrar el filtro \"%s\" a \"%s\"" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s%s: error al compilar la expresión regular \"%s\"" msgid "Trigger monitor" msgstr "" @@ -10020,6 +10019,14 @@ msgstr "Lista de proxies:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sError: no se pudo crear el atajo \"%s\"" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "color para el prefijo de error" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%sError en la expresión a evaluar" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sError: no se pudo deshacer el atajo \"%s\"" @@ -10209,6 +10216,18 @@ msgstr "comando predeterminado:" msgid "default return codes for hook callback" msgstr "color por defecto para la barra" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/fr.po b/po/fr.po index 8780b6cea..0b414d647 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" -"PO-Revision-Date: 2014-03-01 18:08+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" +"PO-Revision-Date: 2014-03-02 08:15+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -10564,11 +10564,8 @@ msgstr "" "paramètres)" #, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" -"%s%s: valeur invalide pout l'option \"regex\", voir /help trigger.trigger.%s." -"regex" +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%sErreur: expression régulière invalide dans le trigger \"%s\"" msgid "Trigger monitor" msgstr "Moniteur de trigger" @@ -10634,6 +10631,14 @@ msgstr "Liste des triggers:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sErreur: type de hook \"%s\" invalide" +#, c-format +msgid "%sError: invalid format for regular expression" +msgstr "%sErreur: format invalide pour l'expression régulière" + +#, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%sErreur: expression régulière invalide (la compilation a échoué)" + #, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sErreur: code retour \"%s\" invalide" @@ -10905,6 +10910,22 @@ msgstr "commande par défaut pour un hook" msgid "default return codes for hook callback" msgstr "code retour par défaut pour un callback de hook" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" +"%sErreur: format invalide pour l'option \"regex\", voir /help trigger." +"trigger.%s.regex" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" +"%sErreur: expression régulière invalide dans l'option \"regex\", voir /help " +"trigger.trigger.%s.regex" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/hu.po b/po/hu.po index c47b41bdc..231388aca 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:25+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -9081,10 +9081,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%s ismeretlen opció a \"%s\" parancsnak\n" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s nincs elég memória az információs pult üzenethez\n" msgid "Trigger monitor" msgstr "" @@ -9157,6 +9156,14 @@ msgstr "Aliaszok listája:\n" msgid "%sError: invalid hook type \"%s\"" msgstr "%s nem sikerült a(z) \"%s\" billentyűt hozzárendelni\n" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "belépési nyíl színe" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%s a(z) \"%s\" érvénytelen reguláris kifejezés (%s)\n" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%s nem sikerült a(z) \"%s\" billentyűparancsot visszavonni\n" @@ -9346,6 +9353,18 @@ msgstr "%s belső parancsok:\n" msgid "default return codes for hook callback" msgstr "információs pult szövegének színe" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/it.po b/po/it.po index 47a363e12..a9b6b4274 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:25+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -10110,10 +10110,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sErrore: impossibile rinominare il filtro da \"%s\" a \"%s\"" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s%s: errore nella compilazione dell'espressione regolare \"%s\"" msgid "Trigger monitor" msgstr "" @@ -10186,6 +10185,14 @@ msgstr "Elenco di proxy:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sErrore: impossibile associare il tasto \"%s\"" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "colore del testo per il prefisso di errore" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%sErrore nell'espressione da analizzare" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sErrore: impossibile rimuovere la combinazione del tasto \"%s\"" @@ -10375,6 +10382,18 @@ msgstr "comando predefinito:" msgid "default return codes for hook callback" msgstr "colore predefinito del testo per la barra" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/ja.po b/po/ja.po index 59d8b6326..acdbe356e 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:25+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" @@ -10182,10 +10182,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sエラー: フィルタ \"%s\" の名前を \"%s\" に変更できません" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s%s: 正規表現のコンパイル中にエラー \"%s\"" msgid "Trigger monitor" msgstr "" @@ -10258,6 +10257,14 @@ msgstr "プロキシリスト:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sエラー: キー \"%s\" の割り当てに失敗しました" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "エラープレフィックスのテキスト色" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%s評価する式にエラーがあります" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sエラー: キー \"%s\" の割り当てを解除できません" @@ -10447,6 +10454,18 @@ msgstr "デフォルトコマンド:" msgid "default return codes for hook callback" msgstr "バーのデフォルトテキスト色" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/pl.po b/po/pl.po index 311c5cfd2..37fe90f51 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:25+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -10367,10 +10367,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sBłąd: nie można zmienić nazwy filtru z \"%s\" na \"%s\"" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s%s: błąd podczas kompilowania wyrażenia regularnego \"%s\"" msgid "Trigger monitor" msgstr "" @@ -10443,6 +10442,14 @@ msgstr "Lista proxy:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sBłąd: nie można przypisać klawisza \"%s\"" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "kolor przedrostka błędu" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%sBłąd w wyrażeniu do przetworzenia" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sBłąd: nie można od bindować klawisza \"%s\"" @@ -10632,6 +10639,18 @@ msgstr "domyślna komenda:" msgid "default return codes for hook callback" msgstr "domyślny kolor napisów na pasku" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index c9f670b50..7653c522a 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:25+0100\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" @@ -9314,10 +9314,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sErro: não foi possível renomear filtro \"%s\" para \"%s\"" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s%s: erro ao compilar expressão regular \"%s\"" msgid "Trigger monitor" msgstr "" @@ -9390,6 +9389,14 @@ msgstr "Lista de proxys:" msgid "%sError: invalid hook type \"%s\"" msgstr "%sErro: não foi possível associar o atalho à tecla \"%s\"" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "cor do texto para o prefixo de erro" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%sErro: incapaz de salvar a sessão em arquivo" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sErro: não foi possível desassociar a tecla de atalho \"%s\"" @@ -9579,6 +9586,18 @@ msgstr "comando padrão:" msgid "default return codes for hook callback" msgstr "cor padrão do texto para a barra" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/ru.po b/po/ru.po index 04034743f..8d9da4568 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-20 12:25+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -9106,10 +9106,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%s неизвестный параметр для команды \"%s\"\n" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%s недостаточно памяти для сообщения в строке информации\n" msgid "Trigger monitor" msgstr "" @@ -9182,6 +9181,14 @@ msgstr "Список сокращений:\n" msgid "%sError: invalid hook type \"%s\"" msgstr "%s не могу установить клавишу \"%s\"\n" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "цвет стрелки захода на канал (префикс)" + +#, fuzzy, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "%s \"%s\" не является регулярным выражением (%s)\n" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%s не могу отвязать клавишу \"%s\"\n" @@ -9370,6 +9377,18 @@ msgstr "Внутренние команды %s:\n" msgid "default return codes for hook callback" msgstr "цвет текста информационной панели" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/tr.po b/po/tr.po index 7474b3a56..fd270a0c7 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2014-02-16 11:21+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -8159,10 +8159,9 @@ msgstr "" msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "%sHata: dosya \"%s\" oluşturulamaz" -#, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" -msgstr "" +#, fuzzy, c-format +msgid "%sError: invalid regular expression in trigger \"%s\"" +msgstr "%sHata: dosya \"%s\" oluşturulamaz" msgid "Trigger monitor" msgstr "" @@ -8232,6 +8231,14 @@ msgstr "filtrelerin listesi" msgid "%sError: invalid hook type \"%s\"" msgstr "%sHata: dosya \"%s\" oluşturulamaz" +#, fuzzy, c-format +msgid "%sError: invalid format for regular expression" +msgstr "sunucu isimleri için metin rengi" + +#, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "" + #, fuzzy, c-format msgid "%sError: invalid return code \"%s\"" msgstr "%sHata: dosya \"%s\" oluşturulamaz" @@ -8417,6 +8424,18 @@ msgstr "varsayılan komut:" msgid "default return codes for hook callback" msgstr "çubuk için varsayılan metin rengi" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index aa8454f8c..fef2e6fc4 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.1-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-03-01 18:07+0100\n" +"POT-Creation-Date: 2014-03-02 08:13+0100\n" "PO-Revision-Date: 2013-02-14 18:20+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: weechat-dev \n" @@ -8115,8 +8115,7 @@ msgid "%sError: unable to create hook for trigger \"%s\" (bad arguments)" msgstr "" #, c-format -msgid "" -"%s%s: invalid value for option \"regex\", see /help trigger.trigger.%s.regex" +msgid "%sError: invalid regular expression in trigger \"%s\"" msgstr "" msgid "Trigger monitor" @@ -8183,6 +8182,14 @@ msgstr "" msgid "%sError: invalid hook type \"%s\"" msgstr "" +#, c-format +msgid "%sError: invalid format for regular expression" +msgstr "" + +#, c-format +msgid "%sError: invalid regular expression (compilation failed)" +msgstr "" + #, c-format msgid "%sError: invalid return code \"%s\"" msgstr "" @@ -8362,6 +8369,18 @@ msgstr "" msgid "default return codes for hook callback" msgstr "" +#, c-format +msgid "" +"%sError: invalid format for option \"regex\", see /help trigger.trigger.%s." +"regex" +msgstr "" + +#, c-format +msgid "" +"%sError: invalid regular expression in option \"regex\", see /help trigger." +"trigger.%s.regex" +msgstr "" + msgid "" "if disabled, the hooks are removed from trigger, so it is not called any more" msgstr "" diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c index 7e1b7a76e..efc1371dd 100644 --- a/src/plugins/trigger/trigger-command.c +++ b/src/plugins/trigger/trigger-command.c @@ -285,10 +285,10 @@ trigger_command_list_default (int verbose) for (i = 0; trigger_config_default_list[i][0]; i++) { - trigger_split_regex (trigger_config_default_list[i][0], - trigger_config_default_list[i][5], - ®ex_count, - ®ex); + if (trigger_regex_split (trigger_config_default_list[i][5], + ®ex_count, + ®ex) < 0) + continue; trigger_split_command (trigger_config_default_list[i][6], &commands_count, &commands); @@ -309,7 +309,7 @@ trigger_command_list_default (int verbose) verbose); } - trigger_free_regex (®ex_count, ®ex); + trigger_regex_free (®ex_count, ®ex); if (commands) weechat_string_free_split (commands); } @@ -430,8 +430,10 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { struct t_trigger *ptr_trigger, *ptr_trigger2; + struct t_trigger_regex *regex; char *value, **sargv, **items, input[1024], str_pos[16]; int rc, i, type, count, index_option, enable, sargc, num_items, add_rc; + int regex_count, regex_rc; /* make C compiler happy */ (void) data; @@ -484,6 +486,39 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, weechat_prefix ("error"), sargv[1]); goto end; } + if ((sargc > 4) && sargv[4][0]) + { + regex_count = 0; + regex = NULL; + regex_rc = trigger_regex_split (sargv[4], ®ex_count, ®ex); + trigger_regex_free (®ex_count, ®ex); + switch (regex_rc) + { + case 0: /* OK */ + break; + case -1: /* format error */ + weechat_printf (NULL, + _("%sError: invalid format for regular " + "expression"), + weechat_prefix ("error")); + goto end; + break; + case -2: /* regex compilation error */ + weechat_printf (NULL, + _("%sError: invalid regular expression " + "(compilation failed)"), + weechat_prefix ("error")); + goto end; + break; + case -3: /* memory error */ + weechat_printf (NULL, + _("%s%s: not enough memory"), + weechat_prefix ("error"), + TRIGGER_PLUGIN_NAME); + goto end; + break; + } + } if ((sargc > 6) && sargv[6][0] && (trigger_search_return_code (sargv[6]) < 0)) { diff --git a/src/plugins/trigger/trigger-config.c b/src/plugins/trigger/trigger-config.c index 7f98b5321..ff158a440 100644 --- a/src/plugins/trigger/trigger-config.c +++ b/src/plugins/trigger/trigger-config.c @@ -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; + } } /* diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c index d74c2dda4..45953dcb1 100644 --- a/src/plugins/trigger/trigger.c +++ b/src/plugins/trigger/trigger.c @@ -449,7 +449,7 @@ trigger_hook (struct t_trigger *trigger) */ void -trigger_free_regex (int *regex_count, struct t_trigger_regex **regex) +trigger_regex_free (int *regex_count, struct t_trigger_regex **regex) { int i; @@ -479,25 +479,32 @@ trigger_free_regex (int *regex_count, struct t_trigger_regex **regex) /* * Splits the regex in structures, with regex and replacement text. + * + * Returns: + * 0: OK + * -1: format error + * -2: regex compilation error + * -3: not enough memory */ -void -trigger_split_regex (const char *trigger_name, const char *str_regex, +int +trigger_regex_split (const char *str_regex, int *regex_count, struct t_trigger_regex **regex) { const char *ptr_regex, *pos, *pos_replace, *pos_replace_end; const char *pos_next_regex; char *delimiter; - int index, length_delimiter; + int rc, index, length_delimiter; struct t_trigger_regex *new_regex; + rc = 0; delimiter = NULL; if (!regex_count || !regex) goto end; /* remove any existing regex */ - trigger_free_regex (regex_count, regex); + trigger_regex_free (regex_count, regex); if (!str_regex || !str_regex[0]) goto end; @@ -574,13 +581,15 @@ trigger_split_regex (const char *trigger_name, const char *str_regex, (*regex)[index].str_regex, REG_EXTENDED | REG_ICASE) != 0) { + /* weechat_printf (NULL, _("%s%s: error compiling regular expression \"%s\""), weechat_prefix ("error"), TRIGGER_PLUGIN_NAME, (*regex)[index].str_regex); + */ free ((*regex)[index].regex); (*regex)[index].regex = NULL; - goto end; + goto compile_error; } /* set replace and replace_eval */ @@ -627,24 +636,24 @@ trigger_split_regex (const char *trigger_name, const char *str_regex, goto end; format_error: - weechat_printf (NULL, - _("%s%s: invalid value for option \"regex\", " - "see /help trigger.trigger.%s.regex"), - weechat_prefix ("error"), TRIGGER_PLUGIN_NAME, - trigger_name); - trigger_free_regex (regex_count, regex); + rc = -1; + goto end; + +compile_error: + rc = -2; goto end; memory_error: - weechat_printf (NULL, - _("%s%s: not enough memory"), - weechat_prefix ("error"), TRIGGER_PLUGIN_NAME); - trigger_free_regex (regex_count, regex); + rc = -3; goto end; end: if (delimiter) free (delimiter); + if (rc < 0) + trigger_regex_free (regex_count, regex); + + return rc; } /* @@ -825,10 +834,16 @@ trigger_new_with_options (const char *name, struct t_config_option **options) trigger_add (new_trigger, &triggers, &last_trigger); triggers_count++; - trigger_split_regex (new_trigger->name, - weechat_config_string (new_trigger->options[TRIGGER_OPTION_REGEX]), - &new_trigger->regex_count, - &new_trigger->regex); + if (trigger_regex_split (weechat_config_string (new_trigger->options[TRIGGER_OPTION_REGEX]), + &new_trigger->regex_count, + &new_trigger->regex) < 0) + { + weechat_printf (NULL, + _("%sError: invalid regular expression in trigger " + "\"%s\""), + weechat_prefix ("error"), + name); + } trigger_split_command (weechat_config_string (new_trigger->options[TRIGGER_OPTION_COMMAND]), &new_trigger->commands_count, &new_trigger->commands); @@ -1020,7 +1035,7 @@ trigger_free (struct t_trigger *trigger) /* free data */ trigger_unhook (trigger); - trigger_free_regex (&trigger->regex_count, &trigger->regex); + trigger_regex_free (&trigger->regex_count, &trigger->regex); if (trigger->name) free (trigger->name); for (i = 0; i < TRIGGER_NUM_OPTIONS; i++) diff --git a/src/plugins/trigger/trigger.h b/src/plugins/trigger/trigger.h index 4c5e251ea..2c7346266 100644 --- a/src/plugins/trigger/trigger.h +++ b/src/plugins/trigger/trigger.h @@ -126,12 +126,11 @@ extern int trigger_search_hook_type (const char *type); extern int trigger_search_return_code (const char *return_code); extern struct t_trigger *trigger_search (const char *name); extern struct t_trigger *trigger_search_with_option (struct t_config_option *option); -extern void trigger_free_regex (int *regex_count, +extern void trigger_regex_free (int *regex_count, + struct t_trigger_regex **regex); +extern int trigger_regex_split (const char *str_regex, + int *regex_count, struct t_trigger_regex **regex); -extern void trigger_split_regex (const char *trigger_name, - const char *str_regex, - int *regex_count, - struct t_trigger_regex **regex); extern void trigger_split_command (const char *command, int *commands_count, char ***commands); extern void trigger_unhook (struct t_trigger *trigger);