diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 16 | ||||
-rw-r--r-- | src/core/wee-eval.c | 21 |
2 files changed, 29 insertions, 8 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 142821146..8eb81d5de 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -7204,12 +7204,16 @@ command_init () "Format for hdata can be one of following:\n" " hdata.var1.var2...: start with a hdata (pointer must be known), " "and ask variables one after one (other hdata can be followed)\n" - " hdata[list].var1.var2...: start with a hdata using a list, for " - "example:\n" - " ${buffer[gui_buffers].full_name}: full name of first buffer in " - "linked list of buffers\n" - " ${plugin[weechat_plugins].name}: name of first plugin in linked " - "list of plugins\n" + " hdata[list].var1.var2...: start with a hdata using a " + "list/pointer, for example:\n" + " ${buffer[gui_buffers].full_name}: full name of first buffer " + "in linked list of buffers\n" + " hdata[pointer].var1.var2...: start with a hdata using a list, " + "for example:\n" + " ${buffer[0x1234abcd].full_name}: full name of the buffer " + "with this pointer (can be used in triggers)\n" + " ${plugin[weechat_plugins].name}: name of first plugin in " + "linked list of plugins\n" "For name of hdata and variables, please look at \"Plugin API " "reference\", function \"weechat_hdata_get\".\n" "\n" diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index 8d0216718..105068d89 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -248,8 +248,9 @@ eval_replace_vars_cb (void *data, const char *text) const char *ptr_value, *ptr_arguments, *ptr_string; struct t_hdata *hdata; void *pointer; - int i, length_hide_char, length, index; + int i, length_hide_char, length, index, rc; long number; + long unsigned int ptr; pointers = (struct t_hashtable *)(((void **)data)[0]); extra_vars = (struct t_hashtable *)(((void **)data)[1]); @@ -438,7 +439,23 @@ eval_replace_vars_cb (void *data, const char *text) goto end; if (list_name) - pointer = hdata_get_list (hdata, list_name); + { + if (strncmp (list_name, "0x", 2) == 0) + { + rc = sscanf (list_name, "%lx", &ptr); + if ((rc != EOF) && (rc != 0)) + { + pointer = (void *)ptr; + if (!hdata_check_pointer (hdata, NULL, pointer)) + goto end; + } + else + goto end; + } + else + pointer = hdata_get_list (hdata, list_name); + } + if (!pointer) { pointer = hashtable_get (pointers, hdata_name); |