diff --git a/doc/de/autogen/user/weechat_commands.adoc b/doc/de/autogen/user/weechat_commands.adoc index c08f83c6b..7548770af 100644 --- a/doc/de/autogen/user/weechat_commands.adoc +++ b/doc/de/autogen/user/weechat_commands.adoc @@ -266,67 +266,67 @@ infolists: zeigt Information über die Infolists an /eval [-n|-s] [-n] -c - -n: gibt das Ergebnis aus, ohne das dieses in den Buffer gesendet wird (debug Modus) - -s: teilt Ausdrücke bevor sie evaluiert werden (mehrere Befehle können durch Semikolon getrennt werden) - -c: Auswertung als Bedingung: nutzt Operatoren und runde Klammern, Rückgabewert als Boolean-Wert ("0" oder "1") -expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten); mehrere Befehle werden durch ein Semikolon voneinander getrennt - operator: ein logischer oder vergleichender Operand: - - logische Operanden: - && boolean "und" - || boolean "oder" - - vergleichende Operanden: - == gleich - != ungleich - <= kleiner oder gleich - < kleiner - >= größer oder gleich - > größer - =~ stimmt mit regulärem POSIX Ausdruck überein - !~ stimmt NICHT mit regulärem POSIX Ausdruck überein - =* stimmt mit Maske überein (Platzhalter "*" ist erlaubt) - !* stimmt mit Maske NICHT überein (Platzhalter "*" ist erlaubt) + -n: display result without sending it to buffer (debug mode) + -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: + - logical operators: + && boolean "and" + || boolean "or" + - comparison operators: + == equal + != not equal + <= less or equal + < less + >= greater or equal + > greater + =~ is matching POSIX extended regex + !~ is NOT matching POSIX extended regex + =* is matching mask (wildcard "*" is allowed) + !* is NOT matching mask (wildcard "*" is allowed) -Ein Ausdruck gilt als "wahr" sofern das Ergebnis weder NULL, nicht leer und von "0" abweichend ist. -Für einen Vergleich werden Fließkommazahlen genutzt sofern es sich bei beiden Ausdrücken um gültige Nummer handelt, folgende Formate werden unterstützt: - - Integer (Beispiele: 5, -7) - - Fließkommazahl (Beispiele: 5.2, -7.5, 2.83e-2) - - hexadezimale Zahl (Beispiele: 0xA3, -0xA3) -Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel: +An expression is considered as "true" if it is not NULL, not empty, and different from "0". +The comparison is made using floating point numbers if the two expressions are valid numbers, with one of the following formats: + - integer (examples: 5, -7) + - floating point number (examples: 5.2, -7.5, 2.83e-2) + - hexadecimal number (examples: 0xA3, -0xA3) +To force a string comparison, you can add double quotes around each expression, for example: 50 > 100 ==> 0 "50" > "100" ==> 1 -Einige Variablen werden im Ausdruck, mittels der Formatierung ${variable}, ersetzt. Mögliche Variablen sind, nach Reihenfolge ihrer Priorität: - 1. eine evaluierte Teilzeichenkette (Format: "eval:xxx") - 2. eine Zeichenkette mit Escapesequenzen (Format: "esc:xxx" oder "\xxx") - 3. Zeichen welche in einer Zeichenkette nicht dargestellt werden sollen (Format: "hide:Zeichen,Zeichenkette") - 4. eine Zeichenkette mit einer maximalen Anzahl an Zeichen (Format: "cut:+Max,Suffix,Zeichenkette") - oder maximale Anzahl an Zeichen die auf dem Bildschirm angezeigt werden sollen (Format: "cutscr:Max,Suffix,Zeichenkette oder "cutscr:+Max,Suffix,Zeichenkette") - 5. Ende einer Zeichenkette nutzen (Format: "rev:xxx") - 6. Wiederholung einer Zeichenkette (Format: "repeat:Anzahl,Zeichenkette") - 7. Länge einer Zeichenkette (Format: "length:xxx" oder "lengthscr:xxx") - 8. eine Farbe (Format: "color:xxx", siehe "Anleitung für API Erweiterung", Funktion "color") - 9. eine Info (Format: "info:Name,Argumente", Argumente sind optional) - 10. aktuelles Datum/Uhrzeit (Format: "date" oder "date:format") - 11. eine Umgebungsvariable (Format: "env:XXX") - 12. ein Dreifachoperand (Format: "if:Bedingung?Wert_falls_wahr:Wert_falls_unwahr") - 13. Ergebnis eines Ausdrucks mit Klammern und Operatoren + - * / // % (Format: "calc:xxx") - 14. eine Option (Format: "file.section.option") - 15. der Name einer lokalen Variablen eines Buffer - 16. ein hdata Name/Variable (der Wert wird automatisch in eine Zeichenkette konvertiert), standardmäßig wird für "window" und "buffer" das aktuelle Fenster/Buffer verwendet. -Das Format für hdata kann wie folgt aufgebaut sein: - hdata.var1.var2...: startet mit hdata (der Pointer muss bekannt sein) und fragt eine Variable nach der anderen ab (weitere hdata können folgen) - hdata[list].var1.var2...: startet hdata mittels einer Liste, zum Beispiel: - ${buffer[gui_buffers].full_name}: der vollständige Name des ersten Buffers, in der verknüpften Liste aller Buffer - ${plugin[weechat_plugins].name}: Name der ersten Erweiterung, in der verknüpften Liste aller Erweiterungen - hdata[pointer].var1.var2...: startet hdata mittels einem Pointer, zum Beispiel: - ${buffer[0x1234abcd].full_name}: vollständiger Name eines Buffers und des dazugehörigen Pointers (kann in triggern benutzt werden) -Die vorhandenen Namen für hdata und Variablen sind in der "Anleitung für API Erweiterung", Bereich "weechat_hdata_get". beschrieben +Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority: + 1. an evaluated sub-string (format: "eval:xxx") + 2. a string with escaped chars (format: "esc:xxx" or "\xxx") + 3. a string with chars to hide (format: "hide:char,string") + 4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string") + or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string") + 5. a reversed string (format: "rev:xxx") + 6. a repeated string (format: "repeat:count,string") + 7. length of a string (format: "length:xxx" or "lengthscr:xxx") + 8. a color (format: "color:xxx", see "Plugin API reference", function "color") + 9. an info (format: "info:name,arguments", arguments are optional) + 10. current date/time (format: "date" or "date:format") + 11. an environment variable (format: "env:XXX") + 12. a ternary operator (format: "if:condition?value_if_true:value_if_false") + 13. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") + 14. an option (format: "file.section.option") + 15. a local variable in buffer + 16. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. +Format for hdata can be one of following: + hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed) + hdata[list].var1.var2...: start with a hdata using a list, for example: + ${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers + ${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins + hdata[pointer].var1.var2...: start with a hdata using a pointer, for example: + ${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers) +For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get". -Beispiele (einfache Zeichenketten): +Examples (simple strings): /eval -n ${info:version} ==> 0.4.3 /eval -n ${env:HOME} ==> /home/user /eval -n ${weechat.look.scroll_amount} ==> 3 - /eval -n ${sec.data.freenode_password} ==> geheim + /eval -n ${sec.data.freenode_password} ==> secret /eval -n ${window} ==> 0x2549aa0 /eval -n ${window.buffer} ==> 0x2549320 /eval -n ${window.buffer.full_name} ==> core.weechat @@ -342,16 +342,16 @@ Beispiele (einfache Zeichenketten): /eval -n ${length:test} ==> 4 /eval -n ${calc:(5+2)*3} ==> 21 -Beispiele (Bedingungen): - /eval -n -c ${window.buffer.number} > 2 ==> 0 - /eval -n -c ${window.win_width} > 100 ==> 1 - /eval -n -c (8 > 12) || (5 > 2) ==> 1 - /eval -n -c (8 > 12) && (5 > 2) ==> 0 - /eval -n -c abcd =~ ^ABC ==> 1 - /eval -n -c abcd =~ (?-i)^ABC ==> 0 - /eval -n -c abcd =~ (?-i)^abc ==> 1 - /eval -n -c abcd !~ abc ==> 0 - /eval -n -c abcd =* a*d ==> 1 +Examples (conditions): + /eval -n -c ${window.buffer.number} > 2 ==> 0 + /eval -n -c ${window.win_width} > 100 ==> 1 + /eval -n -c (8 > 12) || (5 > 2) ==> 1 + /eval -n -c (8 > 12) && (5 > 2) ==> 0 + /eval -n -c abcd =~ ^ABC ==> 1 + /eval -n -c abcd =~ (?-i)^ABC ==> 0 + /eval -n -c abcd =~ (?-i)^abc ==> 1 + /eval -n -c abcd !~ abc ==> 0 + /eval -n -c abcd =* a*d ==> 1 ---- [[command_weechat_filter]] diff --git a/doc/en/autogen/user/weechat_commands.adoc b/doc/en/autogen/user/weechat_commands.adoc index 4acf24692..a84d1b074 100644 --- a/doc/en/autogen/user/weechat_commands.adoc +++ b/doc/en/autogen/user/weechat_commands.adoc @@ -309,7 +309,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl 10. current date/time (format: "date" or "date:format") 11. an environment variable (format: "env:XXX") 12. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 13. result of an expression with parentheses and operators + - * / // % (format: "calc:xxx") + 13. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") 14. an option (format: "file.section.option") 15. a local variable in buffer 16. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc index b602ad1c2..e69fbb569 100644 --- a/doc/en/weechat_plugin_api.en.adoc +++ b/doc/en/weechat_plugin_api.en.adoc @@ -2555,18 +2555,21 @@ expanded to last): (_WeeChat ≥ 2.7_) | Result of expression, where parentheses and the following operators are supported: + - `+`: addition + - `-`: subtraction + - `*`: multiplication + - `/`: division + - `//`: result of division without fractional part + - `%`: remainder of division. | + `+++`: addition + + `+-+`: subtraction + + `+*+`: multiplication + + `+/+`: division + + `+//+`: result of division without fractional part + + `+%+`: remainder of division + + `+**+`: power. | `+${calc:5+2*3}+` + `+${calc:(5+2)*3}+` + - `+${calc:9.2%3}+` | + `+${calc:9.2%3}+` + + `+${calc:2**16}+` | `+11+` + `+21+` + - `+0.2+` + `+0.2+` + + `+65536+` | `+${sec.data.name}+` | Value of the secured data `name`. | diff --git a/doc/fr/autogen/user/weechat_commands.adoc b/doc/fr/autogen/user/weechat_commands.adoc index e2e966d85..5807945f1 100644 --- a/doc/fr/autogen/user/weechat_commands.adoc +++ b/doc/fr/autogen/user/weechat_commands.adoc @@ -309,7 +309,7 @@ Des variables sont remplacées dans l'expression, en utilisant le format ${varia 10. la date/heure courante (format : "date" ou "date:format") 11. une variable d'environnement (format : "env:XXX") 12. un opérateur ternaire (format : "if:condition?valeur_si_vrai:valeur_si_faux") - 13. le résultat d'une expression avec parenthèses et les opérateurs + - * / // % (format: "calc:xxx") + 13. le résultat d'une expression avec parenthèses et les opérateurs + - * / // % ** (format: "calc:xxx") 14. une option (format : "fichier.section.option") 15. une variable locale du tampon 16. un hdata/variable (la valeur est automatiquement convertie en chaîne), par défaut "window" et "buffer" pointent vers la fenêtre et le tampon courants. diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc index 583b49ae9..803cf8438 100644 --- a/doc/fr/weechat_plugin_api.fr.adoc +++ b/doc/fr/weechat_plugin_api.fr.adoc @@ -2603,18 +2603,21 @@ première étendue à la dernière) : (_WeeChat ≥ 2.7_) | Résultat de l'expression, où les parenthèses et les opérateurs suivants sont supportés : + - `+` : addition + - `-` : soustraction + - `*` : multiplication + - `/` : division + - `//` : résultat de la division sans la partie décimale + - `%` : reste de la division. | + `+++` : addition + + `+-+` : soustraction + + `+*+` : multiplication + + `+/+` : division + + `+//+` : résultat de la division sans la partie décimale + + `+%+` : reste de la division + + `+**+`: puissance. | `+${calc:5+2*3}+` + `+${calc:(5+2)*3}+` + - `+${calc:9.2%3}+` | + `+${calc:9.2%3}+` + + `+${calc:2**16}+` | `+11+` + `+21+` + - `+0.2+` + `+0.2+` + + `+65536+` | `+${sec.data.nom}+` | Valeur de la donnée sécurisée `nom`. | diff --git a/doc/it/autogen/user/weechat_commands.adoc b/doc/it/autogen/user/weechat_commands.adoc index e2b6961e8..57114e6b8 100644 --- a/doc/it/autogen/user/weechat_commands.adoc +++ b/doc/it/autogen/user/weechat_commands.adoc @@ -309,7 +309,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl 10. current date/time (format: "date" or "date:format") 11. an environment variable (format: "env:XXX") 12. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 13. result of an expression with parentheses and operators + - * / // % (format: "calc:xxx") + 13. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") 14. an option (format: "file.section.option") 15. a local variable in buffer 16. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc index e874795d0..4de105de0 100644 --- a/doc/it/weechat_plugin_api.it.adoc +++ b/doc/it/weechat_plugin_api.it.adoc @@ -2662,18 +2662,21 @@ expanded to last): (_WeeChat ≥ 2.7_) | Result of expression, where parentheses and the following operators are supported: + - `+`: addition + - `-`: subtraction + - `*`: multiplication + - `/`: division + - `//`: result of division without fractional part + - `%`: remainder of division. | + `+++`: addition + + `+-+`: subtraction + + `+*+`: multiplication + + `+/+`: division + + `+//+`: result of division without fractional part + + `+%+`: remainder of division + + `+**+`: power. | `+${calc:5+2*3}+` + `+${calc:(5+2)*3}+` + - `+${calc:9.2%3}+` | + `+${calc:9.2%3}+` + + `+${calc:2**16}+` | `+11+` + `+21+` + - `+0.2+` + `+0.2+` + + `+65536+` | `+${sec.data.name}+` | Value of the secured data `name`. | diff --git a/doc/ja/autogen/user/weechat_commands.adoc b/doc/ja/autogen/user/weechat_commands.adoc index 4ff1a42b4..fc4eee00d 100644 --- a/doc/ja/autogen/user/weechat_commands.adoc +++ b/doc/ja/autogen/user/weechat_commands.adoc @@ -309,7 +309,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl 10. current date/time (format: "date" or "date:format") 11. an environment variable (format: "env:XXX") 12. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 13. result of an expression with parentheses and operators + - * / // % (format: "calc:xxx") + 13. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") 14. an option (format: "file.section.option") 15. a local variable in buffer 16. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc index 1c37b0307..fbf3340f5 100644 --- a/doc/ja/weechat_plugin_api.ja.adoc +++ b/doc/ja/weechat_plugin_api.ja.adoc @@ -2569,18 +2569,21 @@ str5 = weechat.string_eval_expression("password=abc password=def", {}, {}, optio (_WeeChat バージョン 2.7 以上で利用可_) | Result of expression, where parentheses and the following operators are supported: + - `+`: addition + - `-`: subtraction + - `*`: multiplication + - `/`: division + - `//`: result of division without fractional part + - `%`: remainder of division. | + `+++`: addition + + `+-+`: subtraction + + `+*+`: multiplication + + `+/+`: division + + `+//+`: result of division without fractional part + + `+%+`: remainder of division + + `+**+`: power. | `+${calc:5+2*3}+` + `+${calc:(5+2)*3}+` + - `+${calc:9.2%3}+` | + `+${calc:9.2%3}+` + + `+${calc:2**16}+` | `+11+` + `+21+` + - `+0.2+` + `+0.2+` + + `+65536+` | `+${sec.data.name}+` | セキュアデータ `name` の値 | diff --git a/doc/pl/autogen/user/weechat_commands.adoc b/doc/pl/autogen/user/weechat_commands.adoc index cd8c3aa64..cdcef73e0 100644 --- a/doc/pl/autogen/user/weechat_commands.adoc +++ b/doc/pl/autogen/user/weechat_commands.adoc @@ -309,7 +309,7 @@ Some variables are replaced in expression, using the format ${variable}, variabl 10. current date/time (format: "date" or "date:format") 11. an environment variable (format: "env:XXX") 12. a ternary operator (format: "if:condition?value_if_true:value_if_false") - 13. result of an expression with parentheses and operators + - * / // % (format: "calc:xxx") + 13. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx") 14. an option (format: "file.section.option") 15. a local variable in buffer 16. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer. diff --git a/po/cs.po b/po/cs.po index 3e7e1c881..5243bfc1c 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -1580,7 +1580,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/de.po b/po/de.po index 1db1bbe01..27fec3e01 100644 --- a/po/de.po +++ b/po/de.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-09-23 22:06+0200\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -1661,6 +1661,7 @@ msgstr "evaluierter Ausdruck" msgid "[-n|-s] || [-n] -c " msgstr "[-n|-s] || [-n] -c " +#, fuzzy msgid "" " -n: display result without sending it to buffer (debug mode)\n" " -s: split expression before evaluating it (many commands can be " @@ -1716,7 +1717,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/es.po b/po/es.po index 8cfc64b96..f251da6d6 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -1611,7 +1611,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/fr.po b/po/fr.po index 2b0fca272..27211921e 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: 2019-09-23 08:04+0200\n" -"PO-Revision-Date: 2019-09-23 21:26+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" +"PO-Revision-Date: 2019-09-24 21:03+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -1685,7 +1685,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" @@ -1800,7 +1800,7 @@ msgstr "" " 12. un opérateur ternaire (format : \"if:condition?valeur_si_vrai:" "valeur_si_faux\")\n" " 13. le résultat d'une expression avec parenthèses et les opérateurs + - " -"* / // % (format: \"calc:xxx\")\n" +"* / // % ** (format: \"calc:xxx\")\n" " 14. une option (format : \"fichier.section.option\")\n" " 15. une variable locale du tampon\n" " 16. un hdata/variable (la valeur est automatiquement convertie en chaîne), " diff --git a/po/hu.po b/po/hu.po index b4dcc9655..f03245b9f 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -1499,7 +1499,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/it.po b/po/it.po index 818f359b7..790d0176b 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -1594,7 +1594,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/ja.po b/po/ja.po index b4d83727a..bd30de9d8 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-09-22 18:54+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" "Language-Team: Polish \n" @@ -1683,7 +1683,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/pt.po b/po/pt.po index 381ed6551..713bebe6a 100644 --- a/po/pt.po +++ b/po/pt.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-09-22 18:54+0200\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -1652,7 +1652,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/pt_BR.po b/po/pt_BR.po index ad78bbdcf..a67327354 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-05-13 21:32+0200\n" "Last-Translator: Eduardo Elias \n" "Language-Team: weechat-dev \n" @@ -1656,7 +1656,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/ru.po b/po/ru.po index fc9a21ad8..c5c92346d 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-05-13 21:32+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -1521,7 +1521,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/tr.po b/po/tr.po index fb023b491..039ef5743 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2019-05-13 21:32+0200\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -1352,7 +1352,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/po/weechat.pot b/po/weechat.pot index 3d933a422..49760838c 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: 2019-09-23 08:04+0200\n" +"POT-Creation-Date: 2019-09-24 20:55+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -1354,7 +1354,7 @@ msgid "" " 11. an environment variable (format: \"env:XXX\")\n" " 12. a ternary operator (format: \"if:condition?value_if_true:value_if_false" "\")\n" -" 13. result of an expression with parentheses and operators + - * / // % " +" 13. result of an expression with parentheses and operators + - * / // % ** " "(format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" diff --git a/src/core/wee-calc.c b/src/core/wee-calc.c index b31b4e5f9..425f6e423 100644 --- a/src/core/wee-calc.c +++ b/src/core/wee-calc.c @@ -73,7 +73,8 @@ calc_operator_precedence (char *operator) if ((strcmp (operator, "*") == 0) || (strcmp (operator, "/") == 0) || (strcmp (operator, "//") == 0) - || (strcmp (operator, "%") == 0)) + || (strcmp (operator, "%") == 0) + || (strcmp (operator, "**") == 0)) { return 2; } @@ -135,6 +136,9 @@ calc_operation (char *operator, double value1, double value2) if (strcmp (operator, "%") == 0) return (value2 != 0) ? fmod (value1, value2) : 0; + if (strcmp (operator, "**") == 0) + return pow (value1, value2); + return 0; } @@ -217,12 +221,13 @@ calc_format_result (double value, char *result, int max_size) * Calculates an expression, which can contain: * - integer and decimal numbers (ie 2 or 2.5) * - operators: - * +: addition - * -: subtraction - * *: multiplication - * /: division - * \: division giving an integer as result - * %: remainder of division + * +: addition + * -: subtraction + * *: multiplication + * /: division + * \: division giving an integer as result + * %: remainder of division + * **: power * - parentheses: ( ) * * The value returned is a string representation of the result, which can be diff --git a/src/core/wee-command.c b/src/core/wee-command.c index d8a940fa1..c794bf8c6 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -7366,7 +7366,7 @@ command_init () " 12. a ternary operator (format: " "\"if:condition?value_if_true:value_if_false\")\n" " 13. result of an expression with parentheses and operators " - "+ - * / // % (format: \"calc:xxx\")\n" + "+ - * / // % ** (format: \"calc:xxx\")\n" " 14. an option (format: \"file.section.option\")\n" " 15. a local variable in buffer\n" " 16. a hdata name/variable (the value is automatically converted " diff --git a/tests/unit/core/test-core-calc.cpp b/tests/unit/core/test-core-calc.cpp index ae0cea84e..d436b8588 100644 --- a/tests/unit/core/test-core-calc.cpp +++ b/tests/unit/core/test-core-calc.cpp @@ -108,6 +108,18 @@ TEST(CoreCalc, Expression) WEE_CHECK_CALC("-2", "-2%4"); WEE_CHECK_CALC("0", "-2%2"); + /* power */ + WEE_CHECK_CALC("1", "0**0"); + WEE_CHECK_CALC("0", "0**1"); + WEE_CHECK_CALC("1", "1**0"); + WEE_CHECK_CALC("1", "2**0"); + WEE_CHECK_CALC("2", "2**1"); + WEE_CHECK_CALC("4", "2**2"); + WEE_CHECK_CALC("8", "2**3"); + WEE_CHECK_CALC("4294967296", "2**32"); + WEE_CHECK_CALC("0.5", "2**-1"); + WEE_CHECK_CALC("0.25", "2**-2"); + /* multiple operators */ WEE_CHECK_CALC("11", "5+2*3");