diff options
-rw-r--r-- | ChangeLog.asciidoc | 2 | ||||
-rw-r--r-- | ReleaseNotes.asciidoc | 60 | ||||
-rw-r--r-- | doc/de/weechat_user.de.asciidoc | 14 | ||||
-rw-r--r-- | doc/en/weechat_user.en.asciidoc | 14 | ||||
-rw-r--r-- | doc/fr/weechat_user.fr.asciidoc | 16 | ||||
-rw-r--r-- | doc/it/weechat_user.it.asciidoc | 14 | ||||
-rw-r--r-- | doc/ja/weechat_user.ja.asciidoc | 13 | ||||
-rw-r--r-- | doc/pl/weechat_user.pl.asciidoc | 13 | ||||
-rw-r--r-- | po/cs.po | 7 | ||||
-rw-r--r-- | po/de.po | 8 | ||||
-rw-r--r-- | po/es.po | 7 | ||||
-rw-r--r-- | po/fr.po | 14 | ||||
-rw-r--r-- | po/hu.po | 7 | ||||
-rw-r--r-- | po/it.po | 7 | ||||
-rw-r--r-- | po/ja.po | 30 | ||||
-rw-r--r-- | po/pl.po | 8 | ||||
-rw-r--r-- | po/pt_BR.po | 7 | ||||
-rw-r--r-- | po/ru.po | 7 | ||||
-rw-r--r-- | po/tr.po | 7 | ||||
-rw-r--r-- | po/weechat.pot | 7 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-callback.c | 124 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-config.c | 13 |
22 files changed, 238 insertions, 161 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 059f3e506..7be036d02 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -30,6 +30,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * irc: disable creation of temporary servers by default with command /connect, new option irc.look.temporary_servers * relay: add host in sender for IRC backlog PRIVMSG messages sent to clients +* trigger: evaluate and replace regex groups at same time, new format for regex + option in triggers (incompatible with version 1.0) (closes #224) * trigger: add `${tg_displayed}` in conditions of default trigger "beep" * trigger: add option "restore" in command /trigger diff --git a/ReleaseNotes.asciidoc b/ReleaseNotes.asciidoc index c6a4a54b0..f2dbd0a56 100644 --- a/ReleaseNotes.asciidoc +++ b/ReleaseNotes.asciidoc @@ -17,6 +17,45 @@ http://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog] == Version 1.1 (under dev) +=== New format for regex replacement in triggers + +A new format is used in regex replacement to use regex groups, this format +is incompatible with version 1.0. + +The existing triggers are *NOT automatically updated*. + +[width="50%",cols="1,1,3",options="header"] +|=== +| Old format | New format | Examples (new format) +| `$0` ... `$99` | `${re:0}` ... `${re:99}` | `${re:1}` +| `$+` | `${re:+}` | `${re:+}` +| `$.*N` | `${hide:*,${re:N}}` | `${hide:*,${re:2}}` + + `${hide:-,${re:+}}` +|=== + +Moreover, default triggers used to hide passwords have been fixed for *BSD +operating systems. + +You can restore them with the following command: + +---- +/trigger restore cmd_pass msg_auth server_pass +---- + +If you added triggers with the old regex replacement format, you must update +them manually. + +=== Default "beep" trigger + +The command of "beep" trigger is now executed only if the message is displayed +(not filtered with /filter). + +You can restore the default "beep" trigger with the following command: + +---- +/trigger restore beep +---- + === Relay option relay.irc.backlog_tags The option 'relay.irc.backlog_tags' is now a list separated by commas @@ -54,27 +93,6 @@ instead of milliseconds: * function 'util_timeval_add': the argument 'interval' is now expressed in microseconds. -=== Default "beep" trigger - -The command of "beep" trigger is now executed only if the message is displayed -(not filtered with /filter). - -You can restore the default "beep" trigger with the following command: - ----- -/trigger restore beep ----- - -=== Default triggers for hiding passwords - -Triggers used to hide passwords have been fixed for *BSD operating systems. - -You can restore them with the following command: - ----- -/trigger restore cmd_pass msg_auth server_pass ----- - == Version 1.0.1 (2014-09-28) Bug fix and maintenance release. diff --git a/doc/de/weechat_user.de.asciidoc b/doc/de/weechat_user.de.asciidoc index 94a370c39..63d2b108a 100644 --- a/doc/de/weechat_user.de.asciidoc +++ b/doc/de/weechat_user.de.asciidoc @@ -3138,15 +3138,17 @@ oder mehrere identische Zeichen). Matching groups können in "replace" genutzt werden: -* `$0` bis `$99`: `$0` um alles zu matchen, `$1` bis `$99` um Gruppen zu fangen -* `$+`: der letzte match (mit der höchsten Nummer) -* `$.cN`: match "N" mit allen Zeichen die durch "c" ersetzt wurden (Beispiel: `$.*2` ist die group - #2 mit allen Zeichen die durch `*` ersetzt wurden). +* `${re:0}` bis `${re:99}`: `${re:0}` um alles zu matchen, `${re:1}` bis + `${re:99}` um Gruppen zu fangen +* `${re:+}`: der letzte match (mit der höchsten Nummer) +* `${hide:c,${re:N}}`: match "N" mit allen Zeichen die durch "c" ersetzt wurden + (Beispiel: `${hide:*,${re:2}}` ist die group #2 mit allen Zeichen die durch + `*` ersetzt wurden). Beispiel: nutzte Fettschrift zwischen dem Zeichen "*": ---- -/\*(\S+)\*/*${color:bold}$1${color:-bold}*/ +/\*(\S+)\*/*${color:bold}${re:1}${color:-bold}*/ ---- Beispiel: der Standard-Trigger 'server_pass' nutzt folgenden regulären Ausdruck @@ -3154,7 +3156,7 @@ um ein Passwort in den Befehlen `/server` und `/connect` zu verbergen (die einzelnen Zeichen des Passwortes werden durch `*` ersetzt): ---- -==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==$1$.*4$5 +==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==${re:1}${hide:*,${re:4}}${re:5} ---- [NOTE] diff --git a/doc/en/weechat_user.en.asciidoc b/doc/en/weechat_user.en.asciidoc index 0e0144392..d21ffa7f8 100644 --- a/doc/en/weechat_user.en.asciidoc +++ b/doc/en/weechat_user.en.asciidoc @@ -3062,15 +3062,17 @@ The char "/" can be replaced by any char (one or more identical chars). Matching groups can be used in "replace": -* `$0` to `$99`: `$0` is the whole match, `$1` to `$99` are groups captured -* `$+`: the last match (with highest number) -* `$.cN`: match "N" with all chars replaced by "c" (example: `$.*2` is the group - #2 with all chars replaced by `*`). +* `${re:0}` to `${re:99}`: `${re:0}` is the whole match, `${re:1}` to + `${re:99}` are groups captured +* `${re:+}`: the last match (with highest number) +* `${hide:c,${re:N}}`: match "N" with all chars replaced by "c" + (example: `${hide:*,${re:2}}` is the group #2 with all chars replaced by + `*`). Example: use bold for words between "*": ---- -/\*(\S+)\*/*${color:bold}$1${color:-bold}*/ +/\*(\S+)\*/*${color:bold}${re:1}${color:-bold}*/ ---- Example: default trigger 'server_pass' uses this regular expression to hide @@ -3078,7 +3080,7 @@ password in commands `/server` and `/connect` (chars in passwords are replaced by `*`): ---- -==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==$1$.*4$5 +==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==${re:1}${hide:*,${re:4}}${re:5} ---- [NOTE] diff --git a/doc/fr/weechat_user.fr.asciidoc b/doc/fr/weechat_user.fr.asciidoc index 10edab695..3526fd0a3 100644 --- a/doc/fr/weechat_user.fr.asciidoc +++ b/doc/fr/weechat_user.fr.asciidoc @@ -3161,17 +3161,17 @@ caractères identiques). Les groupes de correspondance peuvent être utilisés dans le "remplacement" : -* `$0` à `$99` : `$0` est la correspondance complète, `$1` à `$99` sont les - groupes capturés -* `$+` : la dernière correspondance (avec le numéro le plus élevé) -* `$.cN` : la correspondance "N" avec tous les caractères remplacés par "c" - (exemple : `$.*2` est le groupe n°2 avec tous les caractères remplacés par - `*`). +* `${re:0}` à `${re:99}` : `${re:0}` est la correspondance complète, `${re:1}` + à `${re:99}` sont les groupes capturés +* `${re:+}` : la dernière correspondance (avec le numéro le plus élevé) +* `${hide:c,${re:N}}` : la correspondance "N" avec tous les caractères + remplacés par "c" (exemple : `${hide:*,${re:2}}` est le groupe n°2 avec tous + les caractères remplacés par `*`). Exemple : utiliser du gras pour les mots entre "*" : ---- -/\*(\S+)\*/*${color:bold}$1${color:-bold}*/ +/\*(\S+)\*/*${color:bold}${re:1}${color:-bold}*/ ---- Exemple : le trigger par défaut 'server_pass' utilise cette expression régulière @@ -3179,7 +3179,7 @@ pour cacher le mot de passe dans les commandes `/server` et `/connect` (les caractères des mots de passe sont remplacés par `*`) : ---- -==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==$1$.*4$5 +==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==${re:1}${hide:*,${re:4}}${re:5} ---- [NOTE] diff --git a/doc/it/weechat_user.it.asciidoc b/doc/it/weechat_user.it.asciidoc index 1077cf636..272feed51 100644 --- a/doc/it/weechat_user.it.asciidoc +++ b/doc/it/weechat_user.it.asciidoc @@ -3204,15 +3204,17 @@ The char "/" can be replaced by any char (one or more identical chars). Matching groups can be used in "replace": -* `$0` to `$99`: `$0` is the whole match, `$1` to `$99` are groups captured -* `$+`: the last match (with highest number) -* `$.cN`: match "N" with all chars replaced by "c" (example: `$.*2` is the group - #2 with all chars replaced by `*`). +* `${re:0}` to `${re:99}`: `${re:0}` is the whole match, `${re:1}` to + `${re:99}` are groups captured +* `${re:+}`: the last match (with highest number) +* `${hide:c,${re:N}}`: match "N" with all chars replaced by "c" + (example: `${hide:*,${re:2}}` is the group #2 with all chars replaced by + `*`). Example: use bold for words between "*": ---- -/\*(\S+)\*/*${color:bold}$1${color:-bold}*/ +/\*(\S+)\*/*${color:bold}${re:1}${color:-bold}*/ ---- Example: default trigger 'server_pass' uses this regular expression to hide @@ -3220,7 +3222,7 @@ password in commands `/server` and `/connect` (chars in passwords are replaced by `*`): ---- -==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==$1$.*4$5 +==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==${re:1}${hide:*,${re:4}}${re:5} ---- [NOTE] diff --git a/doc/ja/weechat_user.ja.asciidoc b/doc/ja/weechat_user.ja.asciidoc index 03386283c..26b2bd2d8 100644 --- a/doc/ja/weechat_user.ja.asciidoc +++ b/doc/ja/weechat_user.ja.asciidoc @@ -3060,15 +3060,16 @@ ${tg_highlight} || ${tg_msg_pv} マッチグループを "replace" の中で利用できます: -* `$0` から `$99`: `$0` はマッチ部分の全体、`$1` から `$99` はグループ化されたマッチ部分 -* `$+`: 最後のマッチ部分 (最大のグループ番号を持つ) -* `$.cN`: マッチグループ "N" のすべての文字を "c" で置換した文字列 (例: `$.*2` はグループ - #2 のすべての文字を `*` で置換した文字列). +* `${re:0}` から `${re:99}`: `${re:0}` はマッチ部分の全体、`${re:1}` から + `${re:99}` はグループ化されたマッチ部分 +* `${re:+}`: 最後のマッチ部分 (最大のグループ番号を持つ) +* `${hide:c,${re:N}}`: マッチグループ "N" のすべての文字を "c" で置換した文字列 + (例: `${hide:*,${re:2}}` はグループ #2 のすべての文字を `*` で置換した文字列). 例: "*" で囲まれた文字を太字にする: ---- -/\*(\S+)\*/*${color:bold}$1${color:-bold}*/ +/\*(\S+)\*/*${color:bold}${re:1}${color:-bold}*/ ---- 例: デフォルトトリガ 'server_pass' はこの正規表現を使って、`/server` @@ -3076,7 +3077,7 @@ ${tg_highlight} || ${tg_msg_pv} `*` で置換しています): ---- -==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==$1$.*4$5 +==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==${re:1}${hide:*,${re:4}}${re:5} ---- [NOTE] diff --git a/doc/pl/weechat_user.pl.asciidoc b/doc/pl/weechat_user.pl.asciidoc index 7934e64d3..6b18ce606 100644 --- a/doc/pl/weechat_user.pl.asciidoc +++ b/doc/pl/weechat_user.pl.asciidoc @@ -3089,22 +3089,23 @@ identycznymi znakami). Dopasowane grupy, które mogą zostać użyte w "zamień": -* `$0` to `$99`: `$0` to pełne dopasowanie, `$1` do `$99` to przechwycone grupy -* `$+`: ostatnie dopasowanie (z najwyższym numerem) -* `$.cN`: dopasowanie "N" z wszystkimi znakami zastąpionymi "c" (przykład: `$.*2` - to grupa #2 ze znakami zastąpionymi `*`). +* `${re:0}` to `${re:99}`: `${re:0}` to pełne dopasowanie, `${re:1}` do + `${re:99}` to przechwycone grupy +* `${re:+}`: ostatnie dopasowanie (z najwyższym numerem) +* `${hide:c,${re:N}}`: dopasowanie "N" z wszystkimi znakami zastąpionymi "c" + (przykład: `${hide:*,${re:2}}` to grupa #2 ze znakami zastąpionymi `*`). Przykład: użyj pogrubienia dla słów pomiędzy "*": ---- -/\*(\S+)\*/*${color:bold}$1${color:-bold}*/ +/\*(\S+)\*/*${color:bold}${re:1}${color:-bold}*/ ---- Przykład: domyślny trigger 'server_pass' używa tego wyrażenia do ukrycia hasła w komendach `/server` i `/connect` (znaki haseł są zastępowane przez `*`): ---- -==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==$1$.*4$5 +==^(/(server|connect) .*-(sasl_)?password=)(\S+)(.*)==${re:1}${hide:*,${re:4}}${re:5} ---- [NOTE] @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -10313,8 +10313,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-10-25 08:36+0100\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <weechatter@arcor.de>\n" @@ -11667,6 +11667,7 @@ msgstr "" "(Hinweis: Inhalt ist evaluiert wenn der Trigger ausgeführt wird, siehe /help " "eval)" +#, fuzzy msgid "" "replace text with a POSIX extended regular expression (it is done only if " "conditions are OK, and before running the command) (note: content is " @@ -11675,8 +11676,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" "ersetzt Text mittels erweitertem regulären POSIX Ausdruck (dies passiert nur " "falls die Bedingungen erfüllt werden und bevor der Befehl ausgeführt wird) " @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -10589,8 +10589,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" -"PO-Revision-Date: 2014-10-16 20:44+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" +"PO-Revision-Date: 2014-10-26 11:00+0100\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -11416,8 +11416,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" "remplacer du texte avec une expression régulière POSIX étendue (cela est " "fait seulement si les conditions sont OK, et avant d'exécuter la commande) " @@ -11429,8 +11430,9 @@ msgstr "" "interprétés dans l'expression régulière (par exemple \"\\n\") ; le " "séparateur \"/\" peut être remplacé par n'importe quel caractère (un ou " "plusieurs identiques) ; les groupes de correspondance peuvent être utilisés " -"dans le remplacement : $0 à $99, $+ pour le dernier groupe et $.cN pour " -"remplacer tous les caractères du groupe N par c" +"dans le remplacement : ${re:0} à ${re:99}, ${re:+} pour le dernier groupe et " +"${hide:c,${re:N}} pour remplacer tous les caractères du groupe N par le " +"caractère 'c'" msgid "" "command(s) to run if conditions are OK, after regex replacements (many " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -9683,8 +9683,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -10767,8 +10767,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-10-25 08:29+0900\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/translation_ja>\n" @@ -40,11 +40,11 @@ msgid "max chars" msgstr "最大文字数" msgid "" -"a WeeChat color name (default, black, (dark)gray, white, (light)red, (light)" -"green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a terminal " -"color number or an alias; attributes are allowed before color (for text " -"color only, not background): \"*\" for bold, \"!\" for reverse, \"/\" for " -"italic, \"_\" for underline" +"a WeeChat color name (default, black, (dark)gray, white, (light)red, " +"(light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a " +"terminal color number or an alias; attributes are allowed before color (for " +"text color only, not background): \"*\" for bold, \"!\" for reverse, \"/\" " +"for italic, \"_\" for underline" msgstr "" "WeeChat の色名 (default、black、(dark)gray、white、(light)red、(light)green、" "brown、yellow、(light)blue、(light)magenta、(light)cyan) 、ターミナル色番号ま" @@ -5918,8 +5918,8 @@ msgstr "" " - 内部サーバ名 (/server add で作成されたもの、利用推奨)\n" " - ホスト名/ポート番号又は IP アドレス/ポート番号、デフォルトの" "ポート番号は 6667\n" -" - 次のフォーマットに従う URL: irc[6][s]://[nickname[:password]@]" -"irc.example.org[:port][/#channel1][,#channel2[...]]\n" +" - 次のフォーマットに従う URL: irc[6][s]://[nickname[:" +"password]@]irc.example.org[:port][/#channel1][,#channel2[...]]\n" " 注意: アドレス/IP/URL を指定した場合、サーバを一時的に作ります " "(保存しません)、/help irc.look.temporary_servers を参照してください。\n" " option: サーバに関するオプション (ブール型オプションでは、value は無視さ" @@ -10826,8 +10826,8 @@ msgid "" "Examples (you can also look at default triggers with /trigger listdefault):\n" " add text attributes *bold*, _underline_ and /italic/ (only in user " "messages):\n" -" /trigger add effects modifier weechat_print \"${tg_tag_nick}\" \"==\\*" -"(\\S+)\\*==*${color:bold}$1${color:-bold}*== ==_(\\S+)_==_${color:" +" /trigger add effects modifier weechat_print \"${tg_tag_nick}\" \"==" +"\\*(\\S+)\\*==*${color:bold}$1${color:-bold}*== ==_(\\S+)_==_${color:" "underline}$1${color:-underline}_== ==/(\\S+)/==/${color:italic}$1${color:-" "italic}/\"\n" " hide nicklist bar on small terminals:\n" @@ -10903,8 +10903,8 @@ msgstr "" "\n" "例 (/trigger listdefault でデフォルトトリガを見ることができます):\n" " テキスト属性 *太字*、_下線_、/イタリック/ を追加 (ユーザメッセージのみ):\n" -" /trigger add effects modifier weechat_print \"${tg_tag_nick}\" \"==\\*" -"(\\S+)\\*==*${color:bold}$1${color:-bold}*== ==_(\\S+)_==_${color:" +" /trigger add effects modifier weechat_print \"${tg_tag_nick}\" \"==" +"\\*(\\S+)\\*==*${color:bold}$1${color:-bold}*== ==_(\\S+)_==_${color:" "underline}$1${color:-underline}_== ==/(\\S+)/==/${color:italic}$1${color:-" "italic}/\"\n" " 狭い端末ではニックネームリストバーを隠す:\n" @@ -10984,6 +10984,7 @@ msgstr "" "コマンドを実行する条件 (フックコールバック内で確認されます) (注意: 内容はトリ" "ガの実行時に評価されます、/help eval を参照)" +#, fuzzy msgid "" "replace text with a POSIX extended regular expression (it is done only if " "conditions are OK, and before running the command) (note: content is " @@ -10992,8 +10993,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" "POSIX 拡張正規表現で置換するテキスト (条件が満足され、コマンドが実行される前" "に置換されます) (注意: 内容はトリガの実行時に評価されます、/help eval を参" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-09-14 00:18+0100\n" "Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -11188,6 +11188,7 @@ msgstr "" "(uwaga: zawartość jest przetwarzana, podczas wykonania triggera, zobacz /" "help eval)" +#, fuzzy msgid "" "replace text with a POSIX extended regular expression (it is done only if " "conditions are OK, and before running the command) (note: content is " @@ -11196,8 +11197,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" "zastępuje tekst za pomocą rozszerzonego wyrażenia regularnego POSIX " "(następuje to tylko wtedy, jeśli warunki są spełnione i przed wykonaniem " diff --git a/po/pt_BR.po b/po/pt_BR.po index 2a0341a1b..cdc9c5ada 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-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -9958,8 +9958,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -9708,8 +9708,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-07-25 07:50+0200\n" "Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8767,8 +8767,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" diff --git a/po/weechat.pot b/po/weechat.pot index c210ede36..d78b85875 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-10-16 20:40+0200\n" +"POT-Creation-Date: 2014-10-26 11:00+0100\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -8691,8 +8691,9 @@ msgid "" "can be separated by a space, for example: \"/regex1/replace1/var1 /regex2/" "replace2/var2\"; escaped chars are interpreted in the regex (for example " "\"\\n\"); the separator \"/\" can be replaced by any char (one or more " -"identical chars); matching groups can be used in replace: $0 to $99, $+ for " -"last match and $.cN to replace all chars of group N by char c" +"identical chars); matching groups can be used in replace: ${re:0} to " +"${re:99}, ${re:+} for last match and ${hide:c,${re:N}} to replace all chars " +"of group N by char 'c'" msgstr "" msgid "" diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c index 79782369d..16a5ceef5 100644 --- a/src/plugins/trigger/trigger-callback.c +++ b/src/plugins/trigger/trigger-callback.c @@ -30,8 +30,11 @@ #include "trigger-buffer.h" -/* one hashtable by hook, used in callback to evaluate "conditions" */ -struct t_hashtable *trigger_callback_hashtable_options = NULL; +/* hashtable used to evaluate "conditions" */ +struct t_hashtable *trigger_callback_hashtable_options_conditions = NULL; + +/* hashtable used to replace with regex */ +struct t_hashtable *trigger_callback_hashtable_options_regex = NULL; /* @@ -148,10 +151,11 @@ trigger_callback_check_conditions (struct t_trigger *trigger, if (!conditions || !conditions[0]) return 1; - value = weechat_string_eval_expression (conditions, - pointers, - extra_vars, - trigger_callback_hashtable_options); + value = weechat_string_eval_expression ( + conditions, + pointers, + extra_vars, + trigger_callback_hashtable_options_conditions); rc = (value && (strcmp (value, "1") == 0)); if (value) free (value); @@ -169,13 +173,27 @@ trigger_callback_replace_regex (struct t_trigger *trigger, struct t_hashtable *extra_vars, int display_monitor) { - char *value, *replace_eval; + char *value; const char *ptr_key, *ptr_value; - int i; + int i, pointers_allocated; + + pointers_allocated = 0; if (trigger->regex_count == 0) return; + if (!pointers) + { + pointers = weechat_hashtable_new (32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_POINTER, + NULL, + NULL); + if (!pointers) + return; + pointers_allocated = 1; + } + for (i = 0; i < trigger->regex_count; i++) { /* if regex is not set (invalid), skip it */ @@ -208,43 +226,45 @@ trigger_callback_replace_regex (struct t_trigger *trigger, continue; } - replace_eval = weechat_string_eval_expression ( - trigger->regex[i].replace_escaped, + weechat_hashtable_set (pointers, "regex", trigger->regex[i].regex); + weechat_hashtable_set (trigger_callback_hashtable_options_regex, + "regex_replace", + trigger->regex[i].replace_escaped); + + value = weechat_string_eval_expression ( + ptr_value, pointers, extra_vars, - NULL); - if (replace_eval) + trigger_callback_hashtable_options_regex); + + if (value) { - value = weechat_string_replace_regex (ptr_value, - trigger->regex[i].regex, - replace_eval, - '$', - NULL, NULL); - if (value) + /* display debug info on trigger buffer */ + if (trigger_buffer && display_monitor) { - /* display debug info on trigger buffer */ - if (trigger_buffer && display_monitor) - { - weechat_printf_tags (trigger_buffer, "no_trigger", - "\t regex %d %s(%s%s%s)%s: " - "%s\"%s%s%s\"", - i + 1, - weechat_color ("chat_delimiters"), - weechat_color ("reset"), - ptr_key, - weechat_color ("chat_delimiters"), - weechat_color ("reset"), - weechat_color ("chat_delimiters"), - weechat_color ("reset"), - value, - weechat_color ("chat_delimiters")); - } - weechat_hashtable_set (extra_vars, ptr_key, value); - free (value); + weechat_printf_tags (trigger_buffer, "no_trigger", + "\t regex %d %s(%s%s%s)%s: " + "%s\"%s%s%s\"", + i + 1, + weechat_color ("chat_delimiters"), + weechat_color ("reset"), + ptr_key, + weechat_color ("chat_delimiters"), + weechat_color ("reset"), + weechat_color ("chat_delimiters"), + weechat_color ("reset"), + value, + weechat_color ("chat_delimiters")); } - free (replace_eval); + weechat_hashtable_set (extra_vars, ptr_key, value); + free (value); } } + + if (pointers_allocated) + weechat_hashtable_free (pointers); + else + weechat_hashtable_remove (pointers, "regex"); } /* @@ -912,16 +932,24 @@ end: void trigger_callback_init () { - trigger_callback_hashtable_options = weechat_hashtable_new (32, - WEECHAT_HASHTABLE_STRING, - WEECHAT_HASHTABLE_STRING, - NULL, - NULL); - if (trigger_callback_hashtable_options) + trigger_callback_hashtable_options_conditions = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); + if (trigger_callback_hashtable_options_conditions) { - weechat_hashtable_set (trigger_callback_hashtable_options, + weechat_hashtable_set (trigger_callback_hashtable_options_conditions, "type", "condition"); } + + trigger_callback_hashtable_options_regex = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING, + NULL, + NULL); } /* @@ -931,6 +959,8 @@ trigger_callback_init () void trigger_callback_end () { - if (trigger_callback_hashtable_options) - weechat_hashtable_free (trigger_callback_hashtable_options); + if (trigger_callback_hashtable_options_conditions) + weechat_hashtable_free (trigger_callback_hashtable_options_conditions); + if (trigger_callback_hashtable_options_regex) + weechat_hashtable_free (trigger_callback_hashtable_options_regex); } diff --git a/src/plugins/trigger/trigger-config.c b/src/plugins/trigger/trigger-config.c index 5ab24a268..91782c962 100644 --- a/src/plugins/trigger/trigger-config.c +++ b/src/plugins/trigger/trigger-config.c @@ -70,7 +70,7 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] = "/set +[^ ]*password[^ ]* +|" "/secure +(passphrase|decrypt|set +[^ ]+) +)" "(.*)" - "==$1$.*+", + "==${re:1}${hide:*,${re:+}}", "", "" }, /* hide password in IRC auth message displayed */ @@ -78,7 +78,8 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] = "modifier", "5000|irc_message_auth", "", - "==^(.*(id|identify|register|ghost +[^ ]+|release +[^ ]+) +)(.*)==$1$.*+", + "==^(.*(id|identify|register|ghost +[^ ]+|release +[^ ]+) +)(.*)" + "==${re:1}${hide:*,${re:+}}", "", "" }, /* hide server password in commands /server and /connect */ @@ -86,7 +87,8 @@ char *trigger_config_default_list[][1 + TRIGGER_NUM_OPTIONS] = "modifier", "5000|input_text_display;5000|history_add", "", - "==^(/(server|connect) .*-(sasl_)?password=)([^ ]+)(.*)==$1$.*4$5" + "==^(/(server|connect) .*-(sasl_)?password=)([^ ]+)(.*)" + "==${re:1}${hide:*,${re:4}}${re:5}" "", "" }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, @@ -314,8 +316,9 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option "chars are interpreted in the regex (for example \"\\n\"); " "the separator \"/\" can be replaced by any char (one or " "more identical chars); matching groups can be used in " - "replace: $0 to $99, $+ for last match and $.cN to replace " - "all chars of group N by char c"), + "replace: ${re:0} to ${re:99}, ${re:+} for last match and " + "${hide:c,${re:N}} to replace all chars of group N by " + "char 'c'"), NULL, 0, 0, value, NULL, 0, NULL, NULL, &trigger_config_change_trigger_regex, NULL, NULL, NULL); break; |