diff options
| author | Philipp Janda <siffiejoe@gmx.net> | 2015-09-13 19:10:36 +0200 |
|---|---|---|
| committer | Philipp Janda <siffiejoe@gmx.net> | 2015-09-13 19:10:36 +0200 |
| commit | 77aa5645c55e8f44060cab8657002d7a07de0e64 (patch) | |
| tree | b3991464fba89188347163315854906267fcd96d | |
| parent | 5a462cd093d57797cec2e0efc0788213ab799560 (diff) | |
| download | lua-compat-5.3-77aa5645c55e8f44060cab8657002d7a07de0e64.tar.gz lua-compat-5.3-77aa5645c55e8f44060cab8657002d7a07de0e64.tar.bz2 lua-compat-5.3-77aa5645c55e8f44060cab8657002d7a07de0e64.zip | |
luaL_checkstack accepts NULL message.v0.3
| -rw-r--r-- | c-api/compat-5.3.c | 12 | ||||
| -rw-r--r-- | c-api/compat-5.3.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c index 34b8001..fd41798 100644 --- a/c-api/compat-5.3.c +++ b/c-api/compat-5.3.c | |||
| @@ -155,6 +155,18 @@ COMPAT53_API void luaL_checkversion (lua_State *L) { | |||
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | 157 | ||
| 158 | COMPAT53_API void luaL_checkstack (lua_State *L, int sp, const char *msg) { | ||
| 159 | if (!lua_checkstack(L, sp+LUA_MINSTACK)) { | ||
| 160 | if (msg != NULL) | ||
| 161 | luaL_error(L, "stack overflow (%s)", msg); | ||
| 162 | else { | ||
| 163 | lua_pushliteral(L, "stack overflow"); | ||
| 164 | lua_error(L); | ||
| 165 | } | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | |||
| 158 | COMPAT53_API int luaL_getsubtable (lua_State *L, int i, const char *name) { | 170 | COMPAT53_API int luaL_getsubtable (lua_State *L, int i, const char *name) { |
| 159 | int abs_i = lua_absindex(L, i); | 171 | int abs_i = lua_absindex(L, i); |
| 160 | luaL_checkstack(L, 3, "not enough stack slots"); | 172 | luaL_checkstack(L, 3, "not enough stack slots"); |
diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h index c70ea33..2309294 100644 --- a/c-api/compat-5.3.h +++ b/c-api/compat-5.3.h | |||
| @@ -131,6 +131,9 @@ COMPAT53_API lua_Number lua_tonumberx (lua_State *L, int i, int *isnum); | |||
| 131 | #define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion) | 131 | #define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion) |
| 132 | COMPAT53_API void luaL_checkversion (lua_State *L); | 132 | COMPAT53_API void luaL_checkversion (lua_State *L); |
| 133 | 133 | ||
| 134 | #define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53) | ||
| 135 | COMPAT53_API void luaL_checkstack (lua_State *L, int sp, const char *msg); | ||
| 136 | |||
| 134 | #define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable) | 137 | #define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable) |
| 135 | COMPAT53_API int luaL_getsubtable (lua_State* L, int i, const char *name); | 138 | COMPAT53_API int luaL_getsubtable (lua_State* L, int i, const char *name); |
| 136 | 139 | ||
