Verified Commit 4132bbed authored by AtjonTV's avatar AtjonTV
Browse files

Lua 5.1.4

parent b268fbf5
......@@ -7,28 +7,33 @@
# Your platform. See PLATS for possible values.
PLAT= none
# Where to install. The installation starts in the src directory, so take care
# if INSTALL_TOP is not an absolute path. (Man pages are installed from the
# doc directory.) You may want to make these paths consistent with LUA_ROOT,
# LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
#
# Where to install. The installation starts in the src and doc directories,
# so take care if INSTALL_TOP is not an absolute path.
INSTALL_TOP= /usr/local
INSTALL_BIN= $(INSTALL_TOP)/bin
INSTALL_INC= $(INSTALL_TOP)/include
INSTALL_LIB= $(INSTALL_TOP)/lib
INSTALL_MAN= $(INSTALL_TOP)/man/man1
#
# You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
# How to install. If you don't have "install" (unlikely) then get install-sh at
# http://dev.w3.org/cvsweb/libwww/config/install-sh
# or use cp instead.
INSTALL_EXEC= $(INSTALL) -p -m 0755
INSTALL_DATA= $(INSTALL) -p -m 0644
# How to install. If your install program does not support "-p", then you
# may have to run ranlib on the installed liblua.a (do "make ranlib").
INSTALL= install -p
INSTALL_EXEC= $(INSTALL) -m 0755
INSTALL_DATA= $(INSTALL) -m 0644
#
# If you don't have install you can use cp instead.
# INSTALL= cp -p
# INSTALL_EXEC= $(INSTALL)
# INSTALL_DATA= $(INSTALL)
# Utilities.
INSTALL= install
MKDIR= mkdir
MKDIR= mkdir -p
RANLIB= ranlib
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
......@@ -43,7 +48,7 @@ TO_MAN= lua.1 luac.1
# Lua version and release.
V= 5.1
R= 5.1.3
R= 5.1.4
all: $(PLAT)
......@@ -54,12 +59,15 @@ test: dummy
src/lua test/hello.lua
install: dummy
cd src && $(MKDIR) -p $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
ranlib:
cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)
local:
$(MAKE) install INSTALL_TOP=..
......
This diff is collapsed.
......@@ -12,7 +12,7 @@
Documentation
</H1>
This is the documentation included in the source distribution of Lua 5.1.3.
This is the documentation included in the source distribution of Lua 5.1.4.
<UL>
<LI><A HREF="contents.html">Reference manual</A>
......@@ -33,7 +33,7 @@ especially the
<HR>
<SMALL>
Last update:
Wed Dec 19 13:59:14 BRST 2007
Tue Aug 12 14:46:07 BRT 2008
</SMALL>
</BODY>
......
......@@ -5,7 +5,7 @@
# grep '^V=' ../Makefile
V= 5.1
# grep '^R=' ../Makefile
R= 5.1.3
R= 5.1.4
# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
prefix= /usr/local
......
/*
** $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 @@ void luaA_pushobject (lua_State *L, const TValue *o) {
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 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
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: {
......
/*
** $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 @@ static int luaB_unpack (lua_State *L) {
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 @@ static int auxresume (lua_State *L, lua_State *co, int narg) {
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;
......
/*
** $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 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
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 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
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 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
}
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 @@ static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
}
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: {
......
/*
** $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 int ll_require (lua_State *L) {
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);
......
/*
** $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 @@ typedef union TString {
#define getstr(ts) cast(const char *, (ts) + 1)
#define svalue(o) getstr(tsvalue(o))
#define svalue(o) getstr(rawtsvalue(o))
......
/*
** $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 int str_len (lua_State *L) {
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;
}
......
/*
** $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 int tremove (lua_State *L) {
}
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 @@ static int tconcat (lua_State *L) {
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;
}
......
/*
** $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"
......
/*
** $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
*/
......@@ -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
......
/*
** $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 error(LoadState* S, const char* why)
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 @@ static void LoadConstants(LoadState* S, Proto* f)
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 void LoadDebug(LoadState* S, Proto* f)
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 @@ static Proto* LoadFunction(LoadState* S, TString* p)
LoadDebug(S,f);
IF (!luaG_checkcode(f), "bad code");
S->L->top--;
S->L->nCcalls--;
return f;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment