summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-08-04 08:56:56 +0200
committerSebastien Helleu <flashcode@flashtux.org>2013-08-04 08:56:56 +0200
commitdc878c5b69d498e3edb225e1997455510579deed (patch)
tree2c6dbd6bb5640ce17d23b937463310656ec7f126
parentb94a1ce59baa99e2076c83d82f25cbe5d9a7c19b (diff)
downloadweechat-dc878c5b69d498e3edb225e1997455510579deed.zip
api: add argument "options" in function string_eval_expression, add option "-c" for command /eval (to evaluate a condition)
-rw-r--r--ChangeLog4
-rw-r--r--doc/de/autogen/user/weechat_commands.txt91
-rw-r--r--doc/en/autogen/user/weechat_commands.txt29
-rw-r--r--doc/en/weechat_plugin_api.en.txt34
-rw-r--r--doc/fr/autogen/user/weechat_commands.txt29
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt34
-rw-r--r--doc/it/autogen/user/weechat_commands.txt93
-rw-r--r--doc/it/weechat_plugin_api.it.txt35
-rw-r--r--doc/ja/autogen/user/weechat_commands.txt91
-rw-r--r--po/cs.po32
-rw-r--r--po/de.po34
-rw-r--r--po/es.po32
-rw-r--r--po/fr.po64
-rw-r--r--po/hu.po32
-rw-r--r--po/it.po34
-rw-r--r--po/ja.po34
-rw-r--r--po/pl.po34
-rw-r--r--po/pt_BR.po32
-rw-r--r--po/ru.po32
-rw-r--r--po/tr.po32
-rw-r--r--po/weechat.pot32
-rw-r--r--src/core/wee-command.c111
-rw-r--r--src/core/wee-eval.c114
-rw-r--r--src/core/wee-eval.h3
-rw-r--r--src/core/wee-hdata.c20
-rw-r--r--src/core/wee-string.c8
-rw-r--r--src/gui/gui-bar.c15
-rw-r--r--src/plugins/guile/weechat-guile-api.c17
-rw-r--r--src/plugins/irc/irc-protocol.c6
-rw-r--r--src/plugins/irc/irc-server.c8
-rw-r--r--src/plugins/lua/weechat-lua-api.c19
-rw-r--r--src/plugins/perl/weechat-perl-api.c13
-rw-r--r--src/plugins/python/weechat-python-api.c16
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c20
-rw-r--r--src/plugins/script/script-repo.c2
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c13
-rw-r--r--src/plugins/weechat-plugin.h9
37 files changed, 764 insertions, 494 deletions
diff --git a/ChangeLog b/ChangeLog
index a5f4eaae9..1e6fc82ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.4.2-dev, 2013-08-02
+v0.4.2-dev, 2013-08-04
This document lists all changes for each version.
@@ -52,6 +52,8 @@ Version 0.4.2 (under dev!)
"layout_window"
* core: fix line alignment when option weechat.look.buffer_time_format is set
to empty string
+* api: add argument "options" in function string_eval_expression, add option
+ "-c" for command /eval (to evaluate a condition)
* api: use pointer for infolist "hook" to return only one hook
* api: add new function strlen_screen
* plugins: remove the demo plugin
diff --git a/doc/de/autogen/user/weechat_commands.txt b/doc/de/autogen/user/weechat_commands.txt
index dde392745..d67b971ce 100644
--- a/doc/de/autogen/user/weechat_commands.txt
+++ b/doc/de/autogen/user/weechat_commands.txt
@@ -207,55 +207,56 @@ infolists: zeigt Information über die Infolists an
[command]*`eval`* wertet einen Ausdruck aus und gibt das Resultat im Buffer aus::
........................................
/eval [-n] <expression>
- [-n] <expression1> <operator> <expression2>
-
- -n: zeigt das Ergebnis an, ohne das dieses in den Buffer geschrieben wird (debug Modus)
-expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten)
- 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 Ausdruck überein
- !~ stimmt NICHT mit regulärem Ausdruck überein
-
-Ein Ausdruck gilt als "wahr", sofern das Ergebnis nicht NULL, nicht leer und von "0" abweichend ist.
-Der Vergleich findet zwischen zwei Integer Werten statt, sofern die beiden Ausdrücke gültige Integer-Werte sind.
-Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel:
+ [-n] -c <expression1> <operator> <expression2>
+
+ -n: display result without sending it to buffer (debug mode)
+ -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)
+ 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 regex
+ !~ is NOT matching regex
+
+An expression is considered as "true" if it is not NULL, not empty, and different from "0".
+The comparison is made using integers if the two expressions are valid integers.
+To force a string comparison, 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. der Name einer Option (file.section.option)
- 2. der Name der lokalen Variablen für Buffer
- 3. ein hdata Name/Variable (der Wert wird automatisch als Zeichenkette konvertiert), Standardmäßig wird für "window" und "buffer" das aktuelle Fenster/Buffer verwendet.
-Das Format für hdata:
- 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
-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. the name of an option (file.section.option)
+ 2. the name of a local variable in buffer
+ 3. 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
+For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
-Beispiele:
- /eval -n ${weechat.look.scroll_amount} ==> 3
- /eval -n ${window} ==> 0x2549aa0
- /eval -n ${window.buffer} ==> 0x2549320
- /eval -n ${window.buffer.full_name} ==> core.weechat
- /eval -n ${window.buffer.number} ==> 1
- /eval -n ${window.buffer.number} > 2 ==> 0
- /eval -n ${window.win_width} > 100 ==> 1
- /eval -n (8 > 12) || (5 > 2) ==> 1
- /eval -n (8 > 12) && (5 > 2) ==> 0
- /eval -n abcd =~ ^ABC ==> 1
- /eval -n abcd =~ (?-i)^ABC ==> 0
- /eval -n abcd =~ (?-i)^abc ==> 1
- /eval -n abcd !~ abc ==> 0
+Examples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /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
........................................
[[command_weechat_filter]]
diff --git a/doc/en/autogen/user/weechat_commands.txt b/doc/en/autogen/user/weechat_commands.txt
index 992e470b6..0885078d3 100644
--- a/doc/en/autogen/user/weechat_commands.txt
+++ b/doc/en/autogen/user/weechat_commands.txt
@@ -207,9 +207,10 @@ infolists: display infos about infolists
[command]*`eval`* evaluate expression and send result to buffer::
........................................
/eval [-n] <expression>
- [-n] <expression1> <operator> <expression2>
+ [-n] -c <expression1> <operator> <expression2>
-n: display result without sending it to buffer (debug mode)
+ -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)
operator: a logical or comparison operator:
- logical operators:
@@ -243,19 +244,19 @@ Format for hdata can be one of following:
For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
Examples:
- /eval -n ${weechat.look.scroll_amount} ==> 3
- /eval -n ${window} ==> 0x2549aa0
- /eval -n ${window.buffer} ==> 0x2549320
- /eval -n ${window.buffer.full_name} ==> core.weechat
- /eval -n ${window.buffer.number} ==> 1
- /eval -n ${window.buffer.number} > 2 ==> 0
- /eval -n ${window.win_width} > 100 ==> 1
- /eval -n (8 > 12) || (5 > 2) ==> 1
- /eval -n (8 > 12) && (5 > 2) ==> 0
- /eval -n abcd =~ ^ABC ==> 1
- /eval -n abcd =~ (?-i)^ABC ==> 0
- /eval -n abcd =~ (?-i)^abc ==> 1
- /eval -n abcd !~ abc ==> 0
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /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
........................................
[[command_weechat_filter]]
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index 30e162daa..03e042876 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -1699,7 +1699,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test"
weechat_string_eval_expression
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-_New in version 0.4.0._
+_New in version 0.4.0, updated in 0.4.2._
Evaluate an expression and return result as a string.
Special variables with format `${variable}` are expanded (see command `/eval` in
@@ -1711,7 +1711,8 @@ Prototype:
----------------------------------------
char *weechat_string_eval_expression (const char *expr,
struct t_hashtable *pointers,
- struct t_hashtable *extra_vars);
+ struct t_hashtable *extra_vars,
+ struct t_hashtable *options);
----------------------------------------
Arguments:
@@ -1721,6 +1722,14 @@ Arguments:
pointer); pointers "window" and "buffer" are automatically added if they are
not in hashtable (with pointer to current window/buffer) (can be NULL)
* 'extra_vars': extra variables that will be expanded (can be NULL)
+* 'options': a hashtable with some options (keys and values must be string)
+ (can be NULL):
+** 'type': default behaviour is just to replace values in expression, other
+ types can be selected:
+*** 'condition': the expression is evaluated as a condition: operators and
+ parentheses are used, result is a boolean ("0" or "1")
+** 'prefix': prefix before variables to replace (default: "${")
+** 'suffix': suffix after variables to replace (default: "}")
Return value:
@@ -1731,9 +1740,16 @@ C examples:
[source,C]
----------------------------------------
-char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */
-char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */
-char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */
+struct t_hashtable *options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+if (options)
+ weechat_hashtable_set (options, "type", "condition");
+char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
+char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
+char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
----------------------------------------
Script (Python):
@@ -1741,12 +1757,12 @@ Script (Python):
[source,python]
----------------------------------------
# prototype
-str = weechat.string_eval_expression(expr, pointers, extra_vars)
+str = weechat.string_eval_expression(expr, pointers, extra_vars, options)
# examples
-str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}) # "core.weechat"
-str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}) # "1"
-str3 = weechat.string_eval_expression("abc =~ def", {}, {}) # "0"
+str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
+str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
+str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
----------------------------------------
[[utf-8]]
diff --git a/doc/fr/autogen/user/weechat_commands.txt b/doc/fr/autogen/user/weechat_commands.txt
index ad4d214c0..6752c7592 100644
--- a/doc/fr/autogen/user/weechat_commands.txt
+++ b/doc/fr/autogen/user/weechat_commands.txt
@@ -207,9 +207,10 @@ infolists: afficher des infos sur les infolists
[command]*`eval`* évaluer une expression et envoyer le résultat au tampon::
........................................
/eval [-n] <expression>
- [-n] <expression1> <opérateur> <expression2>
+ [-n] -c <expression1> <opérateur> <expression2>
-n: afficher le résultat sans envoyer au tampon (mode debug)
+ -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)
opérateur: un opérateur logique ou de comparaison :
- opérateurs logiques :
@@ -243,19 +244,19 @@ Le format du hdata peut être le suivant :
Pour le nom du hdata et des variables, voir la "Référence API extension", fonction "weechat_hdata_get".
Exemples:
- /eval -n ${weechat.look.scroll_amount} ==> 3
- /eval -n ${window} ==> 0x2549aa0
- /eval -n ${window.buffer} ==> 0x2549320
- /eval -n ${window.buffer.full_name} ==> core.weechat
- /eval -n ${window.buffer.number} ==> 1
- /eval -n ${window.buffer.number} > 2 ==> 0
- /eval -n ${window.win_width} > 100 ==> 1
- /eval -n (8 > 12) || (5 > 2) ==> 1
- /eval -n (8 > 12) && (5 > 2) ==> 0
- /eval -n abcd =~ ^ABC ==> 1
- /eval -n abcd =~ (?-i)^ABC ==> 0
- /eval -n abcd =~ (?-i)^abc ==> 1
- /eval -n abcd !~ abc ==> 0
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /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
........................................
[[command_weechat_filter]]
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index 5db4d9c16..72df89327 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -1723,7 +1723,7 @@ str3 = weechat.string_input_for_buffer("//test") # "/test"
weechat_string_eval_expression
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-_Nouveau dans la version 0.4.0._
+_Nouveau dans la version 0.4.0, mis à jour dans la 0.4.2._
Evalue l'expression et retourne le résultat sous forme de chaîne.
Les variables spéciales avec le format `${variable}` sont étendues (voir la
@@ -1735,7 +1735,8 @@ Prototype :
----------------------------------------
char *weechat_string_eval_expression (const char *expr,
struct t_hashtable *pointers,
- struct t_hashtable *extra_vars);
+ struct t_hashtable *extra_vars,
+ struct t_hashtable *options);
----------------------------------------
Paramètres :
@@ -1746,6 +1747,14 @@ Paramètres :
sont automatiquement ajoutés s'ils ne sont pas dans la hashtable (avec le
pointer vers fenêtre/tampon courants) (peut être NULL)
* 'extra_vars' : variables additionnelles qui seront étendues (peut être NULL)
+* 'options' : hashtable avec des options (les clés et valeurs doivent être des
+ des chaînes) (peut être NULL) :
+** 'type' : le comportement par défaut est de juste remplacer les valeurs dans
+ l'expression, d'autres types peuvent être choisis :
+*** 'condition' : l'expression est évaluée comme une condition : les opérateurs
+ et parenthèses sont utilisés, le résultat est un booléen ("0" ou "1")
+** 'prefix' : préfixe avant les variables à remplacer (par défaut: "${")
+** 'suffix' : suffixe après les variables à remplacer (par défaut: "}")
Valeur de retour :
@@ -1757,9 +1766,16 @@ Exemples en C :
[source,C]
----------------------------------------
-char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */
-char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */
-char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */
+struct t_hashtable *options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+if (options)
+ weechat_hashtable_set (options, "type", "condition");
+char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
+char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
+char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
----------------------------------------
Script (Python) :
@@ -1767,12 +1783,12 @@ Script (Python) :
[source,python]
----------------------------------------
# prototype
-str = weechat.string_eval_expression(expr, pointers, extra_vars)
+str = weechat.string_eval_expression(expr, pointers, extra_vars, options)
# exemples
-str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}) # "core.weechat"
-str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}) # "1"
-str3 = weechat.string_eval_expression("abc =~ def", {}, {}) # "0"
+str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
+str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
+str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
----------------------------------------
[[utf-8]]
diff --git a/doc/it/autogen/user/weechat_commands.txt b/doc/it/autogen/user/weechat_commands.txt
index 21207d11a..e58f4e8a6 100644
--- a/doc/it/autogen/user/weechat_commands.txt
+++ b/doc/it/autogen/user/weechat_commands.txt
@@ -206,56 +206,57 @@ infolists: mostra informazioni sulle liste info
[[command_weechat_eval]]
[command]*`eval`* analizza l'espressione e invia il risultato al buffer::
........................................
-/eval [-n] <espressione>
- [-n] <espressione1> <operatore> <espressione2>
-
- -n: mostra il risultato senza inviarlo al buffer (modalità debug)
-espressione: espressione da analizzare, le variabili con il formato ${variable} vengono sostituite (vedere sotto)
- operatore: operatore logico o di confronto:
- - operatori logici:
- && "and" booleano
- || "or" booleano
- - operatori di confronto:
- == uguale
- != non uguale
- <= minore o uguale
- < minore
- >= maggiore o uguale
- > maggiore
- =~ corrisponde alla regex
- !~ NON corrisponde alla regex
-
-Un'espressione è considerata come "true" se non è NULL, non vuota, e diversa da "0".
-Il confronto viene fatto usando gli interi se le due espressioni sono interi validi.
-Per forzare il confronto stringa, aggiungere un doppio apice all'espressione, ad esempio:
+/eval [-n] <expression>
+ [-n] -c <expression1> <operator> <expression2>
+
+ -n: display result without sending it to buffer (debug mode)
+ -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)
+ 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 regex
+ !~ is NOT matching regex
+
+An expression is considered as "true" if it is not NULL, not empty, and different from "0".
+The comparison is made using integers if the two expressions are valid integers.
+To force a string comparison, add double quotes around each expression, for example:
50 > 100 ==> 0
"50" > "100" ==> 1
-Alcune variabili vengono sostituite nell'espressione, usando il formato ${variable}, la variabile può essere, in ordine di priorità :
- 1. il nome di un'opzione (file.sezione.opzione)
- 2. il nome di una variabile locale nel buffer
- 3. un nome/variabile hdata (il valore viene automaticamente convertito in stringa, per default "window" e "buffer" puntano alla finestra/buffer correnti.
-Il formato per hdata può essere uno dei seguenti:
- hdata.var1.var2...: inizia con un hdata (il puntatore deve essere noto), e richiedere le variabili a seguire (possono seguire altri hdata)
- hdata[list].var1.var2...: inizia con un hdata usando una lista, ad esempio:
- ${buffer[gui_buffers].full_name}: nome completo del primo buffer nell'elenco collegato dei buffer
- ${plugin[weechat_plugins].name}: nome del primo plugin nell'elenco collegato dei plugin
-Per il nome degli hdata e delle variabili, per favore consultare "Referenze API per Plugin", funzione "weechat_hdata_get".
+Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority :
+ 1. the name of an option (file.section.option)
+ 2. the name of a local variable in buffer
+ 3. 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
+For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
-Esempi:
- /eval -n ${weechat.look.scroll_amount} ==> 3
- /eval -n ${window} ==> 0x2549aa0
- /eval -n ${window.buffer} ==> 0x2549320
- /eval -n ${window.buffer.full_name} ==> core.weechat
- /eval -n ${window.buffer.number} ==> 1
- /eval -n ${window.buffer.number} > 2 ==> 0
- /eval -n ${window.win_width} > 100 ==> 1
- /eval -n (8 > 12) || (5 > 2) ==> 1
- /eval -n (8 > 12) && (5 > 2) ==> 0
- /eval -n abcd =~ ^ABC ==> 1
- /eval -n abcd =~ (?-i)^ABC ==> 0
- /eval -n abcd =~ (?-i)^abc ==> 1
- /eval -n abcd !~ abc ==> 0
+Examples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /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
........................................
[[command_weechat_filter]]
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index ceee1ac49..e2267e4a6 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -1683,7 +1683,8 @@ str3 = weechat.string_input_for_buffer("//test") # "/test"
weechat_string_eval_expression
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-_Novità nella versione 0.4.0._
+// TRANSLATION MISSING
+_Novità nella versione 0.4.0, updated in 0.4.2._
// TRANSLATION MISSING
Evaluate an expression and return result as a string.
@@ -1696,7 +1697,8 @@ Prototipo:
----------------------------------------
char *weechat_string_eval_expression (const char *expr,
struct t_hashtable *pointers,
- struct t_hashtable *extra_vars);
+ struct t_hashtable *extra_vars,
+ struct t_hashtable *options);
----------------------------------------
Argomenti:
@@ -1707,6 +1709,14 @@ Argomenti:
pointer); pointers "window" and "buffer" are automatically added if they are
not in hashtable (with pointer to current window/buffer) (can be NULL)
* 'extra_vars': extra variables that will be expanded (can be NULL)
+* 'options': a hashtable with some options (keys and values must be string)
+ (can be NULL):
+** 'type': default behaviour is just to replace values in expression, other
+ types can be selected:
+*** 'condition': the expression is evaluated as a condition: operators and
+ parentheses are used, result is a boolean ("0" or "1")
+** 'prefix': prefix before variables to replace (default: "${")
+** 'suffix': suffix after variables to replace (default: "}")
Valore restituito:
@@ -1718,9 +1728,16 @@ Esempi in C:
[source,C]
----------------------------------------
-char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL); /* "core.weechat" */
-char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL); /* "1" */
-char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL); /* "0" */
+struct t_hashtable *options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+if (options)
+ weechat_hashtable_set (options, "type", "condition");
+char *str1 = weechat_string_eval_expression ("${buffer.full_name}", NULL, NULL, NULL); /* "core.weechat" */
+char *str2 = weechat_string_eval_expression ("${window.win_width} > 100", NULL, NULL, options); /* "1" */
+char *str3 = weechat_string_eval_expression ("abc =~ def", NULL, NULL, options); /* "0" */
----------------------------------------
Script (Python):
@@ -1728,12 +1745,12 @@ Script (Python):
[source,python]
----------------------------------------
# prototipo
-str = weechat.string_eval_expression(expr, pointers, extra_vars)
+str = weechat.string_eval_expression(expr, pointers, extra_vars, options)
# esempi
-str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}) # "core.weechat"
-str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}) # "1"
-str3 = weechat.string_eval_expression("abc =~ def", {}, {}) # "0"
+str1 = weechat.string_eval_expression("${buffer.full_name}", {}, {}, {}) # "core.weechat"
+str2 = weechat.string_eval_expression("${window.win_width} > 100", {}, {}, {"type": "condition"}) # "1"
+str3 = weechat.string_eval_expression("abc =~ def", {}, {}, {"type": "condition"}) # "0"
----------------------------------------
[[utf-8]]
diff --git a/doc/ja/autogen/user/weechat_commands.txt b/doc/ja/autogen/user/weechat_commands.txt
index 9e7a75043..fa4876108 100644
--- a/doc/ja/autogen/user/weechat_commands.txt
+++ b/doc/ja/autogen/user/weechat_commands.txt
@@ -207,55 +207,56 @@ infolists: infolist に関する情報を表示
[command]*`eval`* 式を評価して結果をバッファに送信::
........................................
/eval [-n] <expression>
- [-n] <expression1> <operator> <expression2>
-
- -n: 結果をバッファに送信せずに表示 (デバッグモード)
-expression: 評価する式、フォーマット、${variable} 型のフォーマットの変数は置換されます (以下を参照)
- operator: 論理演算子や比較演算子:
- - 論理演算子:
- && ブール演算の "and"
- || ブール演算の "or"
- - 比較演算子:
- == 等しい
- != 等しくない
- <= 以下
- < より少ない
- >= 以上
- > より大きい
- =~ 正規表現にマッチ
- !~ 正規表現にマッチしない
-
-式が NULL でない場合、空でない場合、"0" でない場合、式は "真" と評価されます。
-両方の式が有効な整数である場合、比較は整数を使って行われます。
-文字列比較を強制するには、それぞれの式をダブルクォートで囲みます、例えば:
+ [-n] -c <expression1> <operator> <expression2>
+
+ -n: display result without sending it to buffer (debug mode)
+ -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)
+ 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 regex
+ !~ is NOT matching regex
+
+An expression is considered as "true" if it is not NULL, not empty, and different from "0".
+The comparison is made using integers if the two expressions are valid integers.
+To force a string comparison, add double quotes around each expression, for example:
50 > 100 ==> 0
"50" > "100" ==> 1
-式中の ${variable} 型のフォーマットの変数は置換さます。変数は以下の優先順位に従います。
- 1. オプションの名前 (file.section.option)
- 2. バッファのローカル変数の名前
- 3. hdata の名前/変数 (値は自動的に文字列に変換されます)、デフォルトでは "window" と "buffer" は現在のウィンドウ/バッファを指します。
-hdata のフォーマットは以下の 1 つです:
- hdata.var1.var2...: hdata (ポインタは既知) で始まり、1 個ずつ変数を続ける (他の hdata を続けることも可能)
- hdata(list).var1.var2...: リストを使って hdata を始める、例:
- ${buffer[gui_buffers].full_name}: バッファリストにリンクされた最初のバッファのフルネーム
- ${plugin[weechat_plugins].name}: プラグインリストにリンクされた最初のプラグインの名前
-hdata と変数の名前については、"プラグイン API リファレンス" の "weechat_hdata_get" 関数を参照してください。
+Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority :
+ 1. the name of an option (file.section.option)
+ 2. the name of a local variable in buffer
+ 3. 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
+For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
-例:
- /eval -n ${weechat.look.scroll_amount} ==> 3
- /eval -n ${window} ==> 0x2549aa0
- /eval -n ${window.buffer} ==> 0x2549320
- /eval -n ${window.buffer.full_name} ==> core.weechat
- /eval -n ${window.buffer.number} ==> 1
- /eval -n ${window.buffer.number} > 2 ==> 0
- /eval -n ${window.win_width} > 100 ==> 1
- /eval -n (8 > 12) || (5 > 2) ==> 1
- /eval -n (8 > 12) && (5 > 2) ==> 0
- /eval -n abcd =~ ^ABC ==> 1
- /eval -n abcd =~ (?-i)^ABC ==> 0
- /eval -n abcd =~ (?-i)^abc ==> 1
- /eval -n abcd !~ abc ==> 0
+Examples:
+ /eval -n ${weechat.look.scroll_amount} ==> 3
+ /eval -n ${window} ==> 0x2549aa0
+ /eval -n ${window.buffer} ==> 0x2549320
+ /eval -n ${window.buffer.full_name} ==> core.weechat
+ /eval -n ${window.buffer.number} ==> 1
+ /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
........................................
[[command_weechat_filter]]
diff --git a/po/cs.po b/po/cs.po
index 8d4312ddd..ad0baf9a5 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-07-31 18:41+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1271,11 +1271,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr ""
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1319,19 +1321,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
msgid ""
diff --git a/po/de.po b/po/de.po
index e977a7582..0224af6e7 100644
--- a/po/de.po
+++ b/po/de.po
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-08-01 19:57+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <weechatter@arcor.de>\n"
@@ -1317,11 +1317,15 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr "wertet einen Ausdruck aus und gibt das Resultat im Buffer aus"
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+#, fuzzy
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+#, fuzzy
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1365,19 +1369,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
" -n: zeigt das Ergebnis an, ohne das dieses in den Buffer geschrieben "
"wird (debug Modus)\n"
diff --git a/po/es.po b/po/es.po
index c79201c41..4bc4bdce6 100644
--- a/po/es.po
+++ b/po/es.po
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-07-31 18:41+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1308,11 +1308,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr "evaluar la expresión y enviar el resultado al buffer"
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1356,19 +1358,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
msgid ""
diff --git a/po/fr.po b/po/fr.po
index 2d84539f4..4a73b8937 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
-"PO-Revision-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 17:59+0200\n"
+"PO-Revision-Date: 2013-08-03 15:06+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@@ -1301,11 +1301,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr "évaluer une expression et envoyer le résultat au tampon"
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
-msgstr "[-n] <expression> || [-n] <expression1> <opérateur> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
+msgstr "[-n] <expression> || [-n] -c <expression1> <opérateur> <expression2>"
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1349,21 +1351,23 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
" -n: afficher le résultat sans envoyer au tampon (mode debug)\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} "
"sont remplacées (voir ci-dessous)\n"
" opérateur: un opérateur logique ou de comparaison :\n"
@@ -1410,19 +1414,19 @@ msgstr ""
"fonction \"weechat_hdata_get\".\n"
"\n"
"Exemples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgid ""
"filter messages in buffers, to hide/show them according to tags or regex"
diff --git a/po/hu.po b/po/hu.po
index 22a2bd56c..29b802c19 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-07-31 18:41+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1201,11 +1201,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr ""
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1249,19 +1251,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
msgid ""
diff --git a/po/it.po b/po/it.po
index 56808809e..175f083a8 100644
--- a/po/it.po
+++ b/po/it.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-07-31 18:41+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1291,11 +1291,15 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr "analizza l'espressione e invia il risultato al buffer"
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+#, fuzzy
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr "[-n] <espressione> || [-n] <espressione1> <operatore> <espressione2>"
+#, fuzzy
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1339,19 +1343,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
" -n: mostra il risultato senza inviarlo al buffer (modalità debug)\n"
"espressione: espressione da analizzare, le variabili con il formato "
diff --git a/po/ja.po b/po/ja.po
index 70d261966..b0d3fa047 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-08-02 08:50+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/WeeChat>\n"
@@ -1276,11 +1276,15 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr "式を評価して結果をバッファに送信"
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+#, fuzzy
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+#, fuzzy
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1324,19 +1328,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
" -n: 結果をバッファに送信せずに表示 (デバッグモード)\n"
"expression: 評価する式、フォーマット、${variable} 型のフォーマットの変数は置"
diff --git a/po/pl.po b/po/pl.po
index 8ca4bee11..4aa658b11 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-08-02 08:50+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1306,11 +1306,15 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr "przetwarza wyrażenie i wysyła wynik do buforu"
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+#, fuzzy
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr "[-n] <wyrażenie> || [-n] <wyrażenie1> <operator> <wyrażenie2>"
+#, fuzzy
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1354,19 +1358,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
" -n: wyświetla wynik bez wysyłania go do buforu (tryb debugowania)\n"
"wyrażenie: wyrażenie do przetworzenia, zmienne o formacie ${zmienna} są "
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 406c4de25..40970ae09 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-07-31 18:42+0200\n"
"Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1339,11 +1339,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr ""
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1387,19 +1389,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
msgid ""
diff --git a/po/ru.po b/po/ru.po
index 74ed87314..893f2e0f9 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-07-31 18:42+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1222,11 +1222,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr ""
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1270,19 +1272,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
msgid ""
diff --git a/po/tr.po b/po/tr.po
index d66d4b224..f09fbb108 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-07-31 18:42+0200\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1067,11 +1067,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr ""
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1115,19 +1117,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
msgid ""
diff --git a/po/weechat.pot b/po/weechat.pot
index c2a4b3baa..5a2fcfe0c 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: 2013-08-02 23:16+0200\n"
+"POT-Creation-Date: 2013-08-03 15:05+0200\n"
"PO-Revision-Date: 2013-02-14 18:20+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1073,11 +1073,13 @@ msgstr ""
msgid "evaluate expression and send result to buffer"
msgstr ""
-msgid "[-n] <expression> || [-n] <expression1> <operator> <expression2>"
+msgid "[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\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 "
"replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -1121,19 +1123,19 @@ msgid ""
"function \"weechat_hdata_get\".\n"
"\n"
"Examples:\n"
-" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
-" /eval -n ${window} ==> 0x2549aa0\n"
-" /eval -n ${window.buffer} ==> 0x2549320\n"
-" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
-" /eval -n ${window.buffer.number} ==> 1\n"
-" /eval -n ${window.buffer.number} > 2 ==> 0\n"
-" /eval -n ${window.win_width} > 100 ==> 1\n"
-" /eval -n (8 > 12) || (5 > 2) ==> 1\n"
-" /eval -n (8 > 12) && (5 > 2) ==> 0\n"
-" /eval -n abcd =~ ^ABC ==> 1\n"
-" /eval -n abcd =~ (?-i)^ABC ==> 0\n"
-" /eval -n abcd =~ (?-i)^abc ==> 1\n"
-" /eval -n abcd !~ abc ==> 0"
+" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+" /eval -n ${window} ==> 0x2549aa0\n"
+" /eval -n ${window.buffer} ==> 0x2549320\n"
+" /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+" /eval -n ${window.buffer.number} ==> 1\n"
+" /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+" /eval -n -c ${window.win_width} > 100 ==> 1\n"
+" /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+" /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+" /eval -n -c abcd =~ ^ABC ==> 1\n"
+" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+" /eval -n -c abcd !~ abc ==> 0"
msgstr ""
msgid ""
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 6e0b88140..05116261b 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1471,8 +1471,9 @@ COMMAND_CALLBACK(debug)
COMMAND_CALLBACK(eval)
{
- int print_only, i;
- char *result, *ptr_args, **commands;
+ int i, print_only, condition;
+ char *result, *ptr_args, *expr, **commands;
+ struct t_hashtable *options;
/* make C compiler happy */
(void) buffer;
@@ -1480,42 +1481,74 @@ COMMAND_CALLBACK(eval)
(void) argv;
print_only = 0;
+ condition = 0;
if (argc < 2)
return WEECHAT_RC_OK;
ptr_args = argv_eol[1];
- if (string_strcasecmp (argv[1], "-n") == 0)
+ for (i = 1; i < argc; i++)
{
- print_only = 1;
- ptr_args = argv_eol[2];
+ if (string_strcasecmp (argv[i], "-n") == 0)
+ {
+ print_only = 1;
+ ptr_args = argv_eol[i + 1];
+ }
+ else if (string_strcasecmp (argv[i], "-c") == 0)
+ {
+ condition = 1;
+ ptr_args = argv_eol[i + 1];
+ }
+ else
+ {
+ ptr_args = argv_eol[i];
+ break;
+ }
}
if (ptr_args)
{
- result = eval_expression (ptr_args, NULL, NULL);
+ options = NULL;
+ if (condition)
+ {
+ options = hashtable_new (32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL,
+ NULL);
+ if (options)
+ hashtable_set (options, "type", "condition");
+ }
+
if (print_only)
{
- gui_chat_printf_date_tags (NULL, 0, "no_log", ">> %s", ptr_args);
- if (result)
+ expr = string_remove_quotes (ptr_args, "\"");
+ if (expr)
{
- gui_chat_printf_date_tags (NULL, 0, "no_log", "== %s[%s%s%s]",
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT),
- result,
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
- }
- else
- {
- gui_chat_printf_date_tags (NULL, 0, "no_log", "== %s<%s%s%s>",
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
- GUI_COLOR(GUI_COLOR_CHAT),
- _("error"),
- GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
+ result = eval_expression (expr, NULL, NULL, options);
+ gui_chat_printf_date_tags (NULL, 0, "no_log", ">> %s", ptr_args);
+ if (result)
+ {
+ gui_chat_printf_date_tags (NULL, 0, "no_log", "== %s[%s%s%s]",
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_CHAT),
+ result,
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
+ }
+ else
+ {
+ gui_chat_printf_date_tags (NULL, 0, "no_log", "== %s<%s%s%s>",
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_CHAT),
+ _("error"),
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
+ }
+ free (expr);
}
}
else
{
+ result = eval_expression (ptr_args, NULL, NULL, options);
if (result)
{
commands = string_split_command (result, ';');
@@ -1537,6 +1570,8 @@ COMMAND_CALLBACK(eval)
}
if (result)
free (result);
+ if (options)
+ hashtable_free (options);
}
return WEECHAT_RC_OK;
@@ -6314,9 +6349,11 @@ command_init ()
hook_command (NULL, "eval",
N_("evaluate expression and send result to buffer"),
N_("[-n] <expression>"
- " || [-n] <expression1> <operator> <expression2>"),
+ " || [-n] -c <expression1> <operator> <expression2>"),
N_(" -n: display result without sending it to buffer "
"(debug mode)\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 replaced (see below)\n"
" operator: a logical or comparison operator:\n"
@@ -6360,20 +6397,20 @@ command_init ()
"For name of hdata and variables, please look at \"Plugin "
"API reference\", function \"weechat_hdata_get\".\n\n"
"Examples:\n"
- " /eval -n ${weechat.look.scroll_amount} ==> 3\n"
- " /eval -n ${window} ==> 0x2549aa0\n"
- " /eval -n ${window.buffer} ==> 0x2549320\n"
- " /eval -n ${window.buffer.full_name} ==> core.weechat\n"
- " /eval -n ${window.buffer.number} ==> 1\n"
- " /eval -n ${window.buffer.number} > 2 ==> 0\n"
- " /eval -n ${window.win_width} > 100 ==> 1\n"
- " /eval -n (8 > 12) || (5 > 2) ==> 1\n"
- " /eval -n (8 > 12) && (5 > 2) ==> 0\n"
- " /eval -n abcd =~ ^ABC ==> 1\n"
- " /eval -n abcd =~ (?-i)^ABC ==> 0\n"
- " /eval -n abcd =~ (?-i)^abc ==> 1\n"
- " /eval -n abcd !~ abc ==> 0"),
- "-n",
+ " /eval -n ${weechat.look.scroll_amount} ==> 3\n"
+ " /eval -n ${window} ==> 0x2549aa0\n"
+ " /eval -n ${window.buffer} ==> 0x2549320\n"
+ " /eval -n ${window.buffer.full_name} ==> core.weechat\n"
+ " /eval -n ${window.buffer.number} ==> 1\n"
+ " /eval -n -c ${window.buffer.number} > 2 ==> 0\n"
+ " /eval -n -c ${window.win_width} > 100 ==> 1\n"
+ " /eval -n -c (8 > 12) || (5 > 2) ==> 1\n"
+ " /eval -n -c (8 > 12) && (5 > 2) ==> 0\n"
+ " /eval -n -c abcd =~ ^ABC ==> 1\n"
+ " /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
+ " /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
+ " /eval -n -c abcd !~ abc ==> 0"),
+ "-n|-c -n|-c",
&command_eval, NULL);
hook_command (NULL, "filter",
N_("filter messages in buffers, to hide/show them according "
@@ -7089,7 +7126,7 @@ command_exec_list (const char *command_list)
if (!command_list || !command_list[0])
return;
- command_list2 = eval_expression (command_list, NULL, NULL);
+ command_list2 = eval_expression (command_list, NULL, NULL, NULL);
if (command_list2 && command_list2[0])
{
commands = string_split_command (command_list2, ';');
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index 866f44f8c..3db3cc8c2 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -343,11 +343,14 @@ end:
/*
* Replaces variables in a string.
+ *
+ * Note: result must be freed after use.
*/
char *
eval_replace_vars (const char *expr, struct t_hashtable *pointers,
- struct t_hashtable *extra_vars)
+ struct t_hashtable *extra_vars,
+ const char *prefix, const char *suffix)
{
int errors;
void *ptr[2];
@@ -355,7 +358,7 @@ eval_replace_vars (const char *expr, struct t_hashtable *pointers,
ptr[0] = pointers;
ptr[1] = extra_vars;
- return string_replace_with_callback (expr, "${", "}",
+ return string_replace_with_callback (expr, prefix, suffix,
&eval_replace_vars_cb,
ptr,
&errors);
@@ -463,19 +466,21 @@ end:
}
/*
- * Evaluates an expression (this function must not be called directly).
+ * Evaluates a condition (this function must not be called directly).
*
* Argument keep_parentheses is almost always 0, it is 1 only if the expression
* is a regex (to keep flags inside the parentheses).
*
* For return value, see function eval_expression().
- * Note: result must be freed after use.
+ *
+ * Note: result must be freed after use (if not NULL).
*/
char *
-eval_expression_internal (const char *expr, struct t_hashtable *pointers,
- struct t_hashtable *extra_vars,
- int keep_parentheses)
+eval_expression_condition (const char *expr, struct t_hashtable *pointers,
+ struct t_hashtable *extra_vars,
+ int keep_parentheses,
+ const char *prefix, const char *suffix)
{
int logic, comp, length, level, rc;
const char *pos_end;
@@ -535,7 +540,9 @@ eval_expression_internal (const char *expr, struct t_hashtable *pointers,
sub_expr = string_strndup (expr2 + 1, pos - expr2 - 1);
if (!sub_expr)
goto end;
- tmp_value = eval_expression_internal (sub_expr, pointers, extra_vars, 0);
+ tmp_value = eval_expression_condition (sub_expr, pointers,
+ extra_vars,
+ 0, prefix, suffix);
free (sub_expr);
if (!pos[1])
{
@@ -577,7 +584,9 @@ eval_expression_internal (const char *expr, struct t_hashtable *pointers,
sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
if (!sub_expr)
goto end;
- tmp_value = eval_expression_internal (sub_expr, pointers, extra_vars, 0);
+ tmp_value = eval_expression_condition (sub_expr, pointers,
+ extra_vars,
+ 0, prefix, suffix);
free (sub_expr);
rc = eval_is_true (tmp_value);
if (tmp_value)
@@ -597,7 +606,8 @@ eval_expression_internal (const char *expr, struct t_hashtable *pointers,
{
pos++;
}
- tmp_value = eval_expression_internal (pos, pointers, extra_vars, 0);
+ tmp_value = eval_expression_condition (pos, pointers, extra_vars,
+ 0, prefix, suffix);
rc = eval_is_true (tmp_value);
if (tmp_value)
free (tmp_value);
@@ -626,16 +636,19 @@ eval_expression_internal (const char *expr, struct t_hashtable *pointers,
sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
if (!sub_expr)
goto end;
- tmp_value = eval_expression_internal (sub_expr, pointers, extra_vars, 0);
+ tmp_value = eval_expression_condition (sub_expr, pointers,
+ extra_vars,
+ 0, prefix, suffix);
free (sub_expr);
pos += strlen (comparisons[comp]);
while (pos[0] == ' ')
{
pos++;
}
- tmp_value2 = eval_expression_internal (pos, pointers, extra_vars,
- ((comp == EVAL_COMPARE_REGEX_MATCHING)
- || (comp == EVAL_COMPARE_REGEX_NOT_MATCHING)) ? 1 : 0);
+ tmp_value2 = eval_expression_condition (pos, pointers, extra_vars,
+ ((comp == EVAL_COMPARE_REGEX_MATCHING)
+ || (comp == EVAL_COMPARE_REGEX_NOT_MATCHING)) ? 1 : 0,
+ prefix, suffix);
value = eval_compare (tmp_value, comp, tmp_value2);
if (tmp_value)
free (tmp_value);
@@ -649,7 +662,7 @@ eval_expression_internal (const char *expr, struct t_hashtable *pointers,
* at this point, there is no more logical operator neither comparison,
* so we just replace variables in string and return the result
*/
- value = eval_replace_vars (expr2, pointers, extra_vars);
+ value = eval_replace_vars (expr2, pointers, extra_vars, prefix, suffix);
end:
if (expr2)
@@ -663,37 +676,50 @@ end:
*
* The hashtable "pointers" must have string for keys, pointer for values.
* The hashtable "extra_vars" must have string for keys and values.
+ * The hashtable "options" must have string for keys and values.
*
- * The expression can contain:
+ * Supported options:
+ * - prefix: change the default prefix before variables to replace ("${")
+ * - suffix: change the default suffix after variables to replace ('}")
+ * - type:
+ * - condition: evaluate as a condition (use operators/parentheses,
+ * return a boolean)
+ *
+ * If the expression is a condition, it can contain:
* - conditions: == != < <= > >=
* - logical operators: && ||
* - parentheses for priority
*
- * Examples (the [ ] are NOT part of result):
+ * Examples of simple expression without condition (the [ ] are NOT part of
+ * result):
* >> ${window.buffer.number}
* == [2]
* >> buffer:${window.buffer.full_name}
* == [buffer:irc.freenode.#weechat]
- * >> ${window.buffer.full_name} == irc.freenode.#weechat
- * == [1]
- * >> ${window.buffer.full_name} == irc.freenode.#test
- * == [0]
* >> ${window.win_width}
* == [112]
* >> ${window.win_height}
* == [40]
+ *
+ * Examples of conditions:
+ * >> ${window.buffer.full_name} == irc.freenode.#weechat
+ * == [1]
+ * >> ${window.buffer.full_name} == irc.freenode.#test
+ * == [0]
* >> ${window.win_width} >= 30 && ${window.win_height} >= 20
* == [1]
*
- * Note: result must be freed after use.
+ * Note: result must be freed after use (if not NULL).
*/
char *
eval_expression (const char *expr, struct t_hashtable *pointers,
- struct t_hashtable *extra_vars)
+ struct t_hashtable *extra_vars, struct t_hashtable *options)
{
- int pointers_created, extra_vars_created;
+ int condition, pointers_created, extra_vars_created, rc;
char *value;
+ const char *prefix, *suffix, *default_prefix = "${", *default_suffix = "}";
+ const char *ptr_value;
struct t_gui_window *window;
if (!expr)
@@ -702,6 +728,10 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
pointers_created = 0;
extra_vars_created = 0;
+ condition = 0;
+ prefix = default_prefix;
+ suffix = default_suffix;
+
/* create hashtable pointers if it's NULL */
if (!pointers)
{
@@ -744,7 +774,41 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
extra_vars_created = 1;
}
- value = eval_expression_internal (expr, pointers, extra_vars, 0);
+ /* read options */
+ if (options)
+ {
+ /* check the type of evaluation */
+ ptr_value = hashtable_get (options, "type");
+ if (ptr_value && (strcmp (ptr_value, "condition") == 0))
+ condition = 1;
+
+ /* check for custom prefix */
+ ptr_value = hashtable_get (options, "prefix");
+ if (ptr_value && ptr_value[0])
+ prefix = ptr_value;
+
+ /* check for custom suffix */
+ ptr_value = hashtable_get (options, "suffix");
+ if (ptr_value && ptr_value[0])
+ suffix = ptr_value;
+ }
+
+ /* evaluate expression */
+ if (condition)
+ {
+ /* evaluate as condition (return a boolean: "0" or "1") */
+ value = eval_expression_condition (expr, pointers, extra_vars,
+ 0, prefix, suffix);
+ rc = eval_is_true (value);
+ if (value)
+ free (value);
+ value = strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE);
+ }
+ else
+ {
+ /* only replace variables in expression */
+ value = eval_replace_vars (expr, pointers, extra_vars, prefix, suffix);
+ }
if (pointers_created)
hashtable_free (pointers);
diff --git a/src/core/wee-eval.h b/src/core/wee-eval.h
index d768ff2cb..a570b57e6 100644
--- a/src/core/wee-eval.h
+++ b/src/core/wee-eval.h
@@ -50,6 +50,7 @@ enum t_eval_comparison
extern int eval_is_true (const char *value);
extern char *eval_expression (const char *expr,
struct t_hashtable *pointers,
- struct t_hashtable *extra_vars);
+ struct t_hashtable *extra_vars,
+ struct t_hashtable *options);
#endif /* __WEECHAT_EVAL_H */
diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c
index 2e8fc1dfd..6391676e4 100644
--- a/src/core/wee-hdata.c
+++ b/src/core/wee-hdata.c
@@ -40,6 +40,7 @@ struct t_hashtable *weechat_hdata = NULL;
/* hashtables used in hdata_search() for evaluating expression */
struct t_hashtable *hdata_search_pointers = NULL;
struct t_hashtable *hdata_search_extra_vars = NULL;
+struct t_hashtable *hdata_search_options = NULL;
char *hdata_type_string[8] =
{ "other", "char", "integer", "long", "string", "pointer", "time",
@@ -508,6 +509,17 @@ hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move
NULL);
}
+ if (!hdata_search_options)
+ {
+ hdata_search_options = hashtable_new (32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+ if (hdata_search_options)
+ hashtable_set (hdata_search_options, "type", "condition");
+ }
+
while (pointer)
{
/* set pointer in hashtable (used for evaluating expression) */
@@ -515,7 +527,8 @@ hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move
/* evaluate expression */
result = eval_expression (search, hdata_search_pointers,
- hdata_search_extra_vars);
+ hdata_search_extra_vars,
+ hdata_search_options);
rc = eval_is_true (result);
if (result)
free (result);
@@ -1138,4 +1151,9 @@ hdata_end ()
hashtable_free (hdata_search_extra_vars);
hdata_search_extra_vars = NULL;
}
+ if (hdata_search_options)
+ {
+ hashtable_free (hdata_search_options);
+ hdata_search_options = NULL;
+ }
}
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 34ad3b1bb..0c95dadca 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -1656,7 +1656,7 @@ string_iconv (int from_utf8, const char *from_code, const char *to_code,
/*
* Converts a string to WeeChat internal storage charset (UTF-8).
*
- * Note: result has to be freed after use.
+ * Note: result must be freed after use.
*/
char *
@@ -1696,7 +1696,7 @@ string_iconv_to_internal (const char *charset, const char *string)
/*
* Converts internal string to terminal charset, for display.
*
- * Note: result has to be freed after use.
+ * Note: result must be freed after use.
*/
char *
@@ -1762,7 +1762,7 @@ string_iconv_fprintf (FILE *file, const char *data, ...)
/*
* Formats a string with size and unit name (bytes, KB, MB, GB).
*
- * Note: result has to be freed after use.
+ * Note: result must be freed after use.
*/
char *
@@ -2099,6 +2099,8 @@ string_input_for_buffer (const char *string)
* must be newly allocated because it will be freed in this function).
*
* Argument "errors" is set with number of keys not found by callback.
+ *
+ * Note: result must be freed after use.
*/
char *
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index e30c03b5b..4a3c3d3b8 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -381,7 +381,7 @@ gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
int rc;
char str_modifier[256], str_window[128], *str_displayed, *result;
const char *conditions;
- struct t_hashtable *pointers, *extra_vars;
+ struct t_hashtable *pointers, *extra_vars, *options;
/* check bar condition(s) */
conditions = CONFIG_STRING(bar->options[GUI_BAR_OPTION_CONDITIONS]);
@@ -426,7 +426,16 @@ gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
hashtable_set (extra_vars, "nicklist",
(window->buffer && window->buffer->nicklist) ? "1" : "0");
}
- result = eval_expression (conditions, pointers, extra_vars);
+ options = hashtable_new (32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL,
+ NULL);
+ if (options)
+ hashtable_set (options, "type", "condition");
+
+ result = eval_expression (conditions, pointers, extra_vars, options);
+
rc = eval_is_true (result);
if (result)
free (result);
@@ -434,6 +443,8 @@ gui_bar_check_conditions_for_window (struct t_gui_bar *bar,
hashtable_free (pointers);
if (extra_vars)
hashtable_free (extra_vars);
+ if (options)
+ hashtable_free (options);
if (!rc)
return 0;
}
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index 5142eb862..31c9fef25 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -439,15 +439,15 @@ weechat_guile_api_string_input_for_buffer (SCM string)
SCM
weechat_guile_api_string_eval_expression (SCM expr, SCM pointers,
- SCM extra_vars)
+ SCM extra_vars, SCM options)
{
char *result;
SCM return_value;
- struct t_hashtable *c_pointers, *c_extra_vars;
+ struct t_hashtable *c_pointers, *c_extra_vars, *c_options;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
if (!scm_is_string (expr) || !scm_list_p (pointers)
- || !scm_list_p (extra_vars))
+ || !scm_list_p (extra_vars) || !scm_list_p (options))
API_WRONG_ARGS(API_RETURN_EMPTY);
c_pointers = weechat_guile_alist_to_hashtable (pointers,
@@ -458,14 +458,21 @@ weechat_guile_api_string_eval_expression (SCM expr, SCM pointers,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
+ c_options = weechat_guile_alist_to_hashtable (options,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
result = weechat_string_eval_expression (API_SCM_TO_STRING(expr),
- c_pointers, c_extra_vars);
+ c_pointers, c_extra_vars,
+ c_options);
if (c_pointers)
weechat_hashtable_free (c_pointers);
if (c_extra_vars)
weechat_hashtable_free (c_extra_vars);
+ if (c_options)
+ weechat_hashtable_free (c_options);
API_RETURN_STRING_FREE(result);
}
@@ -4608,7 +4615,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_DEF_FUNC(string_input_for_buffer, 1);
- API_DEF_FUNC(string_eval_expression, 3);
+ API_DEF_FUNC(string_eval_expression, 4);
API_DEF_FUNC(mkdir_home, 2);
API_DEF_FUNC(mkdir, 2);
API_DEF_FUNC(mkdir_parents, 2);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 26337f4c6..49072db41 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -159,10 +159,10 @@ IRC_PROTOCOL_CALLBACK(authenticate)
IRC_SERVER_OPTION_SASL_MECHANISM);
sasl_username = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_SASL_USERNAME),
- NULL, NULL);
+ NULL, NULL, NULL);
sasl_password = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_SASL_PASSWORD),
- NULL, NULL);
+ NULL, NULL, NULL);
answer = NULL;
switch (sasl_mechanism)
{
@@ -2122,7 +2122,7 @@ IRC_PROTOCOL_CALLBACK(001)
/* execute command when connected */
server_command = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_COMMAND),
- NULL, NULL);
+ NULL, NULL, NULL);
if (server_command && server_command[0])
{
/* split command on ';' which can be escaped with '\;' */
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 20c9c887e..28266c0aa 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -324,10 +324,10 @@ irc_server_sasl_enabled (struct t_irc_server *server)
IRC_SERVER_OPTION_SASL_MECHANISM);
sasl_username = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_SASL_USERNAME),
- NULL, NULL);
+ NULL, NULL, NULL);
sasl_password = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_SASL_PASSWORD),
- NULL, NULL);
+ NULL, NULL, NULL);
/*
* SASL is enabled if using mechanism "external"
@@ -3055,7 +3055,7 @@ irc_server_login (struct t_irc_server *server)
password = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_PASSWORD),
- NULL, NULL);
+ NULL, NULL, NULL);
username = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_USERNAME);
realname = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_REALNAME);
capabilities = IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_CAPABILITIES);
@@ -4154,7 +4154,7 @@ irc_server_autojoin_channels (struct t_irc_server *server)
/* auto-join when connecting to server for first time */
autojoin = weechat_string_eval_expression (IRC_SERVER_OPTION_STRING(server,
IRC_SERVER_OPTION_AUTOJOIN),
- NULL, NULL);
+ NULL, NULL, NULL);
if (!server->disable_autojoin && autojoin && autojoin[0])
irc_command_join_server (server, autojoin, 0, 0);
if (autojoin)
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index e60f2d3b3..ae13899ae 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -420,29 +420,36 @@ static int
weechat_lua_api_string_eval_expression (lua_State *L)
{
const char *expr;
- struct t_hashtable *pointers, *extra_vars;
+ struct t_hashtable *pointers, *extra_vars, *options;
char *result;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
- if (lua_gettop (L) < 3)
+ if (lua_gettop (L) < 4)
API_WRONG_ARGS(API_RETURN_EMPTY);
- expr = lua_tostring (L, -3);
- pointers = weechat_lua_tohashtable (L, -2,
+ expr = lua_tostring (L, -4);
+ pointers = weechat_lua_tohashtable (L, -3,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER);
- extra_vars = weechat_lua_tohashtable (L, -1,
+ extra_vars = weechat_lua_tohashtable (L, -2,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
+ options = weechat_lua_tohashtable (L, -1,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
- result = weechat_string_eval_expression (expr, pointers, extra_vars);
+ result = weechat_string_eval_expression (expr, pointers, extra_vars,
+ options);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
+ if (options)
+ weechat_hashtable_free (options);
API_RETURN_STRING_FREE(result);
}
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 19cb70ec8..3aad85b55 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -400,11 +400,11 @@ XS (XS_weechat_api_string_input_for_buffer)
XS (XS_weechat_api_string_eval_expression)
{
char *expr, *result;
- struct t_hashtable *pointers, *extra_vars;
+ struct t_hashtable *pointers, *extra_vars, *options;
dXSARGS;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
- if (items < 3)
+ if (items < 4)
API_WRONG_ARGS(API_RETURN_EMPTY);
expr = SvPV_nolen (ST (0));
@@ -416,13 +416,20 @@ XS (XS_weechat_api_string_eval_expression)
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
+ options = weechat_perl_hash_to_hashtable (ST (3),
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
- result = weechat_string_eval_expression (expr, pointers, extra_vars);
+ result = weechat_string_eval_expression (expr, pointers, extra_vars,
+ options);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
+ if (options)
+ weechat_hashtable_free (options);
API_RETURN_STRING_FREE(result);
}
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 6e2d39722..1ab3ad421 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -397,14 +397,15 @@ static PyObject *
weechat_python_api_string_eval_expression (PyObject *self, PyObject *args)
{
char *expr, *result;
- struct t_hashtable *pointers, *extra_vars;
- PyObject *dict, *dict2, *return_value;
+ struct t_hashtable *pointers, *extra_vars, *options;
+ PyObject *dict, *dict2, *dict3, *return_value;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
expr = NULL;
pointers = NULL;
extra_vars = NULL;
- if (!PyArg_ParseTuple (args, "sOO", &expr, &dict, &dict2))
+ options = NULL;
+ if (!PyArg_ParseTuple (args, "sOOO", &expr, &dict, &dict2, &dict3))
API_WRONG_ARGS(API_RETURN_EMPTY);
pointers = weechat_python_dict_to_hashtable (dict,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
@@ -414,13 +415,20 @@ weechat_python_api_string_eval_expression (PyObject *self, PyObject *args)
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
+ options = weechat_python_dict_to_hashtable (dict3,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
- result = weechat_string_eval_expression (expr, pointers, extra_vars);
+ result = weechat_string_eval_expression (expr, pointers, extra_vars,
+ options);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
+ if (options)
+ weechat_hashtable_free (options);
API_RETURN_STRING_FREE(result);
}
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index 6246ee76f..c7a52bc68 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -463,19 +463,22 @@ weechat_ruby_api_string_input_for_buffer (VALUE class, VALUE string)
static VALUE
weechat_ruby_api_string_eval_expression (VALUE class, VALUE expr,
- VALUE pointers, VALUE extra_vars)
+ VALUE pointers, VALUE extra_vars,
+ VALUE options)
{
char *c_expr, *result;
- struct t_hashtable *c_pointers, *c_extra_vars;
+ struct t_hashtable *c_pointers, *c_extra_vars, *c_options;
VALUE return_value;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
- if (NIL_P (expr) || NIL_P (pointers) || NIL_P (extra_vars))
+ if (NIL_P (expr) || NIL_P (pointers) || NIL_P (extra_vars)
+ || NIL_P (options))
API_WRONG_ARGS(API_RETURN_EMPTY);
Check_Type (expr, T_STRING);
Check_Type (pointers, T_HASH);
Check_Type (extra_vars, T_HASH);
+ Check_Type (options, T_HASH);
c_expr = StringValuePtr (expr);
c_pointers = weechat_ruby_hash_to_hashtable (pointers,
@@ -486,13 +489,20 @@ weechat_ruby_api_string_eval_expression (VALUE class, VALUE expr,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
+ c_options = weechat_ruby_hash_to_hashtable (options,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
- result = weechat_string_eval_expression (c_expr, c_pointers, c_extra_vars);
+ result = weechat_string_eval_expression (c_expr, c_pointers, c_extra_vars,
+ c_options);
if (c_pointers)
weechat_hashtable_free (c_pointers);
if (c_extra_vars)
weechat_hashtable_free (c_extra_vars);
+ if (c_options)
+ weechat_hashtable_free (c_options);
API_RETURN_STRING_FREE(result);
}
@@ -5945,7 +5955,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(string_remove_color, 2);
API_DEF_FUNC(string_is_command_char, 1);
API_DEF_FUNC(string_input_for_buffer, 1);
- API_DEF_FUNC(string_eval_expression, 3);
+ API_DEF_FUNC(string_eval_expression, 4);
API_DEF_FUNC(mkdir_home, 2);
API_DEF_FUNC(mkdir, 2);
API_DEF_FUNC(mkdir_parents, 2);
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index d74c2f81a..4007ce26c 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -735,7 +735,7 @@ script_repo_script_is_held (struct t_script_repo *script)
/*
* Computes MD5 checksum for the content of a file.
*
- * Note: result has to be freed after use.
+ * Note: result must be freed after use.
*/
char *
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index 24a8ce4a3..2d5511487 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -571,11 +571,11 @@ weechat_tcl_api_string_eval_expression (ClientData clientData,
{
Tcl_Obj *objp;
char *expr, *result;
- struct t_hashtable *pointers, *extra_vars;
+ struct t_hashtable *pointers, *extra_vars, *options;
int i;
API_FUNC(1, "string_eval_expression", API_RETURN_EMPTY);
- if (objc < 4)
+ if (objc < 5)
API_WRONG_ARGS(API_RETURN_EMPTY);
expr = Tcl_GetStringFromObj (objv[1], &i);
@@ -587,13 +587,20 @@ weechat_tcl_api_string_eval_expression (ClientData clientData,
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING);
+ options = weechat_tcl_dict_to_hashtable (interp, objv[4],
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
- result = weechat_string_eval_expression (expr, pointers, extra_vars);
+ result = weechat_string_eval_expression (expr, pointers, extra_vars,
+ options);
if (pointers)
weechat_hashtable_free (pointers);
if (extra_vars)
weechat_hashtable_free (extra_vars);
+ if (options)
+ weechat_hashtable_free (options);
API_RETURN_STRING_FREE(result);
}
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 82873d171..d0d672616 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -52,7 +52,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20130727-01"
+#define WEECHAT_PLUGIN_API_VERSION "20130804-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -256,7 +256,8 @@ struct t_weechat_plugin
const char *(*string_input_for_buffer) (const char *string);
char *(*string_eval_expression )(const char *expr,
struct t_hashtable *pointers,
- struct t_hashtable *extra_vars);
+ struct t_hashtable *extra_vars,
+ struct t_hashtable *options);
/* UTF-8 strings */
int (*utf8_has_8bits) (const char *string);
@@ -1020,9 +1021,9 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
#define weechat_string_input_for_buffer(__string) \
weechat_plugin->string_input_for_buffer(__string)
#define weechat_string_eval_expression(__expr, __pointers, \
- __extra_vars) \
+ __extra_vars, __options) \
weechat_plugin->string_eval_expression(__expr, __pointers, \
- __extra_vars) \
+ __extra_vars, __options)
/* UTF-8 strings */
#define weechat_utf8_has_8bits(__string) \