1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 05:16:38 +02:00

core: allow pointer as list name in evaluation of hdata (closes #450)

This commit is contained in:
Sébastien Helleu
2015-06-23 20:55:52 +02:00
parent 43f471b9c2
commit a79c0fcff3
27 changed files with 301 additions and 157 deletions
+10 -6
View File
@@ -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"
+19 -2
View File
@@ -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);