fixed a wrong IF trunk processing bug, thanks to irony for pointing it out; fixed a crash bug with an invalid IF statement.

This commit is contained in:
tony 2015-08-11 13:27:17 +08:00
parent bd35f56154
commit 8b0e99c755
5 changed files with 16 additions and 9 deletions

View File

@ -1,3 +1,7 @@
Aug. 11 2015
Fixed a wrong IF trunk processing bug, thanks to irony for pointing it out
Fixed a crash bug with an invalid IF statement
Jul. 27 2015
Fixed a memory leak with mb_pop_xxx, thanks to Daniel Haensse for pointing it out

View File

@ -78,7 +78,7 @@ extern "C" {
/** Macros */
#define _VER_MAJOR 1
#define _VER_MINOR 1
#define _VER_REVISION 60
#define _VER_REVISION 61
#define _MB_VERSION ((_VER_MAJOR * 0x01000000) + (_VER_MINOR * 0x00010000) + (_VER_REVISION))
/* Uncomment this line to treat warnings as error */
@ -3166,7 +3166,7 @@ int _skip_if_chunk(mb_interpreter_t* s, _ls_node_t** l) {
obj = (_object_t*)(ast->data);
*l = ast;
ast = ast->next;
} while(!_IS_FUNC(obj, _core_if) && !_IS_FUNC(obj, _core_elseif) && !_IS_FUNC(obj, _core_else));
} while(!_IS_FUNC(obj, _core_if) && !_IS_FUNC(obj, _core_elseif) && !_IS_FUNC(obj, _core_else) && !_IS_FUNC(obj, _core_endif));
_exit:
return result;
@ -5021,10 +5021,12 @@ _elseif:
_skip_if_chunk(s, &ast);
}
if(multi_line && ast && _IS_FUNC(ast->data, _core_elseif)) {
if(ast) ast = ast->next;
ast = ast->next;
goto _elseif;
}
if(multi_line && ast && _IS_FUNC(ast->data, _core_endif))
goto _exit;
result = _skip_to(s, &ast, _core_else, _DT_EOS);
if(result != MB_FUNC_OK)
@ -5057,7 +5059,8 @@ _exit:
if(multi_line)
result = _skip_to(s, &ast, _core_endif, _DT_NIL);
_destroy_object(val, 0);
if(val->type != _DT_ANY)
_destroy_object(val, 0);
*l = ast;

Binary file not shown.

View File

@ -36,8 +36,8 @@
IDI_ICON_MAIN ICON "icon.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,59,0
PRODUCTVERSION 1,1,59,0
FILEVERSION 1,1,61,0
PRODUCTVERSION 1,1,61,0
FILEFLAGSMASK 0x17L
# ifdef _DEBUG
FILEFLAGS 0x1L
@ -55,13 +55,13 @@
VALUE "Comments", "MY-BASIC"
VALUE "CompanyName", "W. Renxin"
VALUE "FileDescription", "MY-BASIC interpreter"
VALUE "FileVersion", "1, 1, 59, 0"
VALUE "FileVersion", "1, 1, 61, 0"
VALUE "InternalName", "my_basic"
VALUE "LegalCopyright", "Copyright (C) 2011 - 2015 W. Renxin"
VALUE "LegalTrademarks", "MY-BASIC"
VALUE "OriginalFilename", "my_basic.exe"
VALUE "ProductName", "MY-BASIC"
VALUE "ProductVersion", "1, 1, 59, 0"
VALUE "ProductVersion", "1, 1, 61, 0"
END
END
BLOCK "VarFileInfo"

View File

@ -267,7 +267,7 @@ static void _list_program(const char* sn, const char* cn) {
if(lsn == 0 && lcn == 0) {
long i = 0;
for(i = 0; i < c->count; ++i) {
printf("%ld]%s\n", i + 1, c->lines[i]);
printf("%ld]%s", i + 1, c->lines[i]);
}
} else {
long i = 0;