Skip to content

Commit

Permalink
#61 *Fixed an array retrieving bug in the mb_get_vars function.
Browse files Browse the repository at this point in the history
  • Loading branch information
paladin-t committed Jul 21, 2022
1 parent 60bcd0b commit c760bef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Jul. 21 2022
Fixed an array retrieving bug in the mb_get_vars function, thanks to nurbles for pointing it out

Jul. 9 2022
Added an MB_PRINT_INPUT_PROMPT macro
Added an MB_PRINT_INPUT_CONTENT macro
Expand Down
17 changes: 16 additions & 1 deletion core/my_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -9774,6 +9774,7 @@ static int _retrieve_var(void* data, void* extra, void* t) {
int* count = 0;
_object_t* obj = 0;
_var_t* var = 0;
_array_t* arr = 0;
mb_value_t val;
mb_unrefvar(extra);

Expand All @@ -9787,13 +9788,27 @@ static int _retrieve_var(void* data, void* extra, void* t) {
count = (int*)tuple->e3;

obj = (_object_t*)data;
if(obj->type == _DT_VAR) {
switch(obj->type) {
case _DT_VAR:
if(retrieved) {
var = (_var_t*)obj->data.variable;
_internal_object_to_public_value(var->data, &val);
retrieved(s, var->name, val);
}
++*count;

break;
case _DT_ARRAY:
if(retrieved) {
arr = (_array_t*)obj->data.array;
_internal_object_to_public_value(obj, &val);
retrieved(s, arr->name, val);
}
++*count;

break;
default: /* Do nothing */
break;
}

return result;
Expand Down

0 comments on commit c760bef

Please sign in to comment.