Skip to content

Commit

Permalink
Upgrade included liblua to 5.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Mar 9, 2016
1 parent 22c1856 commit 3c56648
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 23 deletions.
12 changes: 11 additions & 1 deletion liblua/ldblib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: ldblib.c,v 1.132.1.1 2013/04/12 18:48:47 roberto Exp $
** $Id: ldblib.c,v 1.132.1.2 2015/02/19 17:16:55 roberto Exp $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
Expand All @@ -21,6 +21,11 @@
#define HOOKKEY "_HKEY"


static void checkstack (lua_State *L, lua_State *L1, int n) {
if (L != L1 && !lua_checkstack(L1, n))
luaL_error(L, "stack overflow");
}


static int db_getregistry (lua_State *L) {
lua_pushvalue(L, LUA_REGISTRYINDEX);
Expand Down Expand Up @@ -114,6 +119,7 @@ static int db_getinfo (lua_State *L) {
int arg;
lua_State *L1 = getthread(L, &arg);
const char *options = luaL_optstring(L, arg+2, "flnStu");
checkstack(L, L1, 3);
if (lua_isnumber(L, arg+1)) {
if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) {
lua_pushnil(L); /* level out of range */
Expand Down Expand Up @@ -173,6 +179,7 @@ static int db_getlocal (lua_State *L) {
else { /* stack-level argument */
if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
return luaL_argerror(L, arg+1, "level out of range");
checkstack(L, L1, 1);
name = lua_getlocal(L1, &ar, nvar);
if (name) {
lua_xmove(L1, L, 1); /* push local value */
Expand All @@ -196,6 +203,7 @@ static int db_setlocal (lua_State *L) {
return luaL_argerror(L, arg+1, "level out of range");
luaL_checkany(L, arg+3);
lua_settop(L, arg+3);
checkstack(L, L1, 1);
lua_xmove(L, L1, 1);
lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2)));
return 1;
Expand Down Expand Up @@ -313,6 +321,7 @@ static int db_sethook (lua_State *L) {
lua_pushvalue(L, -1);
lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */
}
checkstack(L, L1, 1);
lua_pushthread(L1); lua_xmove(L1, L, 1);
lua_pushvalue(L, arg+1);
lua_rawset(L, -3); /* set new hook */
Expand All @@ -331,6 +340,7 @@ static int db_gethook (lua_State *L) {
lua_pushliteral(L, "external hook");
else {
gethooktable(L);
checkstack(L, L1, 1);
lua_pushthread(L1); lua_xmove(L1, L, 1);
lua_rawget(L, -2); /* get hook */
lua_remove(L, -2); /* remove hook table */
Expand Down
21 changes: 19 additions & 2 deletions liblua/ldebug.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: ldebug.c,v 2.90.1.3 2013/05/16 16:04:15 roberto Exp $
** $Id: ldebug.c,v 2.90.1.4 2015/02/19 17:05:13 roberto Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -47,6 +47,16 @@ static int currentline (CallInfo *ci) {
}


static void swapextra (lua_State *L) {
if (L->status == LUA_YIELD) {
CallInfo *ci = L->ci; /* get function that yielded */
StkId temp = ci->func; /* exchange its 'func' and 'extra' values */
ci->func = restorestack(L, ci->extra);
ci->extra = savestack(L, temp);
}
}


/*
** this function can be called asynchronous (e.g. during a signal)
*/
Expand Down Expand Up @@ -144,6 +154,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
const char *name;
lua_lock(L);
swapextra(L);
if (ar == NULL) { /* information about non-active function? */
if (!isLfunction(L->top - 1)) /* not a Lua function? */
name = NULL;
Expand All @@ -158,18 +169,22 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
api_incr_top(L);
}
}
swapextra(L);
lua_unlock(L);
return name;
}


LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
StkId pos = 0; /* to avoid warnings */
const char *name = findlocal(L, ar->i_ci, n, &pos);
const char *name;
lua_lock(L);
swapextra(L);
name = findlocal(L, ar->i_ci, n, &pos);
if (name)
setobjs2s(L, pos, L->top - 1);
L->top--; /* pop value */
swapextra(L);
lua_unlock(L);
return name;
}
Expand Down Expand Up @@ -269,6 +284,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
CallInfo *ci;
StkId func;
lua_lock(L);
swapextra(L);
if (*what == '>') {
ci = NULL;
func = L->top - 1;
Expand All @@ -287,6 +303,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
setobjs2s(L, L->top, func);
api_incr_top(L);
}
swapextra(L);
if (strchr(what, 'L'))
collectvalidlines(L, cl);
lua_unlock(L);
Expand Down
4 changes: 2 additions & 2 deletions liblua/lgc.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 2.140.1.2 2013/04/26 18:22:05 roberto Exp $
** $Id: lgc.c,v 2.140.1.3 2014/09/01 16:55:08 roberto Exp $
** Garbage Collector
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -403,7 +403,7 @@ static int traverseephemeron (global_State *g, Table *h) {
reallymarkobject(g, gcvalue(gval(n))); /* mark it now */
}
}
if (prop)
if (g->gcstate != GCSatomic || prop)
linktable(h, &g->ephemeron); /* have to propagate again */
else if (hasclears) /* does table have white keys? */
linktable(h, &g->allweak); /* may have to clean white keys */
Expand Down
4 changes: 2 additions & 2 deletions liblua/llex.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: llex.c,v 2.63.1.2 2013/08/30 15:49:41 roberto Exp $
** $Id: llex.c,v 2.63.1.3 2015/02/09 17:56:34 roberto Exp $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -152,7 +152,7 @@ static void inclinenumber (LexState *ls) {
if (currIsNewline(ls) && ls->current != old)
next(ls); /* skip `\n\r' or `\r\n' */
if (++ls->linenumber >= MAX_INT)
luaX_syntaxerror(ls, "chunk has too many lines");
lexerror(ls, "chunk has too many lines", 0);
}


Expand Down
6 changes: 3 additions & 3 deletions liblua/lobject.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lobject.h,v 2.71.1.1 2013/04/12 18:48:47 roberto Exp $
** $Id: lobject.h,v 2.71.1.2 2014/05/07 14:14:58 roberto Exp $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -561,12 +561,12 @@ typedef struct Table {
CommonHeader;
lu_byte flags; /* 1<<p means tagmethod(p) is not present */
lu_byte lsizenode; /* log2 of size of `node' array */
struct Table *metatable;
int sizearray; /* size of `array' array */
TValue *array; /* array part */
Node *node;
Node *lastfree; /* any free position is before this position */
struct Table *metatable;
GCObject *gclist;
int sizearray; /* size of `array' array */
} Table;


Expand Down
4 changes: 2 additions & 2 deletions liblua/lopcodes.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lopcodes.h,v 1.142.1.1 2013/04/12 18:48:47 roberto Exp $
** $Id: lopcodes.h,v 1.142.1.2 2014/10/20 18:32:09 roberto Exp $
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -196,7 +196,7 @@ OP_LEN,/* A B R(A) := length of R(B) */

OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */

OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A) + 1 */
OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */
OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
Expand Down
10 changes: 6 additions & 4 deletions liblua/ltablib.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
** $Id: ltablib.c,v 1.65.1.1 2013/04/12 18:48:47 roberto Exp $
** $Id: ltablib.c,v 1.65.1.2 2014/05/07 16:32:55 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/


#include <limits.h>
#include <stddef.h>

#define ltablib_c
Expand Down Expand Up @@ -134,13 +135,14 @@ static int pack (lua_State *L) {


static int unpack (lua_State *L) {
int i, e, n;
int i, e;
unsigned int n;
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1);
e = luaL_opt(L, luaL_checkint, 3, luaL_len(L, 1));
if (i > e) return 0; /* empty range */
n = e - i + 1; /* number of elements */
if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
n = (unsigned int)e - (unsigned int)i; /* number of elements minus 1 */
if (n > (INT_MAX - 10) || !lua_checkstack(L, ++n))
return luaL_error(L, "too many results to unpack");
lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
while (i++ < e) /* push arg[i + 1...e] */
Expand Down
8 changes: 4 additions & 4 deletions liblua/lua.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lua.h,v 1.285.1.2 2013/11/11 12:09:16 roberto Exp $
** $Id: lua.h,v 1.285.1.4 2015/02/21 14:04:50 roberto Exp $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http:https://www.lua.org)
** See Copyright Notice at the end of this file
Expand All @@ -19,11 +19,11 @@
#define LUA_VERSION_MAJOR "5"
#define LUA_VERSION_MINOR "2"
#define LUA_VERSION_NUM 502
#define LUA_VERSION_RELEASE "3"
#define LUA_VERSION_RELEASE "4"

#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2013 Lua.org, PUC-Rio"
#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"


Expand Down Expand Up @@ -418,7 +418,7 @@ struct lua_Debug {


/******************************************************************************
* Copyright (C) 1994-2013 Lua.org, PUC-Rio.
* Copyright (C) 1994-2015 Lua.org, PUC-Rio.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down
6 changes: 3 additions & 3 deletions liblua/luaconf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: luaconf.h,v 1.176.1.1 2013/04/12 18:48:47 roberto Exp $
** $Id: luaconf.h,v 1.176.1.2 2013/11/21 17:26:16 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -326,7 +326,7 @@


/*
@@ LUA_INT32 is an signed integer with exactly 32 bits.
@@ LUA_INT32 is a signed integer with exactly 32 bits.
@@ LUAI_UMEM is an unsigned integer big enough to count the total
@* memory used by Lua.
@@ LUAI_MEM is a signed integer big enough to count the total memory
Expand All @@ -350,7 +350,7 @@
/*
@@ LUAI_MAXSTACK limits the size of the Lua stack.
** CHANGE it if you need a different limit. This limit is arbitrary;
** its only purpose is to stop Lua to consume unlimited stack
** its only purpose is to stop Lua from consuming unlimited stack
** space (and to reserve some numbers for pseudo-indices).
*/
#if LUAI_BITSINT >= 32
Expand Down

0 comments on commit 3c56648

Please sign in to comment.