mirror of
https://github.com/lua/lua.git
synced 2025-02-04 06:13:04 +08:00
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)
This commit is contained in:
parent
9945253d57
commit
62f6652d53
21
lauxlib.c
21
lauxlib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.284 2015/11/19 19:16:22 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.285 2015/12/14 11:59:27 roberto Exp roberto $
|
||||||
** Auxiliary functions for building Lua libraries
|
** Auxiliary functions for building Lua libraries
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
/* This file uses only the official API of Lua.
|
/*
|
||||||
|
** This file uses only the official API of Lua.
|
||||||
** Any function declared here could be written as an application function.
|
** Any function declared here could be written as an application function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -217,7 +218,8 @@ LUALIB_API void luaL_where (lua_State *L, int level) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Again, the use of 'lua_pushvfstring' ensures this function does
|
** Again, the use of 'lua_pushvfstring' ensures this function does
|
||||||
** not need reserved stack space when called.
|
** not need reserved stack space when called. (At worst, it generates
|
||||||
|
** an error with "stack overflow" instead of the given message.)
|
||||||
*/
|
*/
|
||||||
LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
|
LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
|
||||||
va_list argp;
|
va_list argp;
|
||||||
@ -358,17 +360,14 @@ LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def,
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Ensures the stack has at least 'space' extra slots, raising
|
** Ensures the stack has at least 'space' extra slots, raising an error
|
||||||
** an error if it cannot fulfill the request. It adds some
|
** if it cannot fulfill the request. (The error handling needs a few
|
||||||
** extra space so that, next time it is called (this function
|
** extra slots to format the error message. In case of an error without
|
||||||
** is typically called inside a loop), it has space to format
|
** this extra space, Lua will generate the same 'stack overflow' error,
|
||||||
** the error message. (In case of an error without this extra
|
|
||||||
** space, Lua will generate the same 'stack overflow' error,
|
|
||||||
** but without 'msg'.)
|
** but without 'msg'.)
|
||||||
*/
|
*/
|
||||||
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) {
|
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) {
|
||||||
const int extra = 5; /* extra space to run error routines */
|
if (!lua_checkstack(L, space)) {
|
||||||
if (!lua_checkstack(L, space + extra)) {
|
|
||||||
if (msg)
|
if (msg)
|
||||||
luaL_error(L, "stack overflow (%s)", msg);
|
luaL_error(L, "stack overflow (%s)", msg);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user