30 #if !defined(MAX_SIZET) 32 #define MAX_SIZET ((size_t)(~(size_t)0)) 62 else if (
findfield(L, objidx, level - 1)) {
85 if (strncmp(name,
LUA_GNAME ".", 3) == 0) {
107 else if (*ar->
what ==
'm')
109 else if (*ar->
what !=
'C')
132 const char *msg,
int level) {
144 if (limit2show-- == 0) {
145 int n = last - level -
LEVELS2 + 1;
178 return luaL_error(L,
"bad argument #%d (%s)", arg, extramsg);
180 if (strcmp(ar.
namewhat,
"method") == 0) {
183 return luaL_error(L,
"calling '%s' on bad self (%s)",
188 return luaL_error(L,
"bad argument #%d to '%s' (%s)",
189 arg, ar.
name, extramsg);
199 typearg =
"light userdata";
263 #if !defined(l_inspectstat) 265 #if defined(LUA_USE_POSIX) 267 #include <sys/wait.h> 272 #define l_inspectstat(stat,what) \ 273 if (WIFEXITED(stat)) { stat = WEXITSTATUS(stat); } \ 274 else if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); what = "signal"; } 278 #define l_inspectstat(stat,what) 286 const char *what =
"exit";
287 if (stat != 0 && errno != 0)
291 if (*what ==
'e' && stat == 0)
361 const char *
const lst[]) {
365 for (i=0; lst[i]; i++)
366 if (strcmp(lst[i], name) == 0)
410 const char *def,
size_t *
len) {
413 *len = (def ? strlen(def) : 0);
436 luaL_argerror(L, arg,
"number has no integer representation");
477 void *temp = allocf(ud, box->
box, box->
bsize, newsize);
478 if (temp == NULL && newsize > 0) {
483 box->
bsize = newsize;
515 #define buffonstack(B) ((B)->b != (B)->init.b) 523 size_t newsize = B->
size * 2;
526 if (newsize < B->n + sz)
538 if (B->
size - B->
n >= sz)
546 newbuff = (
char *)
resizebox(L, boxidx, newsize);
553 newbuff = (
char *)
resizebox(L, boxidx, newsize);
554 memcpy(newbuff, B->
b, B->
n *
sizeof(
char));
558 return newbuff + B->
n;
573 memcpy(b, s, l *
sizeof(
char));
614 memcpy(b, s, len *
sizeof(
char));
704 if (feof(lf->
f))
return NULL;
705 *size = fread(lf->
buff, 1,
sizeof(lf->
buff), lf->
f);
712 const char *serr = strerror(errno);
721 const char *p =
"\xEF\xBB\xBF";
726 if (c == EOF || c != *(
const unsigned char *)p++)
return c;
728 }
while (*p !=
'\0');
746 }
while (c != EOF && c !=
'\n');
757 int status, readstatus;
760 if (filename == NULL) {
766 lf.
f = fopen(filename,
"r");
767 if (lf.
f == NULL)
return errfile(L,
"open", fnameindex);
770 lf.
buff[lf.
n++] =
'\n';
772 lf.
f = freopen(filename,
"rb", lf.
f);
773 if (lf.
f == NULL)
return errfile(L,
"reopen", fnameindex);
779 readstatus = ferror(lf.
f);
780 if (filename) fclose(lf.
f);
783 return errfile(L,
"read", fnameindex);
799 if (ls->
size == 0)
return NULL;
807 const char *
name,
const char *mode) {
855 luaL_error(L,
"object length is not an integer");
864 luaL_error(L,
"'__tostring' must return a string");
906 for (; l->
name != NULL; l++) {
911 for (i = 0; i < nup; i++)
966 const char *p,
const char *r) {
968 size_t l = strlen(p);
969 while ((wild = strstr(s, p)) != NULL) {
979 const char *p,
const char *r) {
988 static void *
l_alloc (
void *ud,
void *
ptr,
size_t osize,
size_t nsize) {
1001 if (msg == NULL) msg =
"error object is not a string";
1014 static void warnf (
void *ud,
const char *message,
int tocont) {
1015 int *warnstate = (
int *)ud;
1016 if (*warnstate != 2 && !tocont && *message ==
'@') {
1017 if (strcmp(message,
"@off") == 0)
1019 else if (strcmp(message,
"@on") == 0)
1023 else if (*warnstate == 0)
1025 if (*warnstate == 1)
1054 luaL_error(L,
"core and library have incompatible numeric types");
1056 luaL_error(L,
"version mismatch: app. needs %f, Lua core provides %f",
#define luaL_addsize(B, s)
LUA_API int lua_isstring(lua_State *L, int idx)
static void * l_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
#define lua_isnoneornil(L, n)
static void interror(lua_State *L, int arg)
union luaL_Buffer::@19 init
static int panic(lua_State *L)
LUALIB_API int luaL_ref(lua_State *L, int t)
#define lua_pushcfunction(L, f)
LUA_API int lua_isinteger(lua_State *L, int idx)
LUA_API void lua_toclose(lua_State *L, int idx)
LUA_API int lua_rawget(lua_State *L, int idx)
int luaL_typeerror(lua_State *L, int arg, const char *tname)
LUA_API const char * lua_pushvfstring(lua_State *L, const char *fmt, va_list argp)
LUALIB_API void luaL_addgsub(luaL_Buffer *b, const char *s, const char *p, const char *r)
static int pushglobalfuncname(lua_State *L, lua_Debug *ar)
LUALIB_API int luaL_checkoption(lua_State *L, int arg, const char *def, const char *const lst[])
LUA_API void lua_pushnil(lua_State *L)
LUA_API int lua_isnumber(lua_State *L, int idx)
LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s)
LUA_API const void * lua_topointer(lua_State *L, int idx)
LUA_API int lua_rawgeti(lua_State *L, int idx, lua_Integer n)
LUALIB_API void luaL_checkversion_(lua_State *L, lua_Number ver, size_t sz)
LUA_API lua_Number lua_version(lua_State *L)
void lua_setwarnf(lua_State *L, lua_WarnFunction f, void *ud)
static const char * getF(lua_State *L, void *ud, size_t *size)
static void pushfuncname(lua_State *L, lua_Debug *ar)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
LUA_API int lua_toboolean(lua_State *L, int idx)
LUA_API void * lua_touserdata(lua_State *L, int idx)
#define luaL_argexpected(L, cond, arg, tname)
static void warnf(void *ud, const char *message, int tocont)
LUALIB_API int luaL_callmeta(lua_State *L, int obj, const char *event)
LUALIB_API void luaL_pushresultsize(luaL_Buffer *B, size_t sz)
LUALIB_API int luaL_loadstring(lua_State *L, const char *s)
static int findfield(lua_State *L, int objidx, int level)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
#define lua_remove(L, idx)
LUALIB_API const char * luaL_gsub(lua_State *L, const char *s, const char *p, const char *r)
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *pisnum)
#define lua_tointeger(L, i)
LUA_API lua_State * lua_newstate(lua_Alloc f, void *ud)
#define LUA_TLIGHTUSERDATA
LUA_API int lua_error(lua_State *L)
LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t size, const char *name, const char *mode)
#define luaL_getmetatable(L, n)
#define lua_tonumber(L, i)
#define luaL_typename(L, i)
char short_src[LUA_IDSIZE]
LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname)
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUA_API lua_Number lua_tonumberx(lua_State *L, int idx, int *pisnum)
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
#define luaL_loadbuffer(L, s, sz, n)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
LUALIB_API int luaL_execresult(lua_State *L, int stat)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
LUA_API void lua_setglobal(lua_State *L, const char *name)
static const luaL_Reg boxmt[]
static int skipcomment(LoadF *lf, int *cp)
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
LUALIB_API void * luaL_testudata(lua_State *L, int ud, const char *tname)
int(* lua_CFunction)(lua_State *L)
#define l_inspectstat(stat, what)
LUALIB_API const char * luaL_checklstring(lua_State *L, int arg, size_t *len)
LUALIB_API char * luaL_buffinitsize(lua_State *L, luaL_Buffer *B, size_t sz)
LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf)
#define luaL_opt(L, f, n, d)
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API void lua_rawseti(lua_State *L, int idx, lua_Integer n)
static char * prepbuffsize(luaL_Buffer *B, size_t sz, int boxidx)
LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
static void newbox(lua_State *L)
static void * resizebox(lua_State *L, int idx, size_t newsize)
#define luaL_addchar(B, c)
LUALIB_API const char * luaL_optlstring(lua_State *L, int arg, const char *def, size_t *len)
#define lua_pushliteral(L, s)
LUA_API const char * lua_tolstring(lua_State *L, int idx, size_t *len)
LUALIB_API lua_Integer luaL_len(lua_State *L, int idx)
LUALIB_API void luaL_unref(lua_State *L, int t, int ref)
LUALIB_API void luaL_checkany(lua_State *L, int arg)
static int errfile(lua_State *L, const char *what, int fnameindex)
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
LUA_API int lua_next(lua_State *L, int idx)
LUALIB_API const char * luaL_tolstring(lua_State *L, int idx, size_t *len)
LUALIB_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level)
LUA_API void lua_concat(lua_State *L, int n)
static int boxgc(lua_State *L)
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
detail::named_arg< Char, T > arg(const Char *name, const T &arg)
LUALIB_API void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb)
LUA_API void * lua_newuserdatauv(lua_State *L, size_t size, int nuvalue)
static void tag_error(lua_State *L, int arg, int tag)
LUALIB_API void * luaL_checkudata(lua_State *L, int ud, const char *tname)
LUA_API int lua_absindex(lua_State *L, int idx)
LUA_API int lua_type(lua_State *L, int idx)
LUALIB_API int luaL_argerror(lua_State *L, int arg, const char *extramsg)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
#define lua_replace(L, idx)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
#define lua_tostring(L, i)
LUA_API void lua_copy(lua_State *L, int fromidx, int toidx)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
#define lua_call(L, n, r)
LUA_API void lua_rotate(lua_State *L, int idx, int n)
LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
LUA_API lua_Alloc lua_getallocf(lua_State *L, void **ud)
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
#define LUA_REGISTRYINDEX
LUALIB_API void luaL_checktype(lua_State *L, int arg, int t)
#define lua_istable(L, n)
LUALIB_API lua_State * luaL_newstate(void)
LUA_API void lua_len(lua_State *L, int idx)
LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode)
LUALIB_API void luaL_setmetatable(lua_State *L, const char *tname)
LUALIB_API lua_Number luaL_checknumber(lua_State *L, int arg)
#define lua_writestringerror(s, p)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
LUALIB_API char * luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
LUALIB_API lua_Number luaL_optnumber(lua_State *L, int arg, lua_Number def)
static const char * getS(lua_State *L, void *ud, size_t *size)
static int lastlevel(lua_State *L)
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
LUALIB_API int luaL_getmetafield(lua_State *L, int obj, const char *event)
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
static int skipBOM(LoadF *lf)
LUA_API int lua_rawequal(lua_State *L, int index1, int index2)
#define luaL_optstring(L, n, d)
LUALIB_API void luaL_where(lua_State *L, int level)
static size_t newbuffsize(luaL_Buffer *B, size_t sz)
LUA_API int lua_checkstack(lua_State *L, int n)
LUA_API int lua_gettop(lua_State *L)
LUA_API lua_Unsigned lua_rawlen(lua_State *L, int idx)
#define luaL_checkstring(L, n)
LUA_API const char * lua_typename(lua_State *L, int t)