core: add debug option "-d" in command /eval (issue #1434)

v2.8-utf8proc
Sébastien Helleu 2019-12-18 21:18:59 +01:00
parent 7e833ee60b
commit a13099aa63
23 changed files with 334 additions and 183 deletions

View File

@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
New features::
* core: add debug option "-d" in command /eval (issue #1434)
* api: add info "weechat_headless" (issue #1433)
Bug fixes::

View File

@ -263,71 +263,72 @@ infolists: zeigt Information über die Infolists an
* `+eval+`: evaluierter Ausdruck
----
/eval [-n|-s] <expression>
[-n] -c <expression1> <operator> <expression2>
/eval [-n|-s] [-d] <expression>
[-n] [-d] -c <expression1> <operator> <expression2>
-n: gibt das Ergebnis aus, ohne dass dieses in den Buffer gesendet wird (debug Modus)
-s: teilt Ausdrücke, bevor sie evaluiert werden (mehrere Befehle können durch Semikolon getrennt werden)
-c: Auswertung als Bedingung: nutzt Operatoren und runde Klammern, Rückgabewert als Boolean-Wert ("0" oder "1")
expression: Ausdruck welcher verarbeitet werden soll. Variablen im Format ${variable} werden ersetzt (siehe unten); mehrere Befehle werden durch ein Semikolon voneinander getrennt
operator: ein logischer oder vergleichender Operand:
- logische Operanden:
&& boolean "und"
|| boolean "oder"
- vergleichende Operanden:
== gleich
!= ungleich
<= kleiner oder gleich
< kleiner
>= größer oder gleich
> größer
=~ stimmt mit regulärem POSIX Ausdruck überein
!~ stimmt NICHT mit regulärem POSIX Ausdruck überein
=* stimmt mit Maske überein (Platzhalter "*" ist erlaubt)
!* stimmt mit Maske NICHT überein (Platzhalter "*" ist erlaubt)
-n: display result without sending it to buffer (debug mode)
-s: split expression before evaluating it (many commands can be separated by semicolons)
-d: display debug output after evaluation
-c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1")
expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons
operator: a logical or comparison operator:
- logical operators:
&& boolean "and"
|| boolean "or"
- comparison operators:
== equal
!= not equal
<= less or equal
< less
>= greater or equal
> greater
=~ is matching POSIX extended regex
!~ is NOT matching POSIX extended regex
=* is matching mask (wildcard "*" is allowed)
!* is NOT matching mask (wildcard "*" is allowed)
Ein Ausdruck gilt als "wahr" sofern das Ergebnis weder NULL, nicht leer und von "0" abweichend ist.
Für einen Vergleich werden Fließkommazahlen genutzt, insofern es sich bei beiden Ausdrücken um gültige Zahlen handelt, folgende Formate werden unterstützt:
- Integer (Beispiele: 5, -7)
- Fließkommazahl (Beispiele: 5.2, -7.5, 2.83e-2)
- hexadezimale Zahl (Beispiele: 0xA3, -0xA3)
Um einen Vergleich zwischen zwei Zeichenketten zu erzwingen, müssen die Ausdrücke in Anführungszeichen gesetzt werden, zum Beispiel:
An expression is considered as "true" if it is not NULL, not empty, and different from "0".
The comparison is made using floating point numbers if the two expressions are valid numbers, with one of the following formats:
- integer (examples: 5, -7)
- floating point number (examples: 5.2, -7.5, 2.83e-2)
- hexadecimal number (examples: 0xA3, -0xA3)
To force a string comparison, you can add double quotes around each expression, for example:
50 > 100 ==> 0
"50" > "100" ==> 1
Einige Variablen werden im Ausdruck mittels der Formatierung ${variable} ersetzt. Mögliche Variablen sind, nach Reihenfolge ihrer Priorität:
1. eine evaluierte Teilzeichenkette (Format: "eval:xxx")
2. eine Zeichenkette mit Escapesequenzen (Format: "esc:xxx" oder "\xxx")
3. Zeichen, die in einer Zeichenkette nicht dargestellt werden sollen (Format: "hide:Zeichen,Zeichenkette")
4. eine Zeichenkette mit einer maximalen Anzahl an Zeichen (Format: "cut:+Max,Suffix,Zeichenkette")
oder maximale Anzahl an Zeichen die auf dem Bildschirm angezeigt werden sollen (Format: "cutscr:Max,Suffix,Zeichenkette oder "cutscr:+Max,Suffix,Zeichenkette")
5. eine Zeichenkette umkehren (Format: "rev:xxx" oder "revscr:xxx")
6. eine Zeichenkette wiederholen (Format: "repeat:Anzahl,Zeichenkette")
7. Länge einer Zeichenkette (Format: "length:xxx" oder "lengthscr:xxx")
8. eine Farbe (Format: "color:xxx", siehe "Anleitung für API Erweiterung", Funktion "color")
9. ein Modifizierer (Format: "info:Name,Argumente", Argumente sind optional)
10. eine Info (Format: "Info:Name,Argumente", Argumente sind optional)
11. aktuelles Datum/Uhrzeit (Format: "date" oder "date:format")
12. eine Umgebungsvariable (Format: "env:XXX")
13. ein Dreifachoperand (Format: "if:Bedingung?Wert_falls_wahr:Wert_falls_unwahr")
14. Ergebnis eines Ausdrucks mit Klammern und Operatoren + - * / // % ** (Format: "calc:xxx")
15. eine Option (Format: "file.section.option")
16. eine lokale Variable eines Buffers
17. ein(e) hdata - Name/Variable (der Wert wird automatisch in eine Zeichenkette konvertiert), standardmäßig wird für "window" und "buffer" das aktuelle Fenster/Buffer verwendet.
Das Format für hdata kann wie folgt aufgebaut sein:
hdata.var1.var2...: startet mit hdata (der Pointer muss bekannt sein) und fragt eine Variable nach der anderen ab (weitere hdata können folgen)
hdata[list].var1.var2...: startet hdata mittels einer Liste, zum Beispiel:
${buffer[gui_buffers].full_name}: der vollständige Name des ersten Buffers, in der verknüpften Liste aller Buffer
${plugin[weechat_plugins].name}: Name der ersten Erweiterung, in der verknüpften Liste aller Erweiterungen
hdata[pointer].var1.var2...: startet hdata mittels einem Pointer, zum Beispiel:
${buffer[0x1234abcd].full_name}: vollständiger Name eines Buffers und des dazugehörigen Pointers (kann in triggern benutzt werden)
Die vorhandenen Namen für hdata und Variablen sind in der "Anleitung für API Erweiterung", Bereich "weechat_hdata_get". beschrieben
Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority:
1. an evaluated sub-string (format: "eval:xxx")
2. a string with escaped chars (format: "esc:xxx" or "\xxx")
3. a string with chars to hide (format: "hide:char,string")
4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string")
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string")
5. a reversed string (format: "rev:xxx" or "revscr:xxx")
6. a repeated string (format: "repeat:count,string")
7. length of a string (format: "length:xxx" or "lengthscr:xxx")
8. a color (format: "color:xxx", see "Plugin API reference", function "color")
9. a modifier (format: "modifier:name,data,string")
10. an info (format: "info:name,arguments", arguments are optional)
11. current date/time (format: "date" or "date:format")
12. an environment variable (format: "env:XXX")
13. a ternary operator (format: "if:condition?value_if_true:value_if_false")
14. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx")
15. an option (format: "file.section.option")
16. a local variable in buffer
17. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer.
Format for hdata can be one of following:
hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed)
hdata[list].var1.var2...: start with a hdata using a list, for example:
${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins
hdata[pointer].var1.var2...: start with a hdata using a pointer, for example:
${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers)
For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
Beispiele (einfache Zeichenketten):
Examples (simple strings):
/eval -n ${info:version} ==> 0.4.3
/eval -n ${env:HOME} ==> /home/user
/eval -n ${weechat.look.scroll_amount} ==> 3
/eval -n ${sec.data.freenode_password} ==> geheim
/eval -n ${sec.data.freenode_password} ==> secret
/eval -n ${window} ==> 0x2549aa0
/eval -n ${window.buffer} ==> 0x2549320
/eval -n ${window.buffer.full_name} ==> core.weechat
@ -343,16 +344,16 @@ Beispiele (einfache Zeichenketten):
/eval -n ${length:test} ==> 4
/eval -n ${calc:(5+2)*3} ==> 21
Beispiele (Bedingungen):
/eval -n -c ${window.buffer.number} > 2 ==> 0
/eval -n -c ${window.win_width} > 100 ==> 1
/eval -n -c (8 > 12) || (5 > 2) ==> 1
/eval -n -c (8 > 12) && (5 > 2) ==> 0
/eval -n -c abcd =~ ^ABC ==> 1
/eval -n -c abcd =~ (?-i)^ABC ==> 0
/eval -n -c abcd =~ (?-i)^abc ==> 1
/eval -n -c abcd !~ abc ==> 0
/eval -n -c abcd =* a*d ==> 1
Examples (conditions):
/eval -n -c ${window.buffer.number} > 2 ==> 0
/eval -n -c ${window.win_width} > 100 ==> 1
/eval -n -c (8 > 12) || (5 > 2) ==> 1
/eval -n -c (8 > 12) && (5 > 2) ==> 0
/eval -n -c abcd =~ ^ABC ==> 1
/eval -n -c abcd =~ (?-i)^ABC ==> 0
/eval -n -c abcd =~ (?-i)^abc ==> 1
/eval -n -c abcd !~ abc ==> 0
/eval -n -c abcd =* a*d ==> 1
----
[[command_weechat_filter]]

View File

@ -263,11 +263,12 @@ infolists: display infos about infolists
* `+eval+`: evaluate expression
----
/eval [-n|-s] <expression>
[-n] -c <expression1> <operator> <expression2>
/eval [-n|-s] [-d] <expression>
[-n] [-d] -c <expression1> <operator> <expression2>
-n: display result without sending it to buffer (debug mode)
-s: split expression before evaluating it (many commands can be separated by semicolons)
-d: display debug output after evaluation
-c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1")
expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons
operator: a logical or comparison operator:

View File

@ -263,11 +263,12 @@ infolists : afficher des infos sur les infolists
* `+eval+`: évaluer une expression
----
/eval [-n|-s] <expression>
[-n] -c <expression1> <opérateur> <expression2>
/eval [-n|-s] [-d] <expression>
[-n] [-d] -c <expression1> <opérateur> <expression2>
-n : afficher le résultat sans envoyer au tampon (mode debug)
-s : découper l'expression avant de l'évaluer (plusieurs commandes peuvent être séparées par des points-virgules)
-d : afficher la sortie de debug après l'évaluation
-c : évaluer comme une condition : utiliser les opérateurs et les parenthèses, retourner une valeur booléenne ("0" ou "1")
expression : expression à évaluer, les variables avec le format ${variable} sont remplacées (voir ci-dessous) ; plusieurs commandes peuvent être séparées par des points-virgules
opérateur : un opérateur logique ou de comparaison :

View File

@ -263,11 +263,12 @@ infolists: display infos about infolists
* `+eval+`: evaluate expression
----
/eval [-n|-s] <expression>
[-n] -c <expression1> <operator> <expression2>
/eval [-n|-s] [-d] <expression>
[-n] [-d] -c <expression1> <operator> <expression2>
-n: display result without sending it to buffer (debug mode)
-s: split expression before evaluating it (many commands can be separated by semicolons)
-d: display debug output after evaluation
-c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1")
expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons
operator: a logical or comparison operator:

View File

@ -263,11 +263,12 @@ infolists: インフォリストに関する情報を表示
* `+eval+`: 式を評価
----
/eval [-n|-s] <expression>
[-n] -c <expression1> <operator> <expression2>
/eval [-n|-s] [-d] <expression>
[-n] [-d] -c <expression1> <operator> <expression2>
-n: display result without sending it to buffer (debug mode)
-s: split expression before evaluating it (many commands can be separated by semicolons)
-d: display debug output after evaluation
-c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1")
expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons
operator: a logical or comparison operator:

View File

@ -263,71 +263,72 @@ infolists: wyświetla informacje o infolistach
* `+eval+`: przetwórz wyrażenie
----
/eval [-n|-s] <wyrażenie>
[-n] -c <wyrażenie1> <operator> <wyrażenie2>
/eval [-n|-s] [-d] <expression>
[-n] [-d] -c <expression1> <operator> <expression2>
-n: wyświetla wynik bez wysyłania go do buforu (tryb debugowania)
-s: podziel wyrażenie przed przetworzeniem go (wiele komend może być oddzielonych średnikami)
-c: przetwarza jako warunek: użyj operatorów i nawiasów, zwraca wartość logiczną ("0" lub "1")
wyrażenie: wyrażenie do przetworzenia, zmienne o formacie ${zmienna} są zastępowane (zobacz niżej); wiele komend można oddzielić średnikami
operator: operator logiczny lub porównania:
- operatory logiczne:
&& logiczne "i"
|| logiczne "lub"
- operatory porównania:
== równy
!= różny
<= mniejszy lub równy
< mniejszy
>= większy lub równy
> większy
=~ pasuje do rozszerzonego wyrażenia regularnego POSIX
!~ NIE pasuje do rozszerzonego wyrażenia regularnego POSIX
=* pasuje do maski (dzika karta "*" dozwolona)
!* NIE pasuje do maski (dzika karta "*" dozwolona)
-n: display result without sending it to buffer (debug mode)
-s: split expression before evaluating it (many commands can be separated by semicolons)
-d: display debug output after evaluation
-c: evaluate as condition: use operators and parentheses, return a boolean value ("0" or "1")
expression: expression to evaluate, variables with format ${variable} are replaced (see below); many commands can be separated by semicolons
operator: a logical or comparison operator:
- logical operators:
&& boolean "and"
|| boolean "or"
- comparison operators:
== equal
!= not equal
<= less or equal
< less
>= greater or equal
> greater
=~ is matching POSIX extended regex
!~ is NOT matching POSIX extended regex
=* is matching mask (wildcard "*" is allowed)
!* is NOT matching mask (wildcard "*" is allowed)
Wyrażenie jest uznawane za „prawdziwe” jeśli nie jest NULL, nie jest puste, oraz różni się od "0".
Porównania dokonuje się z użyciem liczb całkowitych jeśli oba wyrażenia są liczbami całkowitymi, w jednym z następujących formatów:
- liczby całkowite (przykłady: 5, -7)
- liczby zmiennoprzecinkowe (przykłady: 5.2, -7.5, 2.83e-2)
- liczby szesnastkowe (przykłady: 0xA3, -0xA3)
W celu wymuszenia porównywania ciągów, należy umieścić każde wyrażenie w cudzysłowie, na przykład:
An expression is considered as "true" if it is not NULL, not empty, and different from "0".
The comparison is made using floating point numbers if the two expressions are valid numbers, with one of the following formats:
- integer (examples: 5, -7)
- floating point number (examples: 5.2, -7.5, 2.83e-2)
- hexadecimal number (examples: 0xA3, -0xA3)
To force a string comparison, you can add double quotes around each expression, for example:
50 > 100 ==> 0
"50" > "100" ==> 1
Niektóre zmienne w wyrażeniach są zamieniane, poprzez zastosowanie formatu ${zmienna}, według priorytetu zmienną może być:
1. przetworzony ciąg (format: "eval:xxx")
2. ciąg z wyescapowanymi znakami (format: "esc:xxx" lub "\xxx")
3. ciąg ze znakami do ukrycia (format: "hide:char,string")
4. ciąg o maksymalnej długości (format: "cut:max,suffix,string" lub "cut:+max,suffix,string")
lub maksymalna ilość znaków wyświetlanych na ekranie (format: "cutscr:max,suffix,string" lub "cutscr:+max,suffix,string")
5. odwrócony ciąg (format: "rev:xxx")
6. powtórzony ciąg (format: "repeat:ilość,ciąg")
7. długość ciągu (format: "length:xxx" or "lengthscr:xxx")
8. kolor (format "color:xxx", zobacz „Opis API wtyczek”, funkcja "color")
9. modyfikator (format: "modifier:name,data,string")
10. informacja (format: "info:nazwa,argumenty", argumenty są opcjonalne)
11. obecna data/czas (format: "date" lub "date:format")
12. zmienna środowiskowa (format: "env:XXX")
13. wyrażenie warunkowe (format: "if:condition?value_if_true:value_if_false")
14. wynik wyrażenia z nawiasami i operatorami + - * / // % ** (format: "calc:xxx")
15. opcja (format: plik.sekcja.opcja)
16 zmienna lokalna w buforze
17. nazwa hdatay/zmiennej (wartość jest automatycznie konwertowana na ciąg znaków), domyślnie "window" i "buffer" wskazują na aktualne okno/bufor.
Format dla hdata może być jednym z poniższych:
hdata.zmienna1.zmienna2...: inicjuje hdata (wskaźnik musi być znany), następnie wypytuje zmienne jedna po drugiej (inne hdata mogą być następne)
hdata[list].zmienna1.zmienna2...: inicjuje hdata z wykorzystaniem listy, na przykład:
${buffer[gui_buffers].full_name}: pełna nazwa buforu w połączonej liście buforów
${plugin[weechat_plugins].name}: nazwa pierwszej wtyczki w połączonej liście wtyczek
hdata[wskaźnik].zmienna1.zmienna2...: zacznij z hdata używając wskaźnika, na przykład:
${buffer[0x1234abcd].full_name}: pełna nazwa buforu z tym wskaźnikiem (może zostać użyte w triggerach)
Nazwy hdata i zmiennych, można znaleźć w „Opisie API wtyczek”, funkcja "weechat_hdata_get".
Some variables are replaced in expression, using the format ${variable}, variable can be, by order of priority:
1. an evaluated sub-string (format: "eval:xxx")
2. a string with escaped chars (format: "esc:xxx" or "\xxx")
3. a string with chars to hide (format: "hide:char,string")
4. a string with max chars (format: "cut:max,suffix,string" or "cut:+max,suffix,string")
or max chars displayed on screen (format: "cutscr:max,suffix,string" or "cutscr:+max,suffix,string")
5. a reversed string (format: "rev:xxx" or "revscr:xxx")
6. a repeated string (format: "repeat:count,string")
7. length of a string (format: "length:xxx" or "lengthscr:xxx")
8. a color (format: "color:xxx", see "Plugin API reference", function "color")
9. a modifier (format: "modifier:name,data,string")
10. an info (format: "info:name,arguments", arguments are optional)
11. current date/time (format: "date" or "date:format")
12. an environment variable (format: "env:XXX")
13. a ternary operator (format: "if:condition?value_if_true:value_if_false")
14. result of an expression with parentheses and operators + - * / // % ** (format: "calc:xxx")
15. an option (format: "file.section.option")
16. a local variable in buffer
17. a hdata name/variable (the value is automatically converted to string), by default "window" and "buffer" point to current window/buffer.
Format for hdata can be one of following:
hdata.var1.var2...: start with a hdata (pointer must be known), and ask variables one after one (other hdata can be followed)
hdata[list].var1.var2...: start with a hdata using a list, for example:
${buffer[gui_buffers].full_name}: full name of first buffer in linked list of buffers
${plugin[weechat_plugins].name}: name of first plugin in linked list of plugins
hdata[pointer].var1.var2...: start with a hdata using a pointer, for example:
${buffer[0x1234abcd].full_name}: full name of the buffer with this pointer (can be used in triggers)
For name of hdata and variables, please look at "Plugin API reference", function "weechat_hdata_get".
Przykłady (proste ciągi):
Examples (simple strings):
/eval -n ${info:version} ==> 0.4.3
/eval -n ${env:HOME} ==> /home/user
/eval -n ${weechat.look.scroll_amount} ==> 3
/eval -n ${sec.data.freenode_password} ==> secret
/eval -n ${sec.data.freenode_password} ==> secret
/eval -n ${window} ==> 0x2549aa0
/eval -n ${window.buffer} ==> 0x2549320
/eval -n ${window.buffer.full_name} ==> core.weechat
@ -343,7 +344,7 @@ Przykłady (proste ciągi):
/eval -n ${length:test} ==> 4
/eval -n ${calc:(5+2)*3} ==> 21
Przykłady (warunki):
Examples (conditions):
/eval -n -c ${window.buffer.number} > 2 ==> 0
/eval -n -c ${window.win_width} > 100 ==> 1
/eval -n -c (8 > 12) || (5 > 2) ==> 1

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1522,13 +1522,17 @@ msgstr ""
msgid "evaluate expression"
msgstr "vyhodnotit výraz"
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <výraz> || [-n] -c <výraz1> <operátor> <výraz2>"
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -24,7 +24,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-12-15 21:16+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
@ -1658,13 +1658,18 @@ msgstr ""
msgid "evaluate expression"
msgstr "evaluierter Ausdruck"
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1553,13 +1553,16 @@ msgstr ""
msgid "evaluate expression"
msgstr ""
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"PO-Revision-Date: 2019-12-13 21:33+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-12-18 21:18+0100\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@ -1629,14 +1629,18 @@ msgstr ""
msgid "evaluate expression"
msgstr "évaluer une expression"
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr ""
"[-n|-s] <expression> || [-n] -c <expression1> <opérateur> <expression2>"
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <opérateur> "
"<expression2>"
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "
@ -1745,6 +1749,7 @@ msgstr ""
" -n : afficher le résultat sans envoyer au tampon (mode debug)\n"
" -s : découper l'expression avant de l'évaluer (plusieurs commandes "
"peuvent être séparées par des points-virgules)\n"
" -d : afficher la sortie de debug après l'évaluation\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} "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1441,13 +1441,16 @@ msgstr ""
msgid "evaluate expression"
msgstr ""
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1534,7 +1534,9 @@ msgid "evaluate expression"
msgstr ""
#, fuzzy
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr ""
"[-n] <espressione> || [-n] -c <espressione1> <operatore> <espressione2>"
@ -1543,6 +1545,7 @@ msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
@ -1589,7 +1589,10 @@ msgstr ""
msgid "evaluate expression"
msgstr "式を評価"
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
@ -1597,6 +1600,7 @@ msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-12-01 16:23+0100\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: Polish <kde-i18n-doc@kde.org>\n"
@ -1624,13 +1624,18 @@ msgstr ""
msgid "evaluate expression"
msgstr "przetwórz wyrażenie"
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <wyrażenie> || [-n] -c <wyrażenie1> <operator> <wyrażenie2>"
#, fuzzy
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n"
@ -1593,7 +1593,10 @@ msgstr ""
msgid "evaluate expression"
msgstr "avaliar uma expressão"
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <expressão> || [-n] -c <expressão1> <operador> <expressão2>"
#, fuzzy
@ -1601,6 +1604,7 @@ msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Eduardo Elias <camponez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1598,13 +1598,17 @@ msgstr ""
msgid "evaluate expression"
msgstr "avaliar expressão"
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1463,13 +1463,16 @@ msgstr ""
msgid "evaluate expression"
msgstr ""
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2019-11-03 08:38+0100\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1294,13 +1294,16 @@ msgstr ""
msgid "evaluate expression"
msgstr ""
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2019-12-13 21:32+0100\n"
"POT-Creation-Date: 2019-12-18 21:17+0100\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -1296,13 +1296,16 @@ msgstr ""
msgid "evaluate expression"
msgstr ""
msgid "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d] -c <expression1> <operator> "
"<expression2>"
msgstr ""
msgid ""
" -n: display result without sending it to buffer (debug mode)\n"
" -s: split expression before evaluating it (many commands can be "
"separated by semicolons)\n"
" -d: display debug output after evaluation\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 "

View File

@ -1936,8 +1936,9 @@ COMMAND_CALLBACK(debug)
COMMAND_CALLBACK(eval)
{
int i, print_only, split_command, condition, error;
int i, print_only, split_command, condition, debug, error;
char *result, *ptr_args, *expr, **commands;
const char **debug_output;
struct t_hashtable *pointers, *options;
/* make C compiler happy */
@ -1948,6 +1949,7 @@ COMMAND_CALLBACK(eval)
print_only = 0;
split_command = 0;
condition = 0;
debug = 0;
error = 0;
COMMAND_MIN_ARGS(2, "");
@ -1970,6 +1972,11 @@ COMMAND_CALLBACK(eval)
condition = 1;
ptr_args = argv_eol[i + 1];
}
else if (string_strcasecmp (argv[i], "-d") == 0)
{
debug = 1;
ptr_args = argv_eol[i + 1];
}
else
{
ptr_args = argv_eol[i];
@ -1992,7 +1999,7 @@ COMMAND_CALLBACK(eval)
}
options = NULL;
if (condition)
if (condition || debug)
{
options = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
@ -2000,7 +2007,12 @@ COMMAND_CALLBACK(eval)
NULL,
NULL);
if (options)
hashtable_set (options, "type", "condition");
{
if (condition)
hashtable_set (options, "type", "condition");
if (debug)
hashtable_set (options, "debug", "1");
}
}
if (print_only)
@ -2028,6 +2040,13 @@ COMMAND_CALLBACK(eval)
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
}
free (expr);
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
gui_chat_printf (NULL, "%s", debug_output);
}
}
}
else
@ -2050,6 +2069,13 @@ COMMAND_CALLBACK(eval)
{
error = 1;
}
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
gui_chat_printf (NULL, "%s", debug_output);
}
}
string_free_split_command (commands);
}
@ -2066,6 +2092,13 @@ COMMAND_CALLBACK(eval)
{
error = 1;
}
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
gui_chat_printf (NULL, "%s", debug_output);
}
}
}
@ -7304,12 +7337,13 @@ command_init ()
hook_command (
NULL, "eval",
N_("evaluate expression"),
N_("[-n|-s] <expression>"
" || [-n] -c <expression1> <operator> <expression2>"),
N_("[-n|-s] [-d] <expression>"
" || [-n] [-d] -c <expression1> <operator> <expression2>"),
N_(" -n: display result without sending it to buffer "
"(debug mode)\n"
" -s: split expression before evaluating it "
"(many commands can be separated by semicolons)\n"
" -d: display debug output after evaluation\n"
" -c: evaluate as condition: use operators and parentheses, "
"return a boolean value (\"0\" or \"1\")\n"
"expression: expression to evaluate, variables with format "

View File

@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <regex.h>
#include <time.h>
@ -45,6 +46,10 @@
#include "../plugins/plugin.h"
#define EVAL_DEBUG(msg, argz...) \
if (eval_context->debug) \
eval_debug_message (eval_context, msg, ##argz);
char *logical_ops[EVAL_NUM_LOGICAL_OPS] =
{ "||", "&&" };
@ -58,6 +63,24 @@ char *eval_expression_condition (const char *expr,
struct t_eval_context *eval_context);
/*
* Adds a debug message in the debug output.
*/
void
eval_debug_message (struct t_eval_context *eval_context, char *message, ...)
{
weechat_va_format (message);
if (!vbuffer)
return;
if (*(eval_context->debug)[0])
string_dyn_concat (eval_context->debug, "\n");
string_dyn_concat (eval_context->debug, vbuffer);
free (vbuffer);
}
/*
* Checks if a value is true: a value is true if string is non-NULL, non-empty
* and different from "0".
@ -140,13 +163,17 @@ eval_strstr_level (const char *string, const char *search,
*/
char *
eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path)
eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
struct t_eval_context *eval_context)
{
char *value, *old_value, *var_name, str_value[128], *pos;
const char *ptr_value, *hdata_name, *ptr_var_name;
int type;
struct t_hashtable *hashtable;
EVAL_DEBUG("eval_hdata_get_value(\"%s\", 0x%lx, \"%s\")",
hdata->name, pointer, path);
value = NULL;
var_name = NULL;
@ -274,7 +301,10 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path)
hdata = hook_hdata_get (NULL, hdata_name);
old_value = value;
value = eval_hdata_get_value (hdata, pointer, (pos) ? pos + 1 : NULL);
value = eval_hdata_get_value (hdata,
pointer,
(pos) ? pos + 1 : NULL,
eval_context);
if (old_value)
free (old_value);
}
@ -339,6 +369,8 @@ eval_replace_vars_cb (void *data, const char *text)
eval_context = (struct t_eval_context *)data;
EVAL_DEBUG("eval_replace_vars_cb(\"%s\")", text);
/* 1. variable in hashtable "extra_vars" */
if (eval_context->extra_vars)
{
@ -785,7 +817,10 @@ eval_replace_vars_cb (void *data, const char *text)
goto end;
}
value = eval_hdata_get_value (hdata, pointer, (pos) ? pos + 1 : NULL);
value = eval_hdata_get_value (hdata,
pointer,
(pos) ? pos + 1 : NULL,
eval_context);
end:
if (hdata_name)
@ -808,6 +843,8 @@ eval_replace_vars (const char *expr, struct t_eval_context *eval_context)
const char *no_replace_prefix_list[] = { "if:", NULL };
char *result;
EVAL_DEBUG("eval_replace_vars(\"%s\")", expr);
eval_context->recursion_count++;
if (eval_context->recursion_count < EVAL_RECURSION_MAX)
@ -845,13 +882,17 @@ eval_replace_vars (const char *expr, struct t_eval_context *eval_context)
*/
char *
eval_compare (const char *expr1, int comparison, const char *expr2)
eval_compare (const char *expr1, int comparison, const char *expr2,
struct t_eval_context *eval_context)
{
int rc, string_compare, length1, length2;
regex_t regex;
double value1, value2;
char *error;
EVAL_DEBUG("eval_compare(\"%s\", \"%s\", \"%s\")",
expr1, comparisons[comparison], expr2);
rc = 0;
string_compare = 0;
@ -958,6 +999,8 @@ eval_expression_condition (const char *expr,
const char *pos, *pos_end;
char *expr2, *sub_expr, *value, *tmp_value, *tmp_value2;
EVAL_DEBUG("eval_expression_condition(\"%s\")", expr);
value = NULL;
if (!expr)
@ -1080,7 +1123,7 @@ eval_expression_condition (const char *expr,
tmp_value2 = eval_expression_condition (pos, eval_context);
}
free (sub_expr);
value = eval_compare (tmp_value, comp, tmp_value2);
value = eval_compare (tmp_value, comp, tmp_value2, eval_context);
if (tmp_value)
free (tmp_value);
if (tmp_value2)
@ -1192,6 +1235,9 @@ eval_replace_regex (const char *string, regex_t *regex, const char *replace,
int empty_replace_allowed;
struct t_eval_regex eval_regex;
EVAL_DEBUG("eval_replace_regex(\"%s\", 0x%lx, \"%s\")",
string, regex, replace);
if (!string || !regex || !replace)
return NULL;
@ -1334,7 +1380,7 @@ char *
eval_expression (const char *expr, struct t_hashtable *pointers,
struct t_hashtable *extra_vars, struct t_hashtable *options)
{
struct t_eval_context eval_context;
struct t_eval_context context, *eval_context;
int condition, rc, pointers_allocated, regex_allocated;
int ptr_window_added, ptr_buffer_added;
char *value;
@ -1372,13 +1418,16 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
pointers_allocated = 1;
}
eval_context.pointers = pointers;
eval_context.extra_vars = extra_vars;
eval_context.extra_vars_eval = 0;
eval_context.prefix = default_prefix;
eval_context.suffix = default_suffix;
eval_context.regex = NULL;
eval_context.recursion_count = 0;
eval_context = &context;
eval_context->pointers = pointers;
eval_context->extra_vars = extra_vars;
eval_context->extra_vars_eval = 0;
eval_context->prefix = default_prefix;
eval_context->suffix = default_suffix;
eval_context->regex = NULL;
eval_context->recursion_count = 0;
eval_context->debug = NULL;
/*
* set window/buffer with pointer to current window/buffer
@ -1413,17 +1462,17 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
/* check if extra vars must be evaluated */
ptr_value = hashtable_get (options, "extra");
if (ptr_value && (strcmp (ptr_value, "eval") == 0))
eval_context.extra_vars_eval = 1;
eval_context->extra_vars_eval = 1;
/* check for custom prefix */
ptr_value = hashtable_get (options, "prefix");
if (ptr_value && ptr_value[0])
eval_context.prefix = ptr_value;
eval_context->prefix = ptr_value;
/* check for custom suffix */
ptr_value = hashtable_get (options, "suffix");
if (ptr_value && ptr_value[0])
eval_context.suffix = ptr_value;
eval_context->suffix = ptr_value;
/* check for regex */
ptr_value = hashtable_get (options, "regex");
@ -1448,13 +1497,19 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
{
regex_replace = ptr_value;
}
/* check for debug */
if (hashtable_has_key (options, "debug"))
eval_context->debug = string_dyn_alloc (256);
}
EVAL_DEBUG("eval_expression(\"%s\")", expr);
/* evaluate expression */
if (condition)
{
/* evaluate as condition (return a boolean: "0" or "1") */
value = eval_expression_condition (expr, &eval_context);
value = eval_expression_condition (expr, eval_context);
rc = eval_is_true (value);
if (value)
free (value);
@ -1466,12 +1521,12 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
{
/* replace with regex */
value = eval_replace_regex (expr, regex, regex_replace,
&eval_context);
eval_context);
}
else
{
/* only replace variables in expression */
value = eval_replace_vars (expr, &eval_context);
value = eval_replace_vars (expr, eval_context);
}
}
@ -1492,5 +1547,10 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
free (regex);
}
if (options && eval_context->debug)
hashtable_set (options, "debug_output", *(eval_context->debug));
if (eval_context->debug)
string_dyn_free (eval_context->debug, 1);
return value;
}

View File

@ -72,6 +72,7 @@ struct t_eval_context
const char *suffix;
struct t_eval_regex *regex;
int recursion_count;
char **debug;
};
extern int eval_is_true (const char *value);