diff options
-rw-r--r-- | ChangeLog.asciidoc | 4 | ||||
-rw-r--r-- | doc/de/autogen/user/weechat_commands.asciidoc | 2 | ||||
-rw-r--r-- | doc/en/autogen/user/weechat_commands.asciidoc | 2 | ||||
-rw-r--r-- | doc/fr/autogen/user/weechat_commands.asciidoc | 2 | ||||
-rw-r--r-- | doc/it/autogen/user/weechat_commands.asciidoc | 2 | ||||
-rw-r--r-- | doc/ja/autogen/user/weechat_commands.asciidoc | 2 | ||||
-rw-r--r-- | doc/pl/autogen/user/weechat_commands.asciidoc | 2 | ||||
-rw-r--r-- | po/cs.po | 5 | ||||
-rw-r--r-- | po/de.po | 5 | ||||
-rw-r--r-- | po/es.po | 5 | ||||
-rw-r--r-- | po/fr.po | 11 | ||||
-rw-r--r-- | po/hu.po | 5 | ||||
-rw-r--r-- | po/it.po | 5 | ||||
-rw-r--r-- | po/ja.po | 5 | ||||
-rw-r--r-- | po/pl.po | 5 | ||||
-rw-r--r-- | po/pt_BR.po | 5 | ||||
-rw-r--r-- | po/ru.po | 5 | ||||
-rw-r--r-- | po/tr.po | 5 | ||||
-rw-r--r-- | po/weechat.pot | 5 | ||||
-rw-r--r-- | src/core/wee-command.c | 58 |
20 files changed, 84 insertions, 56 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index 72fb4ce13..014661ac7 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -19,8 +19,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] === New features -* core: add option "-s" in command /eval to split commands (no more split by - default) (closes #324) +* core: add option "-s" in command /eval to split expression before evaluating + it (no more split by default) (closes #324) * core: add priority in plugins to initialize them in order * irc: add support of "account-notify" capability (closes #11, closes #246) * irc: remove server "freenode" from default config file (closes #309) diff --git a/doc/de/autogen/user/weechat_commands.asciidoc b/doc/de/autogen/user/weechat_commands.asciidoc index 5e875675d..c124bd28a 100644 --- a/doc/de/autogen/user/weechat_commands.asciidoc +++ b/doc/de/autogen/user/weechat_commands.asciidoc @@ -236,7 +236,7 @@ infolists: zeigt Information über die Infolists an [-n] -c <expression1> <operator> <expression2> -n: display result without sending it to buffer (debug mode) - -s: split expression (many commands can be separated by semicolons) + -s: split expression before evaluating it (many commands can be separated by semicolons) -c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons operator: a logical or comparison operator: diff --git a/doc/en/autogen/user/weechat_commands.asciidoc b/doc/en/autogen/user/weechat_commands.asciidoc index 7c696745a..da7145fd5 100644 --- a/doc/en/autogen/user/weechat_commands.asciidoc +++ b/doc/en/autogen/user/weechat_commands.asciidoc @@ -236,7 +236,7 @@ infolists: display infos about infolists [-n] -c <expression1> <operator> <expression2> -n: display result without sending it to buffer (debug mode) - -s: split expression (many commands can be separated by semicolons) + -s: split expression before evaluating it (many commands can be separated by semicolons) -c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons operator: a logical or comparison operator: diff --git a/doc/fr/autogen/user/weechat_commands.asciidoc b/doc/fr/autogen/user/weechat_commands.asciidoc index 8b0f07d6f..8b66a8b95 100644 --- a/doc/fr/autogen/user/weechat_commands.asciidoc +++ b/doc/fr/autogen/user/weechat_commands.asciidoc @@ -236,7 +236,7 @@ infolists : afficher des infos sur les infolists [-n] -c <expression1> <opérateur> <expression2> -n : afficher le résultat sans envoyer au tampon (mode debug) - -s : découper l'expression (plusieurs commandes peuvent être séparées par des points-virgules) + -s : découper l'expression avant de l'évaluer (plusieurs commandes peuvent être séparées par des points-virgules) -c : évaluer comme une condition : utiliser les opérateurs et les parenthèses, retourner une valeur booléenne ("0" ou "1") expression : expression à évaluer, les variables avec le format ${variable} sont remplacées (voir ci-dessous) ; plusieurs commandes peuvent être séparées par des points-virgules opérateur : un opérateur logique ou de comparaison : diff --git a/doc/it/autogen/user/weechat_commands.asciidoc b/doc/it/autogen/user/weechat_commands.asciidoc index 92377941c..c72dd3528 100644 --- a/doc/it/autogen/user/weechat_commands.asciidoc +++ b/doc/it/autogen/user/weechat_commands.asciidoc @@ -236,7 +236,7 @@ infolists: display infos about infolists [-n] -c <expression1> <operator> <expression2> -n: display result without sending it to buffer (debug mode) - -s: split expression (many commands can be separated by semicolons) + -s: split expression before evaluating it (many commands can be separated by semicolons) -c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons operator: a logical or comparison operator: diff --git a/doc/ja/autogen/user/weechat_commands.asciidoc b/doc/ja/autogen/user/weechat_commands.asciidoc index 676cc7a8e..fd3f9dd6f 100644 --- a/doc/ja/autogen/user/weechat_commands.asciidoc +++ b/doc/ja/autogen/user/weechat_commands.asciidoc @@ -236,7 +236,7 @@ infolists: infolist に関する情報を表示 [-n] -c <expression1> <operator> <expression2> -n: display result without sending it to buffer (debug mode) - -s: split expression (many commands can be separated by semicolons) + -s: split expression before evaluating it (many commands can be separated by semicolons) -c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons operator: a logical or comparison operator: diff --git a/doc/pl/autogen/user/weechat_commands.asciidoc b/doc/pl/autogen/user/weechat_commands.asciidoc index 88cfea02b..d1ac2020c 100644 --- a/doc/pl/autogen/user/weechat_commands.asciidoc +++ b/doc/pl/autogen/user/weechat_commands.asciidoc @@ -236,7 +236,7 @@ infolists: wyświetla informacje o infolistach [-n] -c <expression1> <operator> <expression2> -n: display result without sending it to buffer (debug mode) - -s: split expression (many commands can be separated by semicolons) + -s: split expression before evaluating it (many commands can be separated by semicolons) -c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1") expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons operator: a logical or comparison operator: @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2014-11-09 16:23+0100\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1400,7 +1400,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2015-01-25 18:35+0100\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <>\n" @@ -1478,7 +1478,8 @@ msgstr "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>" #, fuzzy msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2014-11-09 16:23+0100\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1438,7 +1438,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" -"PO-Revision-Date: 2015-01-30 08:26+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" +"PO-Revision-Date: 2015-01-30 09:42+0100\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -1450,7 +1450,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -1520,8 +1521,8 @@ msgid "" " /eval -n -c abcd !~ abc ==> 0" msgstr "" " -n : afficher le résultat sans envoyer au tampon (mode debug)\n" -" -s : découper l'expression (plusieurs commandes peuvent être " -"séparées par des points-virgules)\n" +" -s : découper l'expression avant de l'évaluer (plusieurs commandes " +"peuvent être séparées par des points-virgules)\n" " -c : évaluer comme une condition : utiliser les opérateurs et les " "parenthèses, retourner une valeur booléenne (\"0\" ou \"1\")\n" "expression : expression à évaluer, les variables avec le format ${variable} " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2014-11-09 16:23+0100\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1331,7 +1331,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2014-11-09 16:23+0100\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1420,7 +1420,8 @@ msgstr "" #, fuzzy msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2015-01-25 13:54+0900\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/translation_ja>\n" @@ -1417,7 +1417,8 @@ msgstr "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>" #, fuzzy msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2014-12-26 19:51+0100\n" "Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1454,7 +1454,8 @@ msgstr "[-n] <wyrażenie> || [-n] -c <wyrażenie1> <operator> <wyrażenie2>" #, fuzzy msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " diff --git a/po/pt_BR.po b/po/pt_BR.po index 99e9d45a0..b4a3df216 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: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2014-11-09 16:23+0100\n" "Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1456,7 +1456,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+0100\n" "PO-Revision-Date: 2014-11-09 16:23+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1353,7 +1353,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+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" @@ -1188,7 +1188,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " diff --git a/po/weechat.pot b/po/weechat.pot index 368a956d8..5a1b8dae9 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: 2015-01-30 08:25+0100\n" +"POT-Creation-Date: 2015-01-30 09:41+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" @@ -1190,7 +1190,8 @@ msgstr "" msgid "" " -n: display result without sending it to buffer (debug mode)\n" -" -s: split expression (many commands can be separated by semicolons)\n" +" -s: split expression before evaluating it (many commands can be " +"separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, return a " "boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format ${variable} are " diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 176642a96..a4b0f2c22 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1815,7 +1815,7 @@ COMMAND_CALLBACK(debug) COMMAND_CALLBACK(eval) { - int i, print_only, split_command, condition; + int i, print_only, split_command, condition, error; char *result, *ptr_args, *expr, **commands; struct t_hashtable *pointers, *options; @@ -1826,6 +1826,7 @@ COMMAND_CALLBACK(eval) print_only = 0; split_command = 0; condition = 0; + error = 0; COMMAND_MIN_ARGS(2, ""); @@ -1880,7 +1881,6 @@ COMMAND_CALLBACK(eval) hashtable_set (options, "type", "condition"); } - result = NULL; if (print_only) { expr = string_remove_quotes (ptr_args, "\""); @@ -1895,6 +1895,7 @@ COMMAND_CALLBACK(eval) GUI_COLOR(GUI_COLOR_CHAT), result, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + free (result); } else { @@ -1909,35 +1910,50 @@ COMMAND_CALLBACK(eval) } else { - result = eval_expression (ptr_args, pointers, NULL, options); - if (result) + if (split_command) { - if (split_command) + commands = string_split_command (ptr_args, ';'); + if (commands) { - commands = string_split_command (result, ';'); - if (commands) + for (i = 0; commands[i]; i++) { - for (i = 0; commands[i]; i++) + result = eval_expression (commands[i], pointers, NULL, + options); + if (result) { - (void) input_data (buffer, commands[i]); + (void) input_data (buffer, result); + free (result); + } + else + { + error = 1; } - string_free_split_command (commands); } - } - else - { - (void) input_data (buffer, result); + string_free_split_command (commands); } } else { - gui_chat_printf (NULL, - _("%sError in expression to evaluate"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + result = eval_expression (ptr_args, pointers, NULL, options); + if (result) + { + (void) input_data (buffer, result); + free (result); + } + else + { + error = 1; + } } } - if (result) - free (result); + + if (error) + { + gui_chat_printf (NULL, + _("%sError in expression to evaluate"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + } + if (pointers) hashtable_free (pointers); if (options) @@ -7122,8 +7138,8 @@ command_init () " || [-n] -c <expression1> <operator> <expression2>"), N_(" -n: display result without sending it to buffer " "(debug mode)\n" - " -s: split expression (many commands can be separated by " - "semicolons)\n" + " -s: split expression before evaluating it " + "(many commands can be separated by semicolons)\n" " -c: evaluate as condition: use operators and parentheses, " "return a boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format " |