mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 02:33:12 +02:00
core: display more verbose debug with two "-d" in command /eval
Now a single -d in command /eval shows less debug messages than previous versions. To get the same debug messages than previous versions, two -d must be used.
This commit is contained in:
+10
-6
@@ -2023,7 +2023,7 @@ COMMAND_CALLBACK(debug)
|
||||
COMMAND_CALLBACK(eval)
|
||||
{
|
||||
int i, print_only, split_command, condition, debug, error;
|
||||
char *result, *ptr_args, **commands;
|
||||
char *result, *ptr_args, **commands, str_debug[32];
|
||||
const char **debug_output;
|
||||
struct t_hashtable *pointers, *options;
|
||||
|
||||
@@ -2060,7 +2060,7 @@ COMMAND_CALLBACK(eval)
|
||||
}
|
||||
else if (string_strcasecmp (argv[i], "-d") == 0)
|
||||
{
|
||||
debug = 1;
|
||||
debug++;
|
||||
ptr_args = argv_eol[i + 1];
|
||||
}
|
||||
else
|
||||
@@ -2096,8 +2096,11 @@ COMMAND_CALLBACK(eval)
|
||||
{
|
||||
if (condition)
|
||||
hashtable_set (options, "type", "condition");
|
||||
if (debug)
|
||||
hashtable_set (options, "debug", "1");
|
||||
if (debug > 0)
|
||||
{
|
||||
snprintf (str_debug, sizeof (str_debug), "%d", debug);
|
||||
hashtable_set (options, "debug", str_debug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7459,12 +7462,13 @@ command_init ()
|
||||
NULL, "eval",
|
||||
N_("evaluate expression"),
|
||||
N_("[-n|-s] [-d] <expression>"
|
||||
" || [-n] [-d] -c <expression1> <operator> <expression2>"),
|
||||
" || [-n] [-d [-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"
|
||||
" -d: display debug output after evaluation "
|
||||
"(with two -d: more verbose debug)\n"
|
||||
" -c: evaluate as condition: use operators and parentheses, "
|
||||
"return a boolean value (\"0\" or \"1\")\n"
|
||||
"expression: expression to evaluate, variables with format "
|
||||
|
||||
+23
-13
@@ -46,8 +46,8 @@
|
||||
#include "../plugins/plugin.h"
|
||||
|
||||
|
||||
#define EVAL_DEBUG(msg, argz...) \
|
||||
if (eval_context->debug) \
|
||||
#define EVAL_DEBUG(level, msg, argz...) \
|
||||
if (eval_context->debug_level >= level) \
|
||||
eval_debug_message (eval_context, msg, ##argz);
|
||||
|
||||
char *logical_ops[EVAL_NUM_LOGICAL_OPS] =
|
||||
@@ -125,7 +125,7 @@ eval_strstr_level (const char *string, const char *search,
|
||||
int level, length_search;
|
||||
int length_prefix, length_prefix2, length_suffix, length_suffix2;
|
||||
|
||||
EVAL_DEBUG("eval_strstr_level(\"%s\", \"%s\", \"%s\", \"%s\", %d)",
|
||||
EVAL_DEBUG(2, "eval_strstr_level(\"%s\", \"%s\", \"%s\", \"%s\", %d)",
|
||||
string, search, extra_prefix, extra_suffix, escape);
|
||||
|
||||
if (!string || !search)
|
||||
@@ -676,7 +676,7 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
|
||||
int type;
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
EVAL_DEBUG("eval_hdata_get_value(\"%s\", 0x%lx, \"%s\")",
|
||||
EVAL_DEBUG(1, "eval_hdata_get_value(\"%s\", 0x%lx, \"%s\")",
|
||||
hdata->name, pointer, path);
|
||||
|
||||
value = NULL;
|
||||
@@ -958,7 +958,7 @@ eval_replace_vars_cb (void *data, const char *text)
|
||||
|
||||
eval_context = (struct t_eval_context *)data;
|
||||
|
||||
EVAL_DEBUG("eval_replace_vars_cb(\"%s\")", text);
|
||||
EVAL_DEBUG(1, "eval_replace_vars_cb(\"%s\")", text);
|
||||
|
||||
/* 1. variable in hashtable "extra_vars" */
|
||||
if (eval_context->extra_vars)
|
||||
@@ -1148,7 +1148,7 @@ 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_DEBUG(1, "eval_replace_vars(\"%s\")", expr);
|
||||
|
||||
eval_context->recursion_count++;
|
||||
|
||||
@@ -1195,7 +1195,7 @@ eval_compare (const char *expr1, int comparison, const char *expr2,
|
||||
double value1, value2;
|
||||
char *error;
|
||||
|
||||
EVAL_DEBUG("eval_compare(\"%s\", \"%s\", \"%s\")",
|
||||
EVAL_DEBUG(1, "eval_compare(\"%s\", \"%s\", \"%s\")",
|
||||
expr1, comparisons[comparison], expr2);
|
||||
|
||||
rc = 0;
|
||||
@@ -1328,7 +1328,7 @@ 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);
|
||||
EVAL_DEBUG(1, "eval_expression_condition(\"%s\")", expr);
|
||||
|
||||
value = NULL;
|
||||
|
||||
@@ -1566,7 +1566,7 @@ 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\")",
|
||||
EVAL_DEBUG(1, "eval_replace_regex(\"%s\", 0x%lx, \"%s\")",
|
||||
string, regex, replace);
|
||||
|
||||
if (!string || !regex || !replace)
|
||||
@@ -1714,7 +1714,8 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
|
||||
struct t_eval_context context, *eval_context;
|
||||
int condition, rc, pointers_allocated, regex_allocated;
|
||||
int ptr_window_added, ptr_buffer_added;
|
||||
char *value;
|
||||
long number;
|
||||
char *value, *error;
|
||||
const char *default_prefix = EVAL_DEFAULT_PREFIX;
|
||||
const char *default_suffix = EVAL_DEFAULT_SUFFIX;
|
||||
const char *ptr_value, *regex_replace;
|
||||
@@ -1758,6 +1759,7 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
|
||||
eval_context->suffix = default_suffix;
|
||||
eval_context->regex = NULL;
|
||||
eval_context->recursion_count = 0;
|
||||
eval_context->debug_level = 0;
|
||||
eval_context->debug = NULL;
|
||||
|
||||
/*
|
||||
@@ -1830,11 +1832,19 @@ eval_expression (const char *expr, struct t_hashtable *pointers,
|
||||
}
|
||||
|
||||
/* check for debug */
|
||||
if (hashtable_has_key (options, "debug"))
|
||||
eval_context->debug = string_dyn_alloc (256);
|
||||
ptr_value = hashtable_get (options, "debug");
|
||||
if (ptr_value && ptr_value[0])
|
||||
{
|
||||
number = strtol (ptr_value, &error, 10);
|
||||
if (error && !error[0] && (number >= 1))
|
||||
{
|
||||
eval_context->debug_level = (int)number;
|
||||
eval_context->debug = string_dyn_alloc (256);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EVAL_DEBUG("eval_expression(\"%s\")", expr);
|
||||
EVAL_DEBUG(1, "eval_expression(\"%s\")", expr);
|
||||
|
||||
/* evaluate expression */
|
||||
if (condition)
|
||||
|
||||
+9
-8
@@ -71,14 +71,15 @@ struct t_eval_regex
|
||||
|
||||
struct t_eval_context
|
||||
{
|
||||
struct t_hashtable *pointers;
|
||||
struct t_hashtable *extra_vars;
|
||||
int extra_vars_eval;
|
||||
const char *prefix;
|
||||
const char *suffix;
|
||||
struct t_eval_regex *regex;
|
||||
int recursion_count;
|
||||
char **debug;
|
||||
struct t_hashtable *pointers; /* pointers used in eval */
|
||||
struct t_hashtable *extra_vars; /* extra variables used in eval */
|
||||
int extra_vars_eval; /* 1 if extra vars must be evaluated */
|
||||
const char *prefix; /* prefix (default is "${") */
|
||||
const char *suffix; /* suffix (default is "}") */
|
||||
struct t_eval_regex *regex; /* in case of replace with regex */
|
||||
int recursion_count; /* to prevent infinite recursion */
|
||||
int debug_level; /* 0: no debug, 1: debug, 2: extra */
|
||||
char **debug; /* not NULL if debug_level >= 1 */
|
||||
};
|
||||
|
||||
extern int eval_is_true (const char *value);
|
||||
|
||||
Reference in New Issue
Block a user