diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-06 10:03:45 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-06 10:03:45 -0200 |
commit | 617be660158490c7f6558e82d9be2c667c48d9a4 (patch) | |
tree | 27c0c29cb550d576cef2b4953ff4c4622f852503 /lapi.c | |
parent | f356eb010b6785cf22e8d5f1d4f7761e0789ae51 (diff) | |
download | lua-617be660158490c7f6558e82d9be2c667c48d9a4.tar.gz lua-617be660158490c7f6558e82d9be2c667c48d9a4.tar.bz2 lua-617be660158490c7f6558e82d9be2c667c48d9a4.zip |
better control (and error recovery) for begin/end blocks
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.61 1999/12/01 19:50:08 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.62 1999/12/02 16:24:45 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -592,19 +592,16 @@ const char *lua_getobjname (lua_State *L, lua_Object o, const char **name) { | |||
592 | */ | 592 | */ |
593 | 593 | ||
594 | 594 | ||
595 | #ifndef MAX_C_BLOCKS | ||
596 | #define MAX_C_BLOCKS 1000 /* arbitrary limit */ | ||
597 | #endif | ||
598 | |||
599 | |||
600 | void lua_beginblock (lua_State *L) { | 595 | void lua_beginblock (lua_State *L) { |
601 | luaM_growvector(L, L->Cblocks, L->numCblocks, 1, struct C_Lua_Stack, | 596 | luaM_growvector(L, L->Cblocks, L->numCblocks, 1, struct C_Lua_Stack, |
602 | "too many nested blocks", MAX_C_BLOCKS); | 597 | "too many nested blocks", L->stacksize); |
603 | L->Cblocks[L->numCblocks] = L->Cstack; | 598 | L->Cblocks[L->numCblocks] = L->Cstack; |
604 | L->numCblocks++; | 599 | L->numCblocks++; |
605 | } | 600 | } |
606 | 601 | ||
607 | void lua_endblock (lua_State *L) { | 602 | void lua_endblock (lua_State *L) { |
603 | if (L->numCblocks <= 0) | ||
604 | lua_error(L, "API error - no block to end"); | ||
608 | --L->numCblocks; | 605 | --L->numCblocks; |
609 | L->Cstack = L->Cblocks[L->numCblocks]; | 606 | L->Cstack = L->Cblocks[L->numCblocks]; |
610 | L->top = L->Cstack.base; | 607 | L->top = L->Cstack.base; |