[Freeswitch-svn] [commit] r10100 - freeswitch/trunk/src/mod/languages/mod_lua/lua
Freeswitch SVN
mikej at freeswitch.org
Tue Oct 21 15:39:57 EDT 2008
Author: mikej
Date: Tue Oct 21 15:39:57 2008
New Revision: 10100
Modified:
freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c
freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c
freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c
freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c
freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h
freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c
freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c
freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h
freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h
freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c
Log:
MODLANG-87 - Update to lua 5.1.4 release
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lapi.c Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $
+** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -93,15 +93,14 @@
LUA_API int lua_checkstack (lua_State *L, int size) {
- int res;
+ int res = 1;
lua_lock(L);
- if ((L->top - L->base + size) > LUAI_MAXCSTACK)
+ if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
res = 0; /* stack overflow */
- else {
+ else if (size > 0) {
luaD_checkstack(L, size);
if (L->ci->top < L->top + size)
L->ci->top = L->top + size;
- res = 1;
}
lua_unlock(L);
return res;
@@ -930,10 +929,13 @@
g->GCthreshold = g->totalbytes - a;
else
g->GCthreshold = 0;
- while (g->GCthreshold <= g->totalbytes)
+ while (g->GCthreshold <= g->totalbytes) {
luaC_step(L);
- if (g->gcstate == GCSpause) /* end of cycle? */
- res = 1; /* signal it */
+ if (g->gcstate == GCSpause) { /* end of cycle? */
+ res = 1; /* signal it */
+ break;
+ }
+ }
break;
}
case LUA_GCSETPAUSE: {
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lbaselib.c Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: lbaselib.c,v 1.191.1.4 2008/01/20 13:53:22 roberto Exp $
+** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $
** Basic library
** See Copyright Notice in lua.h
*/
@@ -344,10 +344,12 @@
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1);
e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
+ if (i > e) return 0; /* empty range */
n = e - i + 1; /* number of elements */
- if (n <= 0) return 0; /* empty range */
- luaL_checkstack(L, n, "table too big to unpack");
- for (; i<=e; i++) /* push arg[i...e] */
+ if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
+ 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] */
lua_rawgeti(L, 1, i);
return n;
}
@@ -526,7 +528,7 @@
status = lua_resume(co, narg);
if (status == 0 || status == LUA_YIELD) {
int nres = lua_gettop(co);
- if (!lua_checkstack(L, nres))
+ if (!lua_checkstack(L, nres + 1))
luaL_error(L, "too many results to resume");
lua_xmove(co, L, nres); /* move yielded values */
return nres;
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ldebug.c Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 2.29.1.3 2007/12/28 15:32:23 roberto Exp $
+** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -275,12 +275,12 @@
static int precheck (const Proto *pt) {
check(pt->maxstacksize <= MAXSTACK);
- lua_assert(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
- lua_assert(!(pt->is_vararg & VARARG_NEEDSARG) ||
+ check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
+ check(!(pt->is_vararg & VARARG_NEEDSARG) ||
(pt->is_vararg & VARARG_HASARG));
check(pt->sizeupvalues <= pt->nups);
check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
- check(GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
+ check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
return 1;
}
@@ -346,9 +346,18 @@
int dest = pc+1+b;
check(0 <= dest && dest < pt->sizecode);
if (dest > 0) {
- /* cannot jump to a setlist count */
- Instruction d = pt->code[dest-1];
- check(!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0));
+ int j;
+ /* check that it does not jump to a setlist count; this
+ is tricky, because the count from a previous setlist may
+ have the same value of an invalid setlist; so, we must
+ go all the way back to the first of them (if any) */
+ for (j = 0; j < dest; j++) {
+ Instruction d = pt->code[dest-1-j];
+ if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
+ }
+ /* if 'j' is even, previous value is not a setlist (even if
+ it looks like one) */
+ check((j&1) == 0);
}
}
break;
@@ -363,7 +372,11 @@
}
switch (op) {
case OP_LOADBOOL: {
- check(c == 0 || pc+2 < pt->sizecode); /* check its jump */
+ if (c == 1) { /* does it jump? */
+ check(pc+2 < pt->sizecode); /* check its jump */
+ check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
+ GETARG_C(pt->code[pc+1]) != 0);
+ }
break;
}
case OP_LOADNIL: {
@@ -428,7 +441,10 @@
}
case OP_SETLIST: {
if (b > 0) checkreg(pt, a + b);
- if (c == 0) pc++;
+ if (c == 0) {
+ pc++;
+ check(pc < pt->sizecode - 1);
+ }
break;
}
case OP_CLOSURE: {
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/loadlib.c Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.52.1.2 2007/12/28 14:58:43 roberto Exp $
+** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -506,8 +506,10 @@
static void setfenv (lua_State *L) {
lua_Debug ar;
- lua_getstack(L, 1, &ar);
- lua_getinfo(L, "f", &ar);
+ if (lua_getstack(L, 1, &ar) == 0 ||
+ lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
+ lua_iscfunction(L, -1))
+ luaL_error(L, LUA_QL("module") " not called from a Lua function");
lua_pushvalue(L, -2);
lua_setfenv(L, -2);
lua_pop(L, 1);
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lobject.h Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.h,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $
+** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@@ -208,7 +208,7 @@
#define getstr(ts) cast(const char *, (ts) + 1)
-#define svalue(o) getstr(tsvalue(o))
+#define svalue(o) getstr(rawtsvalue(o))
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lstrlib.c Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.132.1.3 2007/12/28 15:32:23 roberto Exp $
+** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -35,7 +35,8 @@
static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
/* relative string position: negative means back from end */
- return (pos>=0) ? pos : (ptrdiff_t)len+pos+1;
+ if (pos < 0) pos += (ptrdiff_t)len + 1;
+ return (pos >= 0) ? pos : 0;
}
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/ltablib.c Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: ltablib.c,v 1.38.1.2 2007/12/28 15:32:23 roberto Exp $
+** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $
** Library for Table Manipulation
** See Copyright Notice in lua.h
*/
@@ -132,6 +132,15 @@
}
+static void addfield (lua_State *L, luaL_Buffer *b, int i) {
+ lua_rawgeti(L, 1, i);
+ if (!lua_isstring(L, -1))
+ luaL_error(L, "invalid value (%s) at index %d in table for "
+ LUA_QL("concat"), luaL_typename(L, -1), i);
+ luaL_addvalue(b);
+}
+
+
static int tconcat (lua_State *L) {
luaL_Buffer b;
size_t lsep;
@@ -141,13 +150,12 @@
i = luaL_optint(L, 3, 1);
last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1));
luaL_buffinit(L, &b);
- for (; i <= last; i++) {
- lua_rawgeti(L, 1, i);
- luaL_argcheck(L, lua_isstring(L, -1), 1, "table contains non-strings");
- luaL_addvalue(&b);
- if (i != last)
- luaL_addlstring(&b, sep, lsep);
+ for (; i < last; i++) {
+ addfield(L, &b, i);
+ luaL_addlstring(&b, sep, lsep);
}
+ if (i == last) /* add last value (if interval was not empty) */
+ addfield(L, &b, i);
luaL_pushresult(&b);
return 1;
}
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lua.h Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.218.1.4 2008/01/03 15:41:15 roberto Exp $
+** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $
** Lua - An Extensible Extension Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@@ -17,7 +17,7 @@
#define LUA_VERSION "Lua 5.1"
-#define LUA_RELEASE "Lua 5.1.3"
+#define LUA_RELEASE "Lua 5.1.4"
#define LUA_VERSION_NUM 501
#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/luaconf.h Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.82.1.6 2008/01/18 17:07:48 roberto Exp $
+** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -91,7 +91,7 @@
".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
#define LUA_CPATH_DEFAULT \
- ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
+ ".\\?.dll;" ".\\?51.dll;" LUA_CDIR"?.dll;" LUA_CDIR"?51.dll;" LUA_CDIR"clibs\\?.dll;" LUA_CDIR"clibs\\?51.dll;" LUA_CDIR"loadall.dll;" LUA_CDIR"clibs\\loadall.dll"
#else
#define LUA_ROOT "/usr/local/"
@@ -101,7 +101,7 @@
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
#define LUA_CPATH_DEFAULT \
- "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
+ "./?.so;" "./lib?51.so;" LUA_CDIR"?.so;" LUA_CDIR"lib?51.so;" LUA_CDIR"loadall.so"
#endif
@@ -440,10 +440,10 @@
@* can use.
** CHANGE it if you need lots of (Lua) stack space for your C
** functions. This limit is arbitrary; its only purpose is to stop C
-** functions to consume unlimited stack space.
+** functions to consume unlimited stack space. (must be smaller than
+** -LUA_REGISTRYINDEX)
*/
-#define LUAI_MCS_AUX ((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
-#define LUAI_MAXCSTACK (LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
+#define LUAI_MAXCSTACK 8000
Modified: freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/lua/lundump.c Tue Oct 21 15:39:57 2008
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 2.7.1.2 2008/01/18 16:39:11 roberto Exp $
+** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -48,7 +48,6 @@
static void LoadBlock(LoadState* S, void* b, size_t size)
{
size_t r=luaZ_read(S->Z,b,size);
- UNUSED(r);
IF (r!=0, "unexpected end");
}
@@ -115,7 +114,7 @@
setnilvalue(o);
break;
case LUA_TBOOLEAN:
- setbvalue(o,LoadChar(S));
+ setbvalue(o,LoadChar(S)!=0);
break;
case LUA_TNUMBER:
setnvalue(o,LoadNumber(S));
@@ -161,7 +160,9 @@
static Proto* LoadFunction(LoadState* S, TString* p)
{
- Proto* f=luaF_newproto(S->L);
+ Proto* f;
+ if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
+ f=luaF_newproto(S->L);
setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
f->source=LoadString(S); if (f->source==NULL) f->source=p;
f->linedefined=LoadInt(S);
@@ -175,6 +176,7 @@
LoadDebug(S,f);
IF (!luaG_checkcode(f), "bad code");
S->L->top--;
+ S->L->nCcalls--;
return f;
}
More information about the Freeswitch-svn
mailing list