diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2018-06-02 15:48:31 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2018-06-02 16:01:14 +0200 |
commit | 1abf4040f11ecf626dc79a3d0fb810b8efd6252e (patch) | |
tree | d561ec2e482eef9b8b9981edf2231e3a1b03486c /src/core/wee-eval.c | |
parent | ab9a0ec2e63d47a3663b08690848ec7b87d3d4fe (diff) | |
download | weechat-1abf4040f11ecf626dc79a3d0fb810b8efd6252e.zip |
core: add reverse of string in evaluation of expressions with "rev:" (closes #1200)
Diffstat (limited to 'src/core/wee-eval.c')
-rw-r--r-- | src/core/wee-eval.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index 2cba33a22..149344975 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -293,15 +293,16 @@ end: * 5. a string with max chars (format: cut:max,suffix,string or * cut:+max,suffix,string) or max chars on screen * (format: cutscr:max,suffix,string or cutscr:+max,suffix,string) - * 6. a regex group captured (format: re:N (0.99) or re:+) - * 7. a color (format: color:xxx) - * 8. an info (format: info:name,arguments) - * 9. current date/time (format: date or date:xxx) - * 10. an environment variable (format: env:XXX) - * 11. a ternary operator (format: if:condition?value_if_true:value_if_false) - * 12. an option (format: file.section.option) - * 13. a buffer local variable - * 14. a hdata variable (format: hdata.var1.var2 or hdata[list].var1.var2 + * 6. a reversed string (format: rev:xxx) + * 7. a regex group captured (format: re:N (0.99) or re:+) + * 8. a color (format: color:xxx) + * 9. an info (format: info:name,arguments) + * 10. current date/time (format: date or date:xxx) + * 11. an environment variable (format: env:XXX) + * 12. a ternary operator (format: if:condition?value_if_true:value_if_false) + * 13. an option (format: file.section.option) + * 14. a buffer local variable + * 15. a hdata variable (format: hdata.var1.var2 or hdata[list].var1.var2 * or hdata[ptr].var1.var2) * * See /help in WeeChat for examples. @@ -448,7 +449,13 @@ eval_replace_vars_cb (void *data, const char *text) return value; } - /* 6. regex group captured */ + /* 6. reverse string */ + if (strncmp (text, "rev:", 4) == 0) + { + return string_reverse (text + 4); + } + + /* 7. regex group captured */ if (strncmp (text, "re:", 3) == 0) { if (eval_context->regex && eval_context->regex->result) @@ -479,7 +486,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (""); } - /* 7. color code */ + /* 8. color code */ if (strncmp (text, "color:", 6) == 0) { ptr_value = gui_color_search_config (text + 6); @@ -489,7 +496,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup ((ptr_value) ? ptr_value : ""); } - /* 8. info */ + /* 9. info */ if (strncmp (text, "info:", 5) == 0) { ptr_value = NULL; @@ -509,7 +516,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup ((ptr_value) ? ptr_value : ""); } - /* 9. current date/time */ + /* 10. current date/time */ if ((strncmp (text, "date", 4) == 0) && (!text[4] || (text[4] == ':'))) { date = time (NULL); @@ -522,7 +529,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup ((rc > 0) ? str_value : ""); } - /* 10. environment variable */ + /* 11. environment variable */ if (strncmp (text, "env:", 4) == 0) { ptr_value = getenv (text + 4); @@ -530,7 +537,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (ptr_value); } - /* 11: ternary operator: if:condition?value_if_true:value_if_false */ + /* 12: ternary operator: if:condition?value_if_true:value_if_false */ if (strncmp (text, "if:", 3) == 0) { value = NULL; @@ -594,7 +601,7 @@ eval_replace_vars_cb (void *data, const char *text) return (value) ? value : strdup (""); } - /* 12. option: if found, return this value */ + /* 13. option: if found, return this value */ if (strncmp (text, "sec.data.", 9) == 0) { ptr_value = hashtable_get (secure_hashtable_data, text + 9); @@ -627,7 +634,7 @@ eval_replace_vars_cb (void *data, const char *text) } } - /* 13. local variable in buffer */ + /* 14. local variable in buffer */ ptr_buffer = hashtable_get (eval_context->pointers, "buffer"); if (ptr_buffer) { @@ -636,7 +643,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (ptr_value); } - /* 14. hdata */ + /* 15. hdata */ value = NULL; hdata_name = NULL; list_name = NULL; |