*fixed a wrong evaluation bug in nested IF statements, thanks to Julien Krief for pointing it out.

This commit is contained in:
tony 2015-10-05 20:48:03 +08:00
parent 8eea0b39af
commit f4ea9dce90
2 changed files with 10 additions and 2 deletions

View File

@ -3,6 +3,7 @@ Added a LIST collection
Added a DICT collection Added a DICT collection
Added TYPE statement Added TYPE statement
Added an mb_get_type_string function Added an mb_get_type_string function
Fixed a wrong evaluation bug in nested IF statements, thanks to Julien Krief for pointing it out
Sep. 30 2015 Sep. 30 2015
Improved UTF8 string manipulation Improved UTF8 string manipulation

View File

@ -79,7 +79,7 @@ extern "C" {
/** Macros */ /** Macros */
#define _VER_MAJOR 1 #define _VER_MAJOR 1
#define _VER_MINOR 1 #define _VER_MINOR 1
#define _VER_REVISION 78 #define _VER_REVISION 79
#define _VER_SUFFIX #define _VER_SUFFIX
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION)) #define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
#define _STRINGIZE(A) _MAKE_STRINGIZE(A) #define _STRINGIZE(A) _MAKE_STRINGIZE(A)
@ -5272,6 +5272,7 @@ int _skip_if_chunk(mb_interpreter_t* s, _ls_node_t** l) {
_ls_node_t* ast = 0; _ls_node_t* ast = 0;
_ls_node_t* tmp = 0; _ls_node_t* tmp = 0;
_object_t* obj = 0; _object_t* obj = 0;
int nested = 0;
mb_assert(s && l); mb_assert(s && l);
@ -5285,7 +5286,13 @@ int _skip_if_chunk(mb_interpreter_t* s, _ls_node_t** l) {
obj = (_object_t*)(ast->data); obj = (_object_t*)(ast->data);
*l = ast; *l = ast;
ast = ast->next; ast = ast->next;
} while(!_IS_FUNC(obj, _core_if) && !_IS_FUNC(obj, _core_elseif) && !_IS_FUNC(obj, _core_else) && !_IS_FUNC(obj, _core_endif)); if(_IS_FUNC((_object_t*)(ast->data), _core_if)) {
++nested;
} else if(nested && _IS_FUNC((_object_t*)(ast->data), _core_endif)) {
--nested;
ast = ast->next;
}
} while(nested || (!_IS_FUNC(obj, _core_elseif) && !_IS_FUNC(obj, _core_else) && !_IS_FUNC(obj, _core_endif)));
_exit: _exit:
return result; return result;