*fixed an array index calculation bug.
This commit is contained in:
parent
a157c2e67a
commit
a9e7245be1
1
HISTORY
1
HISTORY
@ -1,5 +1,6 @@
|
|||||||
Feb. 25 2016
|
Feb. 25 2016
|
||||||
Fixed a bug with the END and RETURN statement with FOR loop
|
Fixed a bug with the END and RETURN statement with FOR loop
|
||||||
|
Fixed an array index calculation bug
|
||||||
|
|
||||||
Feb. 24 2016
|
Feb. 24 2016
|
||||||
Added a TO_ARRAY statement
|
Added a TO_ARRAY statement
|
||||||
|
@ -5807,6 +5807,7 @@ static int _get_array_pos(mb_interpreter_t* s, _array_t* arr, int* d, int c) {
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
int f = 1;
|
||||||
|
|
||||||
mb_assert(s && arr && d);
|
mb_assert(s && arr && d);
|
||||||
|
|
||||||
@ -5822,10 +5823,8 @@ static int _get_array_pos(mb_interpreter_t* s, _array_t* arr, int* d, int c) {
|
|||||||
|
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
if(result)
|
result += n * f;
|
||||||
result *= n;
|
f *= arr->dimensions[i];
|
||||||
else
|
|
||||||
result += n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
@ -5842,6 +5841,7 @@ static int _get_array_index(mb_interpreter_t* s, _ls_node_t** l, _object_t* c, u
|
|||||||
_object_t* subscript_ptr = 0;
|
_object_t* subscript_ptr = 0;
|
||||||
mb_value_u val;
|
mb_value_u val;
|
||||||
int dcount = 0;
|
int dcount = 0;
|
||||||
|
int f = 1;
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
|
|
||||||
mb_assert(s && l && index);
|
mb_assert(s && l && index);
|
||||||
@ -5898,14 +5898,12 @@ static int _get_array_index(mb_interpreter_t* s, _ls_node_t** l, _object_t* c, u
|
|||||||
if((int)val.integer >= arr->data.array->dimensions[dcount]) {
|
if((int)val.integer >= arr->data.array->dimensions[dcount]) {
|
||||||
_handle_error_on_obj(s, SE_RN_ARRAY_OUT_OF_BOUND, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result);
|
_handle_error_on_obj(s, SE_RN_ARRAY_OUT_OF_BOUND, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result);
|
||||||
}
|
}
|
||||||
if(idx)
|
idx += (unsigned int)val.integer * f;
|
||||||
idx *= (unsigned int)val.integer;
|
|
||||||
else
|
|
||||||
idx += (unsigned int)val.integer;
|
|
||||||
/* Comma? */
|
/* Comma? */
|
||||||
if(_IS_SEP(ast->data, ','))
|
if(_IS_SEP(ast->data, ','))
|
||||||
ast = ast->next;
|
ast = ast->next;
|
||||||
|
|
||||||
|
f *= arr->data.array->dimensions[dcount];
|
||||||
++dcount;
|
++dcount;
|
||||||
}
|
}
|
||||||
*index = idx;
|
*index = idx;
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user