Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
lua: Updating to 5.1.4
Updating base code to 5.1.4
Adding -DSYSLINUX build flag
Moving #if 0 to ifndef SYSLINUX
  • Loading branch information
ErwanAliasr1 committed Feb 7, 2011
1 parent 0405304 commit bfcd7b7
Show file tree
Hide file tree
Showing 21 changed files with 308 additions and 215 deletions.
281 changes: 159 additions & 122 deletions com32/lua/doc/manual.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions com32/lua/doc/readme.html
Expand Up @@ -12,7 +12,7 @@ <H1>
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>
Expand All @@ -33,7 +33,7 @@ <H1>
<HR>
<SMALL>
Last update:
Wed Dec 19 13:59:14 BRST 2007
Tue Aug 12 14:46:07 BRT 2008
</SMALL>

</BODY>
Expand Down
2 changes: 1 addition & 1 deletion com32/lua/etc/lua.pc
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions com32/lua/src/Makefile
Expand Up @@ -24,6 +24,7 @@ LNXLIBS =
# Temporarily allow warnings not being treated as errors
#GCCWARN += -Wno-error

CFLAGS += -DSYSLINUX
MODULES = lua.c32
TESTFILES =

Expand Down
18 changes: 10 additions & 8 deletions com32/lua/src/lapi.c
@@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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: {
Expand Down
6 changes: 2 additions & 4 deletions com32/lua/src/lauxlib.c
Expand Up @@ -552,9 +552,6 @@ static int errfile (lua_State *L, const char *what, int fnameindex) {
LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
LoadF lf;
int status, readstatus;
#if 0
int c;
#endif
int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
lf.extraline = 0;
if (filename == NULL) {
Expand All @@ -566,7 +563,8 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
lf.f = fopen(filename, "r");
if (lf.f == NULL) return errfile(L, "open", fnameindex);
}
#if 0
#ifndef SYSLINUX
int c;
c = getc(lf.f);
if (c == '#') { /* Unix exec. file? */
lf.extraline = 1;
Expand Down
12 changes: 7 additions & 5 deletions com32/lua/src/lbaselib.c
@@ -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
*/
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
34 changes: 25 additions & 9 deletions com32/lua/src/ldebug.c
@@ -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
*/
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
7 changes: 5 additions & 2 deletions com32/lua/src/linit.c
Expand Up @@ -19,16 +19,19 @@ static const luaL_Reg lualibs[] = {
{LUA_LOADLIBNAME, luaopen_package},
{LUA_TABLIBNAME, luaopen_table},
{LUA_IOLIBNAME, luaopen_io},
// {LUA_OSLIBNAME, luaopen_os},
#ifndef SYSLINUX
{LUA_OSLIBNAME, luaopen_os},
#endif
{LUA_STRLIBNAME, luaopen_string},
#if !defined LUA_NUMBER_INTEGRAL
{LUA_MATHLIBNAME, luaopen_math},
#endif
{LUA_PCILIBNAME, luaopen_pci},
{LUA_DBLIBNAME, luaopen_debug},
#ifdef SYSLINUX
{LUA_DMILIBNAME, luaopen_dmi},
{LUA_SYSLINUXLIBNAME, luaopen_syslinux},
{LUA_VESALIBNAME, luaopen_vesa},
#endif
{NULL, NULL}
};

Expand Down
26 changes: 13 additions & 13 deletions com32/lua/src/liolib.c
Expand Up @@ -180,7 +180,7 @@ static int io_popen (lua_State *L) {
}


#if 0
#ifndef SYSLINUX
static int io_tmpfile (lua_State *L) {
FILE **pf = newfile(L);
*pf = tmpfile();
Expand Down Expand Up @@ -271,7 +271,7 @@ static int io_lines (lua_State *L) {
** =======================================================
*/

#if 0
#ifndef SYSLINUX
static int read_number (lua_State *L, FILE *f) {
lua_Number d;
if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
Expand Down Expand Up @@ -312,7 +312,7 @@ static int read_line (lua_State *L, FILE *f) {
}
}

#if 0 /* Not used */
#ifndef SYSLINUX /* Not used */
static int read_chars (lua_State *L, FILE *f, size_t n) {
size_t rlen; /* how much to read */
size_t nr; /* number of chars actually read */
Expand All @@ -329,9 +329,7 @@ static int read_chars (lua_State *L, FILE *f, size_t n) {
luaL_pushresult(&b); /* close buffer */
return (n == 0 || lua_objlen(L, -1) > 0);
}
#endif

#if 0
static int g_read (lua_State *L, FILE *f, int first) {
int nargs = lua_gettop(L) - 1;
int success;
Expand Down Expand Up @@ -440,7 +438,7 @@ static int f_write (lua_State *L) {
return g_write(L, tofile(L), 2);
}

#if 0
#ifndef SYSLINUX
static int f_seek (lua_State *L) {
static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
static const char *const modenames[] = {"set", "cur", "end", NULL};
Expand All @@ -455,10 +453,8 @@ static int f_seek (lua_State *L) {
return 1;
}
}
#endif


#if 0
static int f_setvbuf (lua_State *L) {
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
static const char *const modenames[] = {"no", "full", "line", NULL};
Expand Down Expand Up @@ -489,8 +485,10 @@ static const luaL_Reg iolib[] = {
{"open", io_open},
{"output", io_output},
{"popen", io_popen},
/* {"read", io_read}, */
/* {"tmpfile", io_tmpfile}, */
#ifndef SYSLINUX
{"read", io_read},
{"tmpfile", io_tmpfile},
#endif
{"type", io_type},
{"write", io_write},
{NULL, NULL}
Expand All @@ -501,9 +499,11 @@ static const luaL_Reg flib[] = {
{"close", io_close},
{"flush", f_flush},
{"lines", f_lines},
/* {"read", f_read}, */
/* {"seek", f_seek}, */
/* {"setvbuf", f_setvbuf}, */
#ifndef SYSLINUX
{"read", f_read},
{"seek", f_seek},
{"setvbuf", f_setvbuf},
#endif
{"write", f_write},
{"__gc", io_gc},
{"__tostring", io_tostring},
Expand Down
10 changes: 7 additions & 3 deletions com32/lua/src/llex.c
Expand Up @@ -6,7 +6,9 @@


#include <ctype.h>
//#include <locale.h>
#ifndef SYSLINUX
#include <locale.h>
#endif
#include <string.h>

#define llex_c
Expand Down Expand Up @@ -176,9 +178,11 @@ static void buffreplace (LexState *ls, char from, char to) {

static void trydecpoint (LexState *ls, SemInfo *seminfo) {
/* format error: try to update decimal point separator */
//struct lconv *cv = localeconv();
char old = ls->decpoint;
//ls->decpoint = (cv ? cv->decimal_point[0] : '.');
#ifndef SYSLINUX
struct lconv *cv = localeconv();
ls->decpoint = (cv ? cv->decimal_point[0] : '.');
#endif
buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */
if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) {
/* format error with correct decimal point: no more options */
Expand Down
14 changes: 10 additions & 4 deletions com32/lua/src/loadlib.c
@@ -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
**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -589,7 +591,11 @@ static int ll_seeall (lua_State *L) {

static void setpath (lua_State *L, const char *fieldname, const char *envname,
const char *def) {
const char *path = /*getenv(envname)*/ NULL;
#ifdef SYSLINUX
const char *path = NULL;
#else
const char *path = getenv(envname);
#endif
(void)envname; /* Shut up gcc */
if (path == NULL) /* no environment variable? */
lua_pushstring(L, def); /* use default */
Expand Down
4 changes: 2 additions & 2 deletions com32/lua/src/lobject.h
@@ -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
*/
Expand Down Expand Up @@ -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))



Expand Down
6 changes: 5 additions & 1 deletion com32/lua/src/loslib.c
Expand Up @@ -66,7 +66,11 @@ static int os_tmpname (lua_State *L) {


static int os_getenv (lua_State *L) {
lua_pushstring(L, /*getenv(luaL_checkstring(L, 1))*/); /* if NULL push nil */
#ifdef SYSLINUX
lua_pushstring(L, NULL); /* if NULL push nil */
#else
lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */
#endif
return 1;
}

Expand Down

0 comments on commit bfcd7b7

Please sign in to comment.