Skip to content

Commit

Permalink
Updated to Lua 5.1.3 (Bug fix release)
Browse files Browse the repository at this point in the history
Updated stdnse to include tobinary, toocal, and tohex functions.
Minor optimizations to listop.lua
  • Loading branch information
batrick committed May 31, 2008
1 parent 6692822 commit 21a2e7a
Show file tree
Hide file tree
Showing 59 changed files with 628 additions and 387 deletions.
38 changes: 21 additions & 17 deletions liblua/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MYLIBS=

# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========

PLATS= aix ansi bsd generic linux macosx mingw posix solaris
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris

LUA_A= liblua.a
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
Expand Down Expand Up @@ -77,32 +77,37 @@ echo:
# convenience targets for popular platforms

none:
@echo "Please choose a platform: $(PLATS)"
@echo "Please choose a platform:"
@echo " $(PLATS)"

aix:
$(MAKE) all CC="xlc" CFLAGS="-O2" MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
$(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"

ansi:
$(MAKE) all MYCFLAGS=-DLUA_ANSI

bsd:
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"

freebsd:
$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"

generic:
$(MAKE) all MYCFLAGS=

linux:
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"

macosx:
$(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
# use this on Mac OS X 10.4
# $(MAKE) all MYCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" MYLIBS="-lreadline"
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
# use this on Mac OS X 10.3-
# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX

mingw:
$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
$(MAKE) "LUAC_T=luac.exe" luac.exe

posix:
$(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
Expand All @@ -121,15 +126,15 @@ lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \
lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h
lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h
lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h \
ldo.h lgc.h
lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
ltable.h
ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h
ldebug.o: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \
llex.h lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h \
ltm.h ldo.h lfunc.h lstring.h lgc.h lvm.h
llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
lfunc.h lstring.h lgc.h ltable.h lvm.h
ldo.o: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h ltable.h \
lstring.h lundump.h lvm.h
lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \
ltable.h lundump.h lvm.h
ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \
lzio.h lmem.h lundump.h
lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \
Expand All @@ -139,19 +144,18 @@ lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h
liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h
llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \
lzio.h lmem.h llex.h lparser.h ltable.h lstring.h lgc.h
lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h
lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h
loadlib.o: loadlib.c lauxlib.h lua.h luaconf.h lobject.h llimits.h \
lualib.h
loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
lobject.o: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h
lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
lzio.h lmem.h lopcodes.h lparser.h ltable.h ldebug.h lstate.h ltm.h \
ldo.h lfunc.h lstring.h lgc.h
lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
lfunc.h lstring.h lgc.h ltable.h
lstate.o: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h
lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \
Expand Down
21 changes: 14 additions & 7 deletions liblua/lapi.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.53 2006/01/10 12:50:00 roberto Exp $
** $Id: lapi.c,v 2.55.1.3 2008/01/03 15:20:39 roberto Exp $
** Lua API
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -32,7 +32,7 @@


const char lua_ident[] =
"$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n"
"$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
"$Authors: " LUA_AUTHORS " $\n"
"$URL: www.lua.org $\n";

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 All @@ -123,6 +122,11 @@ LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
}


LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
to->nCcalls = from->nCcalls;
}


LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
lua_CFunction old;
lua_lock(L);
Expand Down Expand Up @@ -199,6 +203,9 @@ LUA_API void lua_insert (lua_State *L, int idx) {
LUA_API void lua_replace (lua_State *L, int idx) {
StkId o;
lua_lock(L);
/* explicit test for incompatible code */
if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
luaG_runerror(L, "no calling environment");
api_checknelems(L, 1);
o = index2adr(L, idx);
api_checkvalidindex(L, o);
Expand Down Expand Up @@ -746,7 +753,7 @@ LUA_API int lua_setfenv (lua_State *L, int idx) {
res = 0;
break;
}
luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
L->top--;
lua_unlock(L);
return res;
Expand Down
2 changes: 1 addition & 1 deletion liblua/lapi.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lapi.h,v 2.2 2005/04/25 19:24:10 roberto Exp $
** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions from Lua API
** See Copyright Notice in lua.h
*/
Expand Down
29 changes: 17 additions & 12 deletions liblua/lauxlib.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp $
** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -123,11 +123,17 @@ LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {

LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
void *p = lua_touserdata(L, ud);
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
luaL_typerror(L, ud, tname);
lua_pop(L, 2); /* remove both metatables */
return p;
if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
lua_pop(L, 2); /* remove both metatables */
return p;
}
}
}
luaL_typerror(L, ud, tname); /* else error */
return NULL; /* to avoid warnings */
}


Expand Down Expand Up @@ -238,7 +244,7 @@ LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
if (libname) {
int size = libsize(l);
/* check whether lib already exists */
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", size);
luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1);
lua_getfield(L, -1, libname); /* get _LOADED[libname] */
if (!lua_istable(L, -1)) { /* not found? */
lua_pop(L, 1); /* remove previous result */
Expand Down Expand Up @@ -529,7 +535,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
return "\n";
}
if (feof(lf->f)) return NULL;
*size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f);
*size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
return (*size > 0) ? lf->buff : NULL;
}

Expand Down Expand Up @@ -564,9 +570,8 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
if (c == '\n') c = getc(lf.f);
}
if (c == LUA_SIGNATURE[0] && lf.f != stdin) { /* binary file? */
fclose(lf.f);
lf.f = fopen(filename, "rb"); /* reopen in binary mode */
if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
/* skip eventual `#!...' */
while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
Expand All @@ -575,7 +580,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
ungetc(c, lf.f);
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
readstatus = ferror(lf.f);
if (lf.f != stdin) fclose(lf.f); /* close file (even in case of errors) */
if (filename) fclose(lf.f); /* close file (even in case of errors) */
if (readstatus) {
lua_settop(L, fnameindex); /* ignore results from `lua_load' */
return errfile(L, "read", fnameindex);
Expand Down
8 changes: 5 additions & 3 deletions liblua/lauxlib.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** $Id: lauxlib.h,v 1.87 2005/12/29 15:32:11 roberto Exp $
** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
Expand Down Expand Up @@ -108,9 +108,11 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,

#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))

#define luaL_dofile(L, fn) (luaL_loadfile(L, fn) || lua_pcall(L, 0, 0, 0))
#define luaL_dofile(L, fn) \
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))

#define luaL_dostring(L, s) (luaL_loadstring(L, s) || lua_pcall(L, 0, 0, 0))
#define luaL_dostring(L, s) \
(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))

#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))

Expand Down
Loading

0 comments on commit 21a2e7a

Please sign in to comment.