diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-01-08 13:33:09 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-01-08 13:33:09 -0200 |
commit | 62f6652d5347104efc552e3f30338a962e9ccd0b (patch) | |
tree | 3b25c52360f6cba5d8df50df9f211c1a52cd9efe /lauxlib.c | |
parent | 9945253d57a5d328308c543a3c08334512aaf364 (diff) | |
download | lua-62f6652d5347104efc552e3f30338a962e9ccd0b.tar.gz lua-62f6652d5347104efc552e3f30338a962e9ccd0b.tar.bz2 lua-62f6652d5347104efc552e3f30338a962e9ccd0b.zip |
no more extra space in 'luaL_checkstack'. (It was already useless
for the first call, and function works ok without that space
anyway (just error message misses the 'msg' component)
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 21 |
1 files changed, 10 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.284 2015/11/19 19:16:22 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.285 2015/12/14 11:59:27 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -17,7 +17,8 @@ | |||
17 | #include <string.h> | 17 | #include <string.h> |
18 | 18 | ||
19 | 19 | ||
20 | /* This file uses only the official API of Lua. | 20 | /* |
21 | ** This file uses only the official API of Lua. | ||
21 | ** Any function declared here could be written as an application function. | 22 | ** Any function declared here could be written as an application function. |
22 | */ | 23 | */ |
23 | 24 | ||
@@ -217,7 +218,8 @@ LUALIB_API void luaL_where (lua_State *L, int level) { | |||
217 | 218 | ||
218 | /* | 219 | /* |
219 | ** Again, the use of 'lua_pushvfstring' ensures this function does | 220 | ** Again, the use of 'lua_pushvfstring' ensures this function does |
220 | ** not need reserved stack space when called. | 221 | ** not need reserved stack space when called. (At worst, it generates |
222 | ** an error with "stack overflow" instead of the given message.) | ||
221 | */ | 223 | */ |
222 | LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { | 224 | LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { |
223 | va_list argp; | 225 | va_list argp; |
@@ -358,17 +360,14 @@ LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def, | |||
358 | 360 | ||
359 | 361 | ||
360 | /* | 362 | /* |
361 | ** Ensures the stack has at least 'space' extra slots, raising | 363 | ** Ensures the stack has at least 'space' extra slots, raising an error |
362 | ** an error if it cannot fulfill the request. It adds some | 364 | ** if it cannot fulfill the request. (The error handling needs a few |
363 | ** extra space so that, next time it is called (this function | 365 | ** extra slots to format the error message. In case of an error without |
364 | ** is typically called inside a loop), it has space to format | 366 | ** this extra space, Lua will generate the same 'stack overflow' error, |
365 | ** the error message. (In case of an error without this extra | ||
366 | ** space, Lua will generate the same 'stack overflow' error, | ||
367 | ** but without 'msg'.) | 367 | ** but without 'msg'.) |
368 | */ | 368 | */ |
369 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { | 369 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { |
370 | const int extra = 5; /* extra space to run error routines */ | 370 | if (!lua_checkstack(L, space)) { |
371 | if (!lua_checkstack(L, space + extra)) { | ||
372 | if (msg) | 371 | if (msg) |
373 | luaL_error(L, "stack overflow (%s)", msg); | 372 | luaL_error(L, "stack overflow (%s)", msg); |
374 | else | 373 | else |