30#define TAB_RW (TAB_R | TAB_W)
33#define aux_getn(L,n,w) (checktab(L, n, (w) | TAB_L), luaL_len(L, n))
61#if defined(LUA_COMPAT_MAXN)
90 luaL_argcheck(L, 1 <= pos && pos <= e, 2,
"position out of bounds");
91 for (i = e; i > pos; i--) {
98 return luaL_error(L,
"wrong number of arguments to 'insert'");
110 luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1,
"position out of bounds");
112 for ( ; pos < size; pos++) {
138 "too many elements to move");
141 "destination wrap around");
143 for (i = 0; i < n; i++) {
149 for (i = n - 1; i >= 0; i--) {
163 luaL_error(L,
"invalid value (%s) at index %d in table for 'concat'",
177 for (; i < last; i++) {
199 for (i = n; i >= 1; i--)
214 return luaL_error(L,
"too many results to unpack");
245#if !defined(l_randomizePivot)
250#define sof(e) (sizeof(e) / sizeof(unsigned int))
260 time_t t = time(
NULL);
261 unsigned int buff[
sof(c) +
sof(t)];
262 unsigned int i, rnd = 0;
263 memcpy(buff, &c,
sof(c) *
sizeof(
unsigned int));
264 memcpy(buff +
sof(c), &t,
sof(t) *
sizeof(
unsigned int));
265 for (i = 0; i <
sof(buff); i++)
318 luaL_error(L,
"invalid order function for sorting");
325 luaL_error(L,
"invalid order function for sorting");
347 IdxT r4 = (up - lo) / 4;
348 IdxT p = rnd % (r4 * 2) + (lo + r4);
395 if (p - lo < up - p) {
405 if ((up - lo) / 128 > n)
428#if defined(LUA_COMPAT_MAXN)
443#if defined(LUA_COMPAT_UNPACK)
CURL_EXTERN int void * arg
LUA_API void lua_pushstring(lua_State *L, const char *s)
LUA_API void lua_pushnil(lua_State *L)
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API void lua_rawget(lua_State *L, int idx)
LUA_API int lua_toboolean(lua_State *L, int idx)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API int lua_type(lua_State *L, int idx)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUA_API int lua_isstring(lua_State *L, int idx)
LUA_API int lua_next(lua_State *L, int idx)
LUA_API int lua_checkstack(lua_State *L, int size)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
LUA_API int lua_gettop(lua_State *L)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
LUALIB_API void luaL_checktype(lua_State *L, int narg, int t)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int narg)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int narg, lua_Integer def)
LUALIB_API const char * luaL_optlstring(lua_State *L, int narg, const char *def, size_t *len)
#define luaL_typename(L, i)
#define luaL_opt(L, f, n, d)
#define luaL_argcheck(L, cond, numarg, extramsg)
static int maxn(lua_State *L)
#define lua_setglobal(L, s)
#define lua_isnoneornil(L, n)
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
LUALIB_API int luaL_len(lua_State *L, int idx)
#define luaL_newlib(L, l)
LUA_UNSIGNED lua_Unsigned
#define lua_tonumber(L, i)
#define lua_call(L, n, r)
LUA_API void lua_seti(lua_State *L, int idx, lua_Integer n)
LUA_API int lua_geti(lua_State *L, int idx, lua_Integer n)
static void auxsort(lua_State *L, IdxT lo, IdxT up, unsigned int rnd)
static IdxT partition(lua_State *L, IdxT lo, IdxT up)
static int tinsert(lua_State *L)
static int tmove(lua_State *L)
static int pack(lua_State *L)
#define aux_getn(L, n, w)
static void addfield(lua_State *L, luaL_Buffer *b, lua_Integer i)
static int checkfield(lua_State *L, const char *key, int n)
static void set2(lua_State *L, IdxT i, IdxT j)
static unsigned int l_randomizePivot(void)
static int unpack(lua_State *L)
static void checktab(lua_State *L, int arg, int what)
static IdxT choosePivot(IdxT lo, IdxT up, unsigned int rnd)
LUAMOD_API int luaopen_table(lua_State *L)
static int tremove(lua_State *L)
static int tconcat(lua_State *L)
static const luaL_Reg tab_funcs[]
static int sort(lua_State *L)
static int sort_comp(lua_State *L, int a, int b)
#define lua_insert(L, idx)