From 91c98e615b40bd51c04ede5172d785b3be78ea4d Mon Sep 17 00:00:00 2001 From: Tom van Dijck Date: Mon, 5 Oct 2015 10:11:15 -0700 Subject: [PATCH] Move Lua into folder without version, so it's easier to update to a newer version. --- Bootstrap.mak | 18 +- premake4.lua | 14 +- premake5.lua | 14 +- src/host/debug_prompt.c | 2 +- src/host/lua-5.1.4/Makefile | 128 -- src/host/lua-5.1.4/etc/Makefile | 44 - src/host/lua-5.1.4/src/Makefile | 182 --- src/host/{lua-5.1.4 => lua}/COPYRIGHT | 0 src/host/{lua-5.1.4 => lua}/HISTORY | 0 src/host/{lua-5.1.4 => lua}/INSTALL | 0 src/host/{lua-5.1.4 => lua}/README | 0 src/host/{lua-5.1.4 => lua}/doc/amazon.gif | Bin src/host/{lua-5.1.4 => lua}/doc/contents.html | 0 src/host/{lua-5.1.4 => lua}/doc/cover.png | Bin src/host/{lua-5.1.4 => lua}/doc/logo.gif | Bin src/host/{lua-5.1.4 => lua}/doc/lua.1 | 0 src/host/{lua-5.1.4 => lua}/doc/lua.css | 0 src/host/{lua-5.1.4 => lua}/doc/lua.html | 0 src/host/{lua-5.1.4 => lua}/doc/luac.1 | 0 src/host/{lua-5.1.4 => lua}/doc/luac.html | 0 src/host/{lua-5.1.4 => lua}/doc/manual.css | 0 src/host/{lua-5.1.4 => lua}/doc/manual.html | 0 src/host/{lua-5.1.4 => lua}/doc/readme.html | 0 src/host/{lua-5.1.4 => lua}/etc/README | 0 src/host/{lua-5.1.4 => lua}/etc/all.c | 0 src/host/{lua-5.1.4 => lua}/etc/lua.hpp | 0 src/host/{lua-5.1.4 => lua}/etc/lua.ico | Bin src/host/{lua-5.1.4 => lua}/etc/lua.pc | 0 src/host/{lua-5.1.4 => lua}/etc/luavs.bat | 56 +- src/host/{lua-5.1.4 => lua}/etc/min.c | 0 src/host/{lua-5.1.4 => lua}/etc/noparser.c | 0 src/host/{lua-5.1.4 => lua}/etc/strict.lua | 0 src/host/{lua-5.1.4 => lua}/src/lapi.c | 0 src/host/{lua-5.1.4 => lua}/src/lapi.h | 0 src/host/{lua-5.1.4 => lua}/src/lauxlib.c | 1316 ++++++++--------- src/host/{lua-5.1.4 => lua}/src/lauxlib.h | 0 src/host/{lua-5.1.4 => lua}/src/lbaselib.c | 0 src/host/{lua-5.1.4 => lua}/src/lcode.c | 0 src/host/{lua-5.1.4 => lua}/src/lcode.h | 0 src/host/{lua-5.1.4 => lua}/src/ldblib.c | 0 src/host/{lua-5.1.4 => lua}/src/ldebug.c | 0 src/host/{lua-5.1.4 => lua}/src/ldebug.h | 0 src/host/{lua-5.1.4 => lua}/src/ldo.c | 0 src/host/{lua-5.1.4 => lua}/src/ldo.h | 0 src/host/{lua-5.1.4 => lua}/src/ldump.c | 0 src/host/{lua-5.1.4 => lua}/src/lfunc.c | 0 src/host/{lua-5.1.4 => lua}/src/lfunc.h | 0 src/host/{lua-5.1.4 => lua}/src/lgc.c | 0 src/host/{lua-5.1.4 => lua}/src/lgc.h | 0 src/host/{lua-5.1.4 => lua}/src/linit.c | 0 src/host/{lua-5.1.4 => lua}/src/liolib.c | 0 src/host/{lua-5.1.4 => lua}/src/llex.c | 0 src/host/{lua-5.1.4 => lua}/src/llex.h | 0 src/host/{lua-5.1.4 => lua}/src/llimits.h | 0 src/host/{lua-5.1.4 => lua}/src/lmathlib.c | 0 src/host/{lua-5.1.4 => lua}/src/lmem.c | 0 src/host/{lua-5.1.4 => lua}/src/lmem.h | 0 src/host/{lua-5.1.4 => lua}/src/loadlib.c | 0 src/host/{lua-5.1.4 => lua}/src/lobject.c | 0 src/host/{lua-5.1.4 => lua}/src/lobject.h | 0 src/host/{lua-5.1.4 => lua}/src/lopcodes.c | 0 src/host/{lua-5.1.4 => lua}/src/lopcodes.h | 0 src/host/{lua-5.1.4 => lua}/src/loslib.c | 0 src/host/{lua-5.1.4 => lua}/src/lparser.c | 0 src/host/{lua-5.1.4 => lua}/src/lparser.h | 0 src/host/{lua-5.1.4 => lua}/src/lstate.c | 0 src/host/{lua-5.1.4 => lua}/src/lstate.h | 0 src/host/{lua-5.1.4 => lua}/src/lstring.c | 0 src/host/{lua-5.1.4 => lua}/src/lstring.h | 0 src/host/{lua-5.1.4 => lua}/src/lstrlib.c | 0 src/host/{lua-5.1.4 => lua}/src/ltable.c | 0 src/host/{lua-5.1.4 => lua}/src/ltable.h | 0 src/host/{lua-5.1.4 => lua}/src/ltablib.c | 0 src/host/{lua-5.1.4 => lua}/src/ltm.c | 0 src/host/{lua-5.1.4 => lua}/src/ltm.h | 0 src/host/{lua-5.1.4 => lua}/src/lua.c | 0 src/host/{lua-5.1.4 => lua}/src/lua.h | 0 src/host/{lua-5.1.4 => lua}/src/luac.c | 0 src/host/{lua-5.1.4 => lua}/src/luaconf.h | 0 src/host/{lua-5.1.4 => lua}/src/lualib.h | 0 src/host/{lua-5.1.4 => lua}/src/lundump.c | 0 src/host/{lua-5.1.4 => lua}/src/lundump.h | 0 src/host/{lua-5.1.4 => lua}/src/lvm.c | 0 src/host/{lua-5.1.4 => lua}/src/lvm.h | 0 src/host/{lua-5.1.4 => lua}/src/lzio.c | 0 src/host/{lua-5.1.4 => lua}/src/lzio.h | 0 src/host/{lua-5.1.4 => lua}/src/print.c | 0 src/host/{lua-5.1.4 => lua}/test/README | 0 src/host/{lua-5.1.4 => lua}/test/bisect.lua | 0 src/host/{lua-5.1.4 => lua}/test/cf.lua | 0 src/host/{lua-5.1.4 => lua}/test/echo.lua | 0 src/host/{lua-5.1.4 => lua}/test/env.lua | 0 .../{lua-5.1.4 => lua}/test/factorial.lua | 0 src/host/{lua-5.1.4 => lua}/test/fib.lua | 0 src/host/{lua-5.1.4 => lua}/test/fibfor.lua | 0 src/host/{lua-5.1.4 => lua}/test/globals.lua | 0 src/host/{lua-5.1.4 => lua}/test/hello.lua | 0 src/host/{lua-5.1.4 => lua}/test/life.lua | 0 src/host/{lua-5.1.4 => lua}/test/luac.lua | 0 src/host/{lua-5.1.4 => lua}/test/printf.lua | 0 src/host/{lua-5.1.4 => lua}/test/readonly.lua | 0 src/host/{lua-5.1.4 => lua}/test/sieve.lua | 0 src/host/{lua-5.1.4 => lua}/test/sort.lua | 0 src/host/{lua-5.1.4 => lua}/test/table.lua | 0 .../{lua-5.1.4 => lua}/test/trace-calls.lua | 0 .../{lua-5.1.4 => lua}/test/trace-globals.lua | 0 src/host/{lua-5.1.4 => lua}/test/xd.lua | 0 src/host/lua_auxlib.c | 2 +- 108 files changed, 711 insertions(+), 1065 deletions(-) delete mode 100644 src/host/lua-5.1.4/Makefile delete mode 100644 src/host/lua-5.1.4/etc/Makefile delete mode 100644 src/host/lua-5.1.4/src/Makefile rename src/host/{lua-5.1.4 => lua}/COPYRIGHT (100%) rename src/host/{lua-5.1.4 => lua}/HISTORY (100%) rename src/host/{lua-5.1.4 => lua}/INSTALL (100%) rename src/host/{lua-5.1.4 => lua}/README (100%) rename src/host/{lua-5.1.4 => lua}/doc/amazon.gif (100%) rename src/host/{lua-5.1.4 => lua}/doc/contents.html (100%) rename src/host/{lua-5.1.4 => lua}/doc/cover.png (100%) rename src/host/{lua-5.1.4 => lua}/doc/logo.gif (100%) rename src/host/{lua-5.1.4 => lua}/doc/lua.1 (100%) rename src/host/{lua-5.1.4 => lua}/doc/lua.css (100%) rename src/host/{lua-5.1.4 => lua}/doc/lua.html (100%) rename src/host/{lua-5.1.4 => lua}/doc/luac.1 (100%) rename src/host/{lua-5.1.4 => lua}/doc/luac.html (100%) rename src/host/{lua-5.1.4 => lua}/doc/manual.css (100%) rename src/host/{lua-5.1.4 => lua}/doc/manual.html (100%) rename src/host/{lua-5.1.4 => lua}/doc/readme.html (100%) rename src/host/{lua-5.1.4 => lua}/etc/README (100%) rename src/host/{lua-5.1.4 => lua}/etc/all.c (100%) rename src/host/{lua-5.1.4 => lua}/etc/lua.hpp (100%) rename src/host/{lua-5.1.4 => lua}/etc/lua.ico (100%) rename src/host/{lua-5.1.4 => lua}/etc/lua.pc (100%) rename src/host/{lua-5.1.4 => lua}/etc/luavs.bat (97%) rename src/host/{lua-5.1.4 => lua}/etc/min.c (100%) rename src/host/{lua-5.1.4 => lua}/etc/noparser.c (100%) rename src/host/{lua-5.1.4 => lua}/etc/strict.lua (100%) rename src/host/{lua-5.1.4 => lua}/src/lapi.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lapi.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lauxlib.c (96%) rename src/host/{lua-5.1.4 => lua}/src/lauxlib.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lbaselib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lcode.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lcode.h (100%) rename src/host/{lua-5.1.4 => lua}/src/ldblib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/ldebug.c (100%) rename src/host/{lua-5.1.4 => lua}/src/ldebug.h (100%) rename src/host/{lua-5.1.4 => lua}/src/ldo.c (100%) rename src/host/{lua-5.1.4 => lua}/src/ldo.h (100%) rename src/host/{lua-5.1.4 => lua}/src/ldump.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lfunc.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lfunc.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lgc.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lgc.h (100%) rename src/host/{lua-5.1.4 => lua}/src/linit.c (100%) rename src/host/{lua-5.1.4 => lua}/src/liolib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/llex.c (100%) rename src/host/{lua-5.1.4 => lua}/src/llex.h (100%) rename src/host/{lua-5.1.4 => lua}/src/llimits.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lmathlib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lmem.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lmem.h (100%) rename src/host/{lua-5.1.4 => lua}/src/loadlib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lobject.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lobject.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lopcodes.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lopcodes.h (100%) rename src/host/{lua-5.1.4 => lua}/src/loslib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lparser.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lparser.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lstate.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lstate.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lstring.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lstring.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lstrlib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/ltable.c (100%) rename src/host/{lua-5.1.4 => lua}/src/ltable.h (100%) rename src/host/{lua-5.1.4 => lua}/src/ltablib.c (100%) rename src/host/{lua-5.1.4 => lua}/src/ltm.c (100%) rename src/host/{lua-5.1.4 => lua}/src/ltm.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lua.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lua.h (100%) rename src/host/{lua-5.1.4 => lua}/src/luac.c (100%) rename src/host/{lua-5.1.4 => lua}/src/luaconf.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lualib.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lundump.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lundump.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lvm.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lvm.h (100%) rename src/host/{lua-5.1.4 => lua}/src/lzio.c (100%) rename src/host/{lua-5.1.4 => lua}/src/lzio.h (100%) rename src/host/{lua-5.1.4 => lua}/src/print.c (100%) rename src/host/{lua-5.1.4 => lua}/test/README (100%) rename src/host/{lua-5.1.4 => lua}/test/bisect.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/cf.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/echo.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/env.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/factorial.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/fib.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/fibfor.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/globals.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/hello.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/life.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/luac.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/printf.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/readonly.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/sieve.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/sort.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/table.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/trace-calls.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/trace-globals.lua (100%) rename src/host/{lua-5.1.4 => lua}/test/xd.lua (100%) diff --git a/Bootstrap.mak b/Bootstrap.mak index 8aaff28d..92031b33 100644 --- a/Bootstrap.mak +++ b/Bootstrap.mak @@ -1,23 +1,23 @@ -LUA_DIR=src/host/lua-5.1.4/src +LUA_DIR=src/host/lua/src -SRC= src/host/*.c \ +SRC= src/host/*.c \ $(LUA_DIR)/lapi.c \ $(LUA_DIR)/lcode.c \ $(LUA_DIR)/ldebug.c \ $(LUA_DIR)/ldump.c \ -$(LUA_DIR)/lgc.c \ +$(LUA_DIR)/lgc.c \ $(LUA_DIR)/liolib.c \ -$(LUA_DIR)/lmathlib.c \ +$(LUA_DIR)/lmathlib.c \ $(LUA_DIR)/loadlib.c \ -$(LUA_DIR)/lopcodes.c \ +$(LUA_DIR)/lopcodes.c \ $(LUA_DIR)/lparser.c \ $(LUA_DIR)/lstring.c \ $(LUA_DIR)/ltable.c \ -$(LUA_DIR)/ltm.c \ -$(LUA_DIR)/lvm.c \ -$(LUA_DIR)/lbaselib.c \ +$(LUA_DIR)/ltm.c \ +$(LUA_DIR)/lvm.c \ +$(LUA_DIR)/lbaselib.c \ $(LUA_DIR)/ldblib.c \ -$(LUA_DIR)/ldo.c \ +$(LUA_DIR)/ldo.c \ $(LUA_DIR)/lfunc.c \ $(LUA_DIR)/linit.c \ $(LUA_DIR)/llex.c \ diff --git a/premake4.lua b/premake4.lua index 3d5c5956..1f6284aa 100644 --- a/premake4.lua +++ b/premake4.lua @@ -18,7 +18,7 @@ language "C" kind "ConsoleApp" flags { "No64BitChecks", "ExtraWarnings", "StaticRuntime" } - includedirs { "src/host/lua-5.1.4/src" } + includedirs { "src/host/lua/src" } files { @@ -29,12 +29,12 @@ excludes { - "src/host/lua-5.1.4/src/lauxlib.c", - "src/host/lua-5.1.4/src/lua.c", - "src/host/lua-5.1.4/src/luac.c", - "src/host/lua-5.1.4/src/print.c", - "src/host/lua-5.1.4/**.lua", - "src/host/lua-5.1.4/etc/*.c" + "src/host/lua/src/lauxlib.c", + "src/host/lua/src/lua.c", + "src/host/lua/src/luac.c", + "src/host/lua/src/print.c", + "src/host/lua/**.lua", + "src/host/lua/etc/*.c" } configuration "Debug" diff --git a/premake5.lua b/premake5.lua index 2c00e000..b06fd511 100644 --- a/premake5.lua +++ b/premake5.lua @@ -92,7 +92,7 @@ language "C" kind "ConsoleApp" flags { "No64BitChecks", "ExtraWarnings", "StaticRuntime" } - includedirs { "src/host/lua-5.1.4/src" } + includedirs { "src/host/lua/src" } -- optional 3rd party libraries if not _OPTIONS["no-zlib"] then @@ -115,12 +115,12 @@ excludes { - "src/host/lua-5.1.4/src/lauxlib.c", - "src/host/lua-5.1.4/src/lua.c", - "src/host/lua-5.1.4/src/luac.c", - "src/host/lua-5.1.4/src/print.c", - "src/host/lua-5.1.4/**.lua", - "src/host/lua-5.1.4/etc/*.c" + "src/host/lua/src/lauxlib.c", + "src/host/lua/src/lua.c", + "src/host/lua/src/luac.c", + "src/host/lua/src/print.c", + "src/host/lua/**.lua", + "src/host/lua/etc/*.c" } configuration "Debug" diff --git a/src/host/debug_prompt.c b/src/host/debug_prompt.c index 890ebd76..a1fe19e5 100644 --- a/src/host/debug_prompt.c +++ b/src/host/debug_prompt.c @@ -8,7 +8,7 @@ /* Build on the REPL built into Lua already */ #define main lua_main -#include "lua-5.1.4/src/lua.c" +#include "lua/src/lua.c" /* Based on dotty() in lua.c */ diff --git a/src/host/lua-5.1.4/Makefile b/src/host/lua-5.1.4/Makefile deleted file mode 100644 index 6e78f66f..00000000 --- a/src/host/lua-5.1.4/Makefile +++ /dev/null @@ -1,128 +0,0 @@ -# makefile for installing Lua -# see INSTALL for installation instructions -# see src/Makefile and src/luaconf.h for further customization - -# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= - -# Your platform. See PLATS for possible values. -PLAT= none - -# 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 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. -MKDIR= mkdir -p -RANLIB= ranlib - -# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= - -# Convenience platforms targets. -PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris - -# What to install. -TO_BIN= lua luac -TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp -TO_LIB= liblua.a -TO_MAN= lua.1 luac.1 - -# Lua version and release. -V= 5.1 -R= 5.1.4 - -all: $(PLAT) - -$(PLATS) clean: - cd src && $(MAKE) $@ - -test: dummy - src/lua test/hello.lua - -install: dummy - 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=.. - -none: - @echo "Please do" - @echo " make PLATFORM" - @echo "where PLATFORM is one of these:" - @echo " $(PLATS)" - @echo "See INSTALL for complete instructions." - -# make may get confused with test/ and INSTALL in a case-insensitive OS -dummy: - -# echo config parameters -echo: - @echo "" - @echo "These are the parameters currently set in src/Makefile to build Lua $R:" - @echo "" - @cd src && $(MAKE) -s echo - @echo "" - @echo "These are the parameters currently set in Makefile to install Lua $R:" - @echo "" - @echo "PLAT = $(PLAT)" - @echo "INSTALL_TOP = $(INSTALL_TOP)" - @echo "INSTALL_BIN = $(INSTALL_BIN)" - @echo "INSTALL_INC = $(INSTALL_INC)" - @echo "INSTALL_LIB = $(INSTALL_LIB)" - @echo "INSTALL_MAN = $(INSTALL_MAN)" - @echo "INSTALL_LMOD = $(INSTALL_LMOD)" - @echo "INSTALL_CMOD = $(INSTALL_CMOD)" - @echo "INSTALL_EXEC = $(INSTALL_EXEC)" - @echo "INSTALL_DATA = $(INSTALL_DATA)" - @echo "" - @echo "See also src/luaconf.h ." - @echo "" - -# echo private config parameters -pecho: - @echo "V = $(V)" - @echo "R = $(R)" - @echo "TO_BIN = $(TO_BIN)" - @echo "TO_INC = $(TO_INC)" - @echo "TO_LIB = $(TO_LIB)" - @echo "TO_MAN = $(TO_MAN)" - -# echo config parameters as Lua code -# uncomment the last sed expression if you want nil instead of empty strings -lecho: - @echo "-- installation parameters for Lua $R" - @echo "VERSION = '$V'" - @echo "RELEASE = '$R'" - @$(MAKE) echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/' - @echo "-- EOF" - -# list targets that do not create files (but not all makes understand .PHONY) -.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho - -# (end of Makefile) diff --git a/src/host/lua-5.1.4/etc/Makefile b/src/host/lua-5.1.4/etc/Makefile deleted file mode 100644 index 6d00008d..00000000 --- a/src/host/lua-5.1.4/etc/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# makefile for Lua etc - -TOP= .. -LIB= $(TOP)/src -INC= $(TOP)/src -BIN= $(TOP)/src -SRC= $(TOP)/src -TST= $(TOP)/test - -CC= gcc -CFLAGS= -O2 -Wall -I$(INC) $(MYCFLAGS) -MYCFLAGS= -MYLDFLAGS= -Wl,-E -MYLIBS= -lm -#MYLIBS= -lm -Wl,-E -ldl -lreadline -lhistory -lncurses -RM= rm -f - -default: - @echo 'Please choose a target: min noparser one strict clean' - -min: min.c - $(CC) $(CFLAGS) $@.c -L$(LIB) -llua $(MYLIBS) - echo 'print"Hello there!"' | ./a.out - -noparser: noparser.o - $(CC) noparser.o $(SRC)/lua.o -L$(LIB) -llua $(MYLIBS) - $(BIN)/luac $(TST)/hello.lua - -./a.out luac.out - -./a.out -e'a=1' - -one: - $(CC) $(CFLAGS) all.c $(MYLIBS) - ./a.out $(TST)/hello.lua - -strict: - -$(BIN)/lua -e 'print(a);b=2' - -$(BIN)/lua -lstrict -e 'print(a)' - -$(BIN)/lua -e 'function f() b=2 end f()' - -$(BIN)/lua -lstrict -e 'function f() b=2 end f()' - -clean: - $(RM) a.out core core.* *.o luac.out - -.PHONY: default min noparser one strict clean diff --git a/src/host/lua-5.1.4/src/Makefile b/src/host/lua-5.1.4/src/Makefile deleted file mode 100644 index e4a3cd61..00000000 --- a/src/host/lua-5.1.4/src/Makefile +++ /dev/null @@ -1,182 +0,0 @@ -# makefile for building Lua -# see ../INSTALL for installation instructions -# see ../Makefile and luaconf.h for further customization - -# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= - -# Your platform. See PLATS for possible values. -PLAT= none - -CC= gcc -CFLAGS= -O2 -Wall $(MYCFLAGS) -AR= ar rcu -RANLIB= ranlib -RM= rm -f -LIBS= -lm $(MYLIBS) - -MYCFLAGS= -MYLDFLAGS= -MYLIBS= - -# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= - -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 \ - lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \ - lundump.o lvm.o lzio.o -LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ - lstrlib.o loadlib.o linit.o - -LUA_T= lua -LUA_O= lua.o - -LUAC_T= luac -LUAC_O= luac.o print.o - -ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O) -ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) -ALL_A= $(LUA_A) - -default: $(PLAT) - -all: $(ALL_T) - -o: $(ALL_O) - -a: $(ALL_A) - -$(LUA_A): $(CORE_O) $(LIB_O) - $(AR) $@ $? - $(RANLIB) $@ - -$(LUA_T): $(LUA_O) $(LUA_A) - $(CC) -o $@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) - -$(LUAC_T): $(LUAC_O) $(LUA_A) - $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) - -clean: - $(RM) $(ALL_T) $(ALL_O) - -depend: - @$(CC) $(CFLAGS) -MM l*.c print.c - -echo: - @echo "PLAT = $(PLAT)" - @echo "CC = $(CC)" - @echo "CFLAGS = $(CFLAGS)" - @echo "AR = $(AR)" - @echo "RANLIB = $(RANLIB)" - @echo "RM = $(RM)" - @echo "MYCFLAGS = $(MYCFLAGS)" - @echo "MYLDFLAGS = $(MYLDFLAGS)" - @echo "MYLIBS = $(MYLIBS)" - -# convenience targets for popular platforms - -none: - @echo "Please choose a platform:" - @echo " $(PLATS)" - -aix: - $(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_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 - -solaris: - $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" - -# list targets that do not create files (but not all makes understand .PHONY) -.PHONY: all $(PLATS) default o a clean depend echo none - -# DO NOT DELETE - -lapi.o: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \ - lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \ - lundump.h lvm.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 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 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 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 \ - lstate.h ltm.h lzio.h -lgc.o: lgc.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 lstring.h ltable.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 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 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 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 \ - ltm.h lzio.h lstring.h lgc.h -lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h -ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h -ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h -ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \ - lmem.h lstring.h lgc.h ltable.h -lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h -luac.o: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \ - lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \ - lundump.h -lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \ - llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h -lvm.o: lvm.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 lstring.h ltable.h lvm.h -lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \ - lzio.h -print.o: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \ - ltm.h lzio.h lmem.h lopcodes.h lundump.h - -# (end of Makefile) diff --git a/src/host/lua-5.1.4/COPYRIGHT b/src/host/lua/COPYRIGHT similarity index 100% rename from src/host/lua-5.1.4/COPYRIGHT rename to src/host/lua/COPYRIGHT diff --git a/src/host/lua-5.1.4/HISTORY b/src/host/lua/HISTORY similarity index 100% rename from src/host/lua-5.1.4/HISTORY rename to src/host/lua/HISTORY diff --git a/src/host/lua-5.1.4/INSTALL b/src/host/lua/INSTALL similarity index 100% rename from src/host/lua-5.1.4/INSTALL rename to src/host/lua/INSTALL diff --git a/src/host/lua-5.1.4/README b/src/host/lua/README similarity index 100% rename from src/host/lua-5.1.4/README rename to src/host/lua/README diff --git a/src/host/lua-5.1.4/doc/amazon.gif b/src/host/lua/doc/amazon.gif similarity index 100% rename from src/host/lua-5.1.4/doc/amazon.gif rename to src/host/lua/doc/amazon.gif diff --git a/src/host/lua-5.1.4/doc/contents.html b/src/host/lua/doc/contents.html similarity index 100% rename from src/host/lua-5.1.4/doc/contents.html rename to src/host/lua/doc/contents.html diff --git a/src/host/lua-5.1.4/doc/cover.png b/src/host/lua/doc/cover.png similarity index 100% rename from src/host/lua-5.1.4/doc/cover.png rename to src/host/lua/doc/cover.png diff --git a/src/host/lua-5.1.4/doc/logo.gif b/src/host/lua/doc/logo.gif similarity index 100% rename from src/host/lua-5.1.4/doc/logo.gif rename to src/host/lua/doc/logo.gif diff --git a/src/host/lua-5.1.4/doc/lua.1 b/src/host/lua/doc/lua.1 similarity index 100% rename from src/host/lua-5.1.4/doc/lua.1 rename to src/host/lua/doc/lua.1 diff --git a/src/host/lua-5.1.4/doc/lua.css b/src/host/lua/doc/lua.css similarity index 100% rename from src/host/lua-5.1.4/doc/lua.css rename to src/host/lua/doc/lua.css diff --git a/src/host/lua-5.1.4/doc/lua.html b/src/host/lua/doc/lua.html similarity index 100% rename from src/host/lua-5.1.4/doc/lua.html rename to src/host/lua/doc/lua.html diff --git a/src/host/lua-5.1.4/doc/luac.1 b/src/host/lua/doc/luac.1 similarity index 100% rename from src/host/lua-5.1.4/doc/luac.1 rename to src/host/lua/doc/luac.1 diff --git a/src/host/lua-5.1.4/doc/luac.html b/src/host/lua/doc/luac.html similarity index 100% rename from src/host/lua-5.1.4/doc/luac.html rename to src/host/lua/doc/luac.html diff --git a/src/host/lua-5.1.4/doc/manual.css b/src/host/lua/doc/manual.css similarity index 100% rename from src/host/lua-5.1.4/doc/manual.css rename to src/host/lua/doc/manual.css diff --git a/src/host/lua-5.1.4/doc/manual.html b/src/host/lua/doc/manual.html similarity index 100% rename from src/host/lua-5.1.4/doc/manual.html rename to src/host/lua/doc/manual.html diff --git a/src/host/lua-5.1.4/doc/readme.html b/src/host/lua/doc/readme.html similarity index 100% rename from src/host/lua-5.1.4/doc/readme.html rename to src/host/lua/doc/readme.html diff --git a/src/host/lua-5.1.4/etc/README b/src/host/lua/etc/README similarity index 100% rename from src/host/lua-5.1.4/etc/README rename to src/host/lua/etc/README diff --git a/src/host/lua-5.1.4/etc/all.c b/src/host/lua/etc/all.c similarity index 100% rename from src/host/lua-5.1.4/etc/all.c rename to src/host/lua/etc/all.c diff --git a/src/host/lua-5.1.4/etc/lua.hpp b/src/host/lua/etc/lua.hpp similarity index 100% rename from src/host/lua-5.1.4/etc/lua.hpp rename to src/host/lua/etc/lua.hpp diff --git a/src/host/lua-5.1.4/etc/lua.ico b/src/host/lua/etc/lua.ico similarity index 100% rename from src/host/lua-5.1.4/etc/lua.ico rename to src/host/lua/etc/lua.ico diff --git a/src/host/lua-5.1.4/etc/lua.pc b/src/host/lua/etc/lua.pc similarity index 100% rename from src/host/lua-5.1.4/etc/lua.pc rename to src/host/lua/etc/lua.pc diff --git a/src/host/lua-5.1.4/etc/luavs.bat b/src/host/lua/etc/luavs.bat similarity index 97% rename from src/host/lua-5.1.4/etc/luavs.bat rename to src/host/lua/etc/luavs.bat index 08c2bedd..054b4625 100644 --- a/src/host/lua-5.1.4/etc/luavs.bat +++ b/src/host/lua/etc/luavs.bat @@ -1,28 +1,28 @@ -@rem Script to build Lua under "Visual Studio .NET Command Prompt". -@rem Do not run from this directory; run it from the toplevel: etc\luavs.bat . -@rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src. -@rem (contributed by David Manura and Mike Pall) - -@setlocal -@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE -@set MYLINK=link /nologo -@set MYMT=mt /nologo - -cd src -%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c -del lua.obj luac.obj -%MYLINK% /DLL /out:lua51.dll l*.obj -if exist lua51.dll.manifest^ - %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 -%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c -%MYLINK% /out:lua.exe lua.obj lua51.lib -if exist lua.exe.manifest^ - %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe -%MYCOMPILE% l*.c print.c -del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^ - loslib.obj ltablib.obj lstrlib.obj loadlib.obj -%MYLINK% /out:luac.exe *.obj -if exist luac.exe.manifest^ - %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe -del *.obj *.manifest -cd .. +@rem Script to build Lua under "Visual Studio .NET Command Prompt". +@rem Do not run from this directory; run it from the toplevel: etc\luavs.bat . +@rem It creates lua51.dll, lua51.lib, lua.exe, and luac.exe in src. +@rem (contributed by David Manura and Mike Pall) + +@setlocal +@set MYCOMPILE=cl /nologo /MD /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE +@set MYLINK=link /nologo +@set MYMT=mt /nologo + +cd src +%MYCOMPILE% /DLUA_BUILD_AS_DLL l*.c +del lua.obj luac.obj +%MYLINK% /DLL /out:lua51.dll l*.obj +if exist lua51.dll.manifest^ + %MYMT% -manifest lua51.dll.manifest -outputresource:lua51.dll;2 +%MYCOMPILE% /DLUA_BUILD_AS_DLL lua.c +%MYLINK% /out:lua.exe lua.obj lua51.lib +if exist lua.exe.manifest^ + %MYMT% -manifest lua.exe.manifest -outputresource:lua.exe +%MYCOMPILE% l*.c print.c +del lua.obj linit.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj^ + loslib.obj ltablib.obj lstrlib.obj loadlib.obj +%MYLINK% /out:luac.exe *.obj +if exist luac.exe.manifest^ + %MYMT% -manifest luac.exe.manifest -outputresource:luac.exe +del *.obj *.manifest +cd .. diff --git a/src/host/lua-5.1.4/etc/min.c b/src/host/lua/etc/min.c similarity index 100% rename from src/host/lua-5.1.4/etc/min.c rename to src/host/lua/etc/min.c diff --git a/src/host/lua-5.1.4/etc/noparser.c b/src/host/lua/etc/noparser.c similarity index 100% rename from src/host/lua-5.1.4/etc/noparser.c rename to src/host/lua/etc/noparser.c diff --git a/src/host/lua-5.1.4/etc/strict.lua b/src/host/lua/etc/strict.lua similarity index 100% rename from src/host/lua-5.1.4/etc/strict.lua rename to src/host/lua/etc/strict.lua diff --git a/src/host/lua-5.1.4/src/lapi.c b/src/host/lua/src/lapi.c similarity index 100% rename from src/host/lua-5.1.4/src/lapi.c rename to src/host/lua/src/lapi.c diff --git a/src/host/lua-5.1.4/src/lapi.h b/src/host/lua/src/lapi.h similarity index 100% rename from src/host/lua-5.1.4/src/lapi.h rename to src/host/lua/src/lapi.h diff --git a/src/host/lua-5.1.4/src/lauxlib.c b/src/host/lua/src/lauxlib.c similarity index 96% rename from src/host/lua-5.1.4/src/lauxlib.c rename to src/host/lua/src/lauxlib.c index c1618e34..e51f8cab 100644 --- a/src/host/lua-5.1.4/src/lauxlib.c +++ b/src/host/lua/src/lauxlib.c @@ -1,658 +1,658 @@ -/* -** $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 -*/ - - -#include -#include -#include -#include -#include -#include - - -/* This file uses only the official API of Lua. -** Any function declared here could be written as an application function. -*/ - -#define lauxlib_c -#define LUA_LIB - -#include "lua.h" - -#include "lauxlib.h" - - -#define FREELIST_REF 0 /* free list of references */ - - -/* convert a stack index to positive */ -#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ - lua_gettop(L) + (i) + 1) - - -/* -** {====================================================== -** Error-report functions -** ======================================================= -*/ - - -LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { - lua_Debug ar; - if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ - return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); - lua_getinfo(L, "n", &ar); - if (strcmp(ar.namewhat, "method") == 0) { - narg--; /* do not count `self' */ - if (narg == 0) /* error is in the self argument itself? */ - return luaL_error(L, "calling " LUA_QS " on bad self (%s)", - ar.name, extramsg); - } - if (ar.name == NULL) - ar.name = "?"; - return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", - narg, ar.name, extramsg); -} - - -LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { - const char *msg = lua_pushfstring(L, "%s expected, got %s", - tname, luaL_typename(L, narg)); - return luaL_argerror(L, narg, msg); -} - - -static void tag_error (lua_State *L, int narg, int tag) { - luaL_typerror(L, narg, lua_typename(L, tag)); -} - - -LUALIB_API void luaL_where (lua_State *L, int level) { - lua_Debug ar; - if (lua_getstack(L, level, &ar)) { /* check function at level */ - lua_getinfo(L, "Sl", &ar); /* get info about it */ - if (ar.currentline > 0) { /* is there info? */ - lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); - return; - } - } - lua_pushliteral(L, ""); /* else, no information available... */ -} - - -#ifdef _MANAGED - #pragma managed(push, off) -#endif -LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { - va_list argp; - va_start(argp, fmt); - luaL_where(L, 1); - lua_pushvfstring(L, fmt, argp); - va_end(argp); - lua_concat(L, 2); - return lua_error(L); -} -#ifdef _MANAGED - #pragma managed(pop) -#endif - -/* }====================================================== */ - - -LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, - const char *const lst[]) { - const char *name = (def) ? luaL_optstring(L, narg, def) : - luaL_checkstring(L, narg); - int i; - for (i=0; lst[i]; i++) - if (strcmp(lst[i], name) == 0) - return i; - return luaL_argerror(L, narg, - lua_pushfstring(L, "invalid option " LUA_QS, name)); -} - - -LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { - lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ - if (!lua_isnil(L, -1)) /* name already in use? */ - return 0; /* leave previous value on top, but return 0 */ - lua_pop(L, 1); - lua_newtable(L); /* create metatable */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ - return 1; -} - - -LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { - void *p = lua_touserdata(L, ud); - 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 */ -} - - -LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { - if (!lua_checkstack(L, space)) - luaL_error(L, "stack overflow (%s)", mes); -} - - -LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { - if (lua_type(L, narg) != t) - tag_error(L, narg, t); -} - - -LUALIB_API void luaL_checkany (lua_State *L, int narg) { - if (lua_type(L, narg) == LUA_TNONE) - luaL_argerror(L, narg, "value expected"); -} - - -LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { - const char *s = lua_tolstring(L, narg, len); - if (!s) tag_error(L, narg, LUA_TSTRING); - return s; -} - - -LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, - const char *def, size_t *len) { - if (lua_isnoneornil(L, narg)) { - if (len) - *len = (def ? strlen(def) : 0); - return def; - } - else return luaL_checklstring(L, narg, len); -} - - -LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { - lua_Number d = lua_tonumber(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ - tag_error(L, narg, LUA_TNUMBER); - return d; -} - - -LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { - return luaL_opt(L, luaL_checknumber, narg, def); -} - - -LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { - lua_Integer d = lua_tointeger(L, narg); - if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ - tag_error(L, narg, LUA_TNUMBER); - return d; -} - - -LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, - lua_Integer def) { - return luaL_opt(L, luaL_checkinteger, narg, def); -} - - -LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { - if (!lua_getmetatable(L, obj)) /* no metatable? */ - return 0; - lua_pushstring(L, event); - lua_rawget(L, -2); - if (lua_isnil(L, -1)) { - lua_pop(L, 2); /* remove metatable and metafield */ - return 0; - } - else { - lua_remove(L, -2); /* remove only metatable */ - return 1; - } -} - - -LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { - obj = abs_index(L, obj); - if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ - return 0; - lua_pushvalue(L, obj); - lua_call(L, 1, 1); - return 1; -} - - -LUALIB_API void (luaL_register) (lua_State *L, const char *libname, - const luaL_Reg *l) { - luaI_openlib(L, libname, l, 0); -} - - -static int libsize (const luaL_Reg *l) { - int size = 0; - for (; l->name; l++) size++; - return size; -} - - -LUALIB_API void luaI_openlib (lua_State *L, const char *libname, - const luaL_Reg *l, int nup) { - if (libname) { - int size = libsize(l); - /* check whether lib already exists */ - 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 */ - /* try global variable (and create one if it does not exist) */ - if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) - luaL_error(L, "name conflict for module " LUA_QS, libname); - lua_pushvalue(L, -1); - lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ - } - lua_remove(L, -2); /* remove _LOADED table */ - lua_insert(L, -(nup+1)); /* move library table to below upvalues */ - } - for (; l->name; l++) { - int i; - for (i=0; ifunc, nup); - lua_setfield(L, -(nup+2), l->name); - } - lua_pop(L, nup); /* remove upvalues */ -} - - - -/* -** {====================================================== -** getn-setn: size for arrays -** ======================================================= -*/ - -#if defined(LUA_COMPAT_GETN) - -static int checkint (lua_State *L, int topop) { - int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; - lua_pop(L, topop); - return n; -} - - -static void getsizes (lua_State *L) { - lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); - if (lua_isnil(L, -1)) { /* no `size' table? */ - lua_pop(L, 1); /* remove nil */ - lua_newtable(L); /* create it */ - lua_pushvalue(L, -1); /* `size' will be its own metatable */ - lua_setmetatable(L, -2); - lua_pushliteral(L, "kv"); - lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ - } -} - - -LUALIB_API void luaL_setn (lua_State *L, int t, int n) { - t = abs_index(L, t); - lua_pushliteral(L, "n"); - lua_rawget(L, t); - if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ - lua_pushliteral(L, "n"); /* use it */ - lua_pushinteger(L, n); - lua_rawset(L, t); - } - else { /* use `sizes' */ - getsizes(L); - lua_pushvalue(L, t); - lua_pushinteger(L, n); - lua_rawset(L, -3); /* sizes[t] = n */ - lua_pop(L, 1); /* remove `sizes' */ - } -} - - -LUALIB_API int luaL_getn (lua_State *L, int t) { - int n; - t = abs_index(L, t); - lua_pushliteral(L, "n"); /* try t.n */ - lua_rawget(L, t); - if ((n = checkint(L, 1)) >= 0) return n; - getsizes(L); /* else try sizes[t] */ - lua_pushvalue(L, t); - lua_rawget(L, -2); - if ((n = checkint(L, 2)) >= 0) return n; - return (int)lua_objlen(L, t); -} - -#endif - -/* }====================================================== */ - - - -LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, - const char *r) { - const char *wild; - size_t l = strlen(p); - luaL_Buffer b; - luaL_buffinit(L, &b); - while ((wild = strstr(s, p)) != NULL) { - luaL_addlstring(&b, s, wild - s); /* push prefix */ - luaL_addstring(&b, r); /* push replacement in place of pattern */ - s = wild + l; /* continue after `p' */ - } - luaL_addstring(&b, s); /* push last suffix */ - luaL_pushresult(&b); - return lua_tostring(L, -1); -} - - -LUALIB_API const char *luaL_findtable (lua_State *L, int idx, - const char *fname, int szhint) { - const char *e; - lua_pushvalue(L, idx); - do { - e = strchr(fname, '.'); - if (e == NULL) e = fname + strlen(fname); - lua_pushlstring(L, fname, e - fname); - lua_rawget(L, -2); - if (lua_isnil(L, -1)) { /* no such field? */ - lua_pop(L, 1); /* remove this nil */ - lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ - lua_pushlstring(L, fname, e - fname); - lua_pushvalue(L, -2); - lua_settable(L, -4); /* set new table into field */ - } - else if (!lua_istable(L, -1)) { /* field has a non-table value? */ - lua_pop(L, 2); /* remove table and value */ - return fname; /* return problematic part of the name */ - } - lua_remove(L, -2); /* remove previous table */ - fname = e + 1; - } while (*e == '.'); - return NULL; -} - - - -/* -** {====================================================== -** Generic Buffer manipulation -** ======================================================= -*/ - - -#define bufflen(B) ((B)->p - (B)->buffer) -#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) - -#define LIMIT (LUA_MINSTACK/2) - - -static int emptybuffer (luaL_Buffer *B) { - size_t l = bufflen(B); - if (l == 0) return 0; /* put nothing on stack */ - else { - lua_pushlstring(B->L, B->buffer, l); - B->p = B->buffer; - B->lvl++; - return 1; - } -} - - -static void adjuststack (luaL_Buffer *B) { - if (B->lvl > 1) { - lua_State *L = B->L; - int toget = 1; /* number of levels to concat */ - size_t toplen = lua_strlen(L, -1); - do { - size_t l = lua_strlen(L, -(toget+1)); - if (B->lvl - toget + 1 >= LIMIT || toplen > l) { - toplen += l; - toget++; - } - else break; - } while (toget < B->lvl); - lua_concat(L, toget); - B->lvl = B->lvl - toget + 1; - } -} - - -LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { - if (emptybuffer(B)) - adjuststack(B); - return B->buffer; -} - - -LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { - while (l--) - luaL_addchar(B, *s++); -} - - -LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { - luaL_addlstring(B, s, strlen(s)); -} - - -LUALIB_API void luaL_pushresult (luaL_Buffer *B) { - emptybuffer(B); - lua_concat(B->L, B->lvl); - B->lvl = 1; -} - - -LUALIB_API void luaL_addvalue (luaL_Buffer *B) { - lua_State *L = B->L; - size_t vl; - const char *s = lua_tolstring(L, -1, &vl); - if (vl <= bufffree(B)) { /* fit into buffer? */ - memcpy(B->p, s, vl); /* put it there */ - B->p += vl; - lua_pop(L, 1); /* remove from stack */ - } - else { - if (emptybuffer(B)) - lua_insert(L, -2); /* put buffer before new value */ - B->lvl++; /* add new value into B stack */ - adjuststack(B); - } -} - - -LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { - B->L = L; - B->p = B->buffer; - B->lvl = 0; -} - -/* }====================================================== */ - - -LUALIB_API int luaL_ref (lua_State *L, int t) { - int ref; - t = abs_index(L, t); - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* remove from stack */ - return LUA_REFNIL; /* `nil' has a unique fixed reference */ - } - lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ - ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ - lua_pop(L, 1); /* remove it from stack */ - if (ref != 0) { /* any free element? */ - lua_rawgeti(L, t, ref); /* remove it from list */ - lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ - } - else { /* no free elements */ - ref = (int)lua_objlen(L, t); - ref++; /* create new reference */ - } - lua_rawseti(L, t, ref); - return ref; -} - - -LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { - if (ref >= 0) { - t = abs_index(L, t); - lua_rawgeti(L, t, FREELIST_REF); - lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ - lua_pushinteger(L, ref); - lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ - } -} - - - -/* -** {====================================================== -** Load functions -** ======================================================= -*/ - -typedef struct LoadF { - int extraline; - FILE *f; - char buff[LUAL_BUFFERSIZE]; -} LoadF; - - -static const char *getF (lua_State *L, void *ud, size_t *size) { - LoadF *lf = (LoadF *)ud; - (void)L; - if (lf->extraline) { - lf->extraline = 0; - *size = 1; - return "\n"; - } - if (feof(lf->f)) return NULL; - *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); - return (*size > 0) ? lf->buff : NULL; -} - - -static int errfile (lua_State *L, const char *what, int fnameindex) { - const char *serr = strerror(errno); - const char *filename = lua_tostring(L, fnameindex) + 1; - lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); - lua_remove(L, fnameindex); - return LUA_ERRFILE; -} - - -LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { - LoadF lf; - int status, readstatus; - int c; - int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ - lf.extraline = 0; - if (filename == NULL) { - lua_pushliteral(L, "=stdin"); - lf.f = stdin; - } - else { - lua_pushfstring(L, "@%s", filename); - lf.f = fopen(filename, "r"); - if (lf.f == NULL) return errfile(L, "open", fnameindex); - } - c = getc(lf.f); - if (c == '#') { /* Unix exec. file? */ - lf.extraline = 1; - while ((c = getc(lf.f)) != EOF && c != '\n') {}; /* skip first line */ - if (c == '\n') c = getc(lf.f); - } - 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]) {}; - lf.extraline = 0; - } - ungetc(c, lf.f); - status = lua_load(L, getF, &lf, lua_tostring(L, -1)); - readstatus = ferror(lf.f); - 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); - } - lua_remove(L, fnameindex); - return status; -} - - -typedef struct LoadS { - const char *s; - size_t size; -} LoadS; - - -static const char *getS (lua_State *L, void *ud, size_t *size) { - LoadS *ls = (LoadS *)ud; - (void)L; - if (ls->size == 0) return NULL; - *size = ls->size; - ls->size = 0; - return ls->s; -} - - -LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, - const char *name) { - LoadS ls; - ls.s = buff; - ls.size = size; - return lua_load(L, getS, &ls, name); -} - - -LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { - return luaL_loadbuffer(L, s, strlen(s), s); -} - - - -/* }====================================================== */ - - -static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { - (void)ud; - (void)osize; - if (nsize == 0) { - free(ptr); - return NULL; - } - else - return realloc(ptr, nsize); -} - - -static int panic (lua_State *L) { - (void)L; /* to avoid warnings */ - fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", - lua_tostring(L, -1)); - return 0; -} - - -LUALIB_API lua_State *luaL_newstate (void) { - lua_State *L = lua_newstate(l_alloc, NULL); - if (L) lua_atpanic(L, &panic); - return L; -} - +/* +** $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 +*/ + + +#include +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +#ifdef _MANAGED + #pragma managed(push, off) +#endif +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} +#ifdef _MANAGED + #pragma managed(pop) +#endif + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + 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 */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + 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 */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') {}; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + 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]) {}; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + 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); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + diff --git a/src/host/lua-5.1.4/src/lauxlib.h b/src/host/lua/src/lauxlib.h similarity index 100% rename from src/host/lua-5.1.4/src/lauxlib.h rename to src/host/lua/src/lauxlib.h diff --git a/src/host/lua-5.1.4/src/lbaselib.c b/src/host/lua/src/lbaselib.c similarity index 100% rename from src/host/lua-5.1.4/src/lbaselib.c rename to src/host/lua/src/lbaselib.c diff --git a/src/host/lua-5.1.4/src/lcode.c b/src/host/lua/src/lcode.c similarity index 100% rename from src/host/lua-5.1.4/src/lcode.c rename to src/host/lua/src/lcode.c diff --git a/src/host/lua-5.1.4/src/lcode.h b/src/host/lua/src/lcode.h similarity index 100% rename from src/host/lua-5.1.4/src/lcode.h rename to src/host/lua/src/lcode.h diff --git a/src/host/lua-5.1.4/src/ldblib.c b/src/host/lua/src/ldblib.c similarity index 100% rename from src/host/lua-5.1.4/src/ldblib.c rename to src/host/lua/src/ldblib.c diff --git a/src/host/lua-5.1.4/src/ldebug.c b/src/host/lua/src/ldebug.c similarity index 100% rename from src/host/lua-5.1.4/src/ldebug.c rename to src/host/lua/src/ldebug.c diff --git a/src/host/lua-5.1.4/src/ldebug.h b/src/host/lua/src/ldebug.h similarity index 100% rename from src/host/lua-5.1.4/src/ldebug.h rename to src/host/lua/src/ldebug.h diff --git a/src/host/lua-5.1.4/src/ldo.c b/src/host/lua/src/ldo.c similarity index 100% rename from src/host/lua-5.1.4/src/ldo.c rename to src/host/lua/src/ldo.c diff --git a/src/host/lua-5.1.4/src/ldo.h b/src/host/lua/src/ldo.h similarity index 100% rename from src/host/lua-5.1.4/src/ldo.h rename to src/host/lua/src/ldo.h diff --git a/src/host/lua-5.1.4/src/ldump.c b/src/host/lua/src/ldump.c similarity index 100% rename from src/host/lua-5.1.4/src/ldump.c rename to src/host/lua/src/ldump.c diff --git a/src/host/lua-5.1.4/src/lfunc.c b/src/host/lua/src/lfunc.c similarity index 100% rename from src/host/lua-5.1.4/src/lfunc.c rename to src/host/lua/src/lfunc.c diff --git a/src/host/lua-5.1.4/src/lfunc.h b/src/host/lua/src/lfunc.h similarity index 100% rename from src/host/lua-5.1.4/src/lfunc.h rename to src/host/lua/src/lfunc.h diff --git a/src/host/lua-5.1.4/src/lgc.c b/src/host/lua/src/lgc.c similarity index 100% rename from src/host/lua-5.1.4/src/lgc.c rename to src/host/lua/src/lgc.c diff --git a/src/host/lua-5.1.4/src/lgc.h b/src/host/lua/src/lgc.h similarity index 100% rename from src/host/lua-5.1.4/src/lgc.h rename to src/host/lua/src/lgc.h diff --git a/src/host/lua-5.1.4/src/linit.c b/src/host/lua/src/linit.c similarity index 100% rename from src/host/lua-5.1.4/src/linit.c rename to src/host/lua/src/linit.c diff --git a/src/host/lua-5.1.4/src/liolib.c b/src/host/lua/src/liolib.c similarity index 100% rename from src/host/lua-5.1.4/src/liolib.c rename to src/host/lua/src/liolib.c diff --git a/src/host/lua-5.1.4/src/llex.c b/src/host/lua/src/llex.c similarity index 100% rename from src/host/lua-5.1.4/src/llex.c rename to src/host/lua/src/llex.c diff --git a/src/host/lua-5.1.4/src/llex.h b/src/host/lua/src/llex.h similarity index 100% rename from src/host/lua-5.1.4/src/llex.h rename to src/host/lua/src/llex.h diff --git a/src/host/lua-5.1.4/src/llimits.h b/src/host/lua/src/llimits.h similarity index 100% rename from src/host/lua-5.1.4/src/llimits.h rename to src/host/lua/src/llimits.h diff --git a/src/host/lua-5.1.4/src/lmathlib.c b/src/host/lua/src/lmathlib.c similarity index 100% rename from src/host/lua-5.1.4/src/lmathlib.c rename to src/host/lua/src/lmathlib.c diff --git a/src/host/lua-5.1.4/src/lmem.c b/src/host/lua/src/lmem.c similarity index 100% rename from src/host/lua-5.1.4/src/lmem.c rename to src/host/lua/src/lmem.c diff --git a/src/host/lua-5.1.4/src/lmem.h b/src/host/lua/src/lmem.h similarity index 100% rename from src/host/lua-5.1.4/src/lmem.h rename to src/host/lua/src/lmem.h diff --git a/src/host/lua-5.1.4/src/loadlib.c b/src/host/lua/src/loadlib.c similarity index 100% rename from src/host/lua-5.1.4/src/loadlib.c rename to src/host/lua/src/loadlib.c diff --git a/src/host/lua-5.1.4/src/lobject.c b/src/host/lua/src/lobject.c similarity index 100% rename from src/host/lua-5.1.4/src/lobject.c rename to src/host/lua/src/lobject.c diff --git a/src/host/lua-5.1.4/src/lobject.h b/src/host/lua/src/lobject.h similarity index 100% rename from src/host/lua-5.1.4/src/lobject.h rename to src/host/lua/src/lobject.h diff --git a/src/host/lua-5.1.4/src/lopcodes.c b/src/host/lua/src/lopcodes.c similarity index 100% rename from src/host/lua-5.1.4/src/lopcodes.c rename to src/host/lua/src/lopcodes.c diff --git a/src/host/lua-5.1.4/src/lopcodes.h b/src/host/lua/src/lopcodes.h similarity index 100% rename from src/host/lua-5.1.4/src/lopcodes.h rename to src/host/lua/src/lopcodes.h diff --git a/src/host/lua-5.1.4/src/loslib.c b/src/host/lua/src/loslib.c similarity index 100% rename from src/host/lua-5.1.4/src/loslib.c rename to src/host/lua/src/loslib.c diff --git a/src/host/lua-5.1.4/src/lparser.c b/src/host/lua/src/lparser.c similarity index 100% rename from src/host/lua-5.1.4/src/lparser.c rename to src/host/lua/src/lparser.c diff --git a/src/host/lua-5.1.4/src/lparser.h b/src/host/lua/src/lparser.h similarity index 100% rename from src/host/lua-5.1.4/src/lparser.h rename to src/host/lua/src/lparser.h diff --git a/src/host/lua-5.1.4/src/lstate.c b/src/host/lua/src/lstate.c similarity index 100% rename from src/host/lua-5.1.4/src/lstate.c rename to src/host/lua/src/lstate.c diff --git a/src/host/lua-5.1.4/src/lstate.h b/src/host/lua/src/lstate.h similarity index 100% rename from src/host/lua-5.1.4/src/lstate.h rename to src/host/lua/src/lstate.h diff --git a/src/host/lua-5.1.4/src/lstring.c b/src/host/lua/src/lstring.c similarity index 100% rename from src/host/lua-5.1.4/src/lstring.c rename to src/host/lua/src/lstring.c diff --git a/src/host/lua-5.1.4/src/lstring.h b/src/host/lua/src/lstring.h similarity index 100% rename from src/host/lua-5.1.4/src/lstring.h rename to src/host/lua/src/lstring.h diff --git a/src/host/lua-5.1.4/src/lstrlib.c b/src/host/lua/src/lstrlib.c similarity index 100% rename from src/host/lua-5.1.4/src/lstrlib.c rename to src/host/lua/src/lstrlib.c diff --git a/src/host/lua-5.1.4/src/ltable.c b/src/host/lua/src/ltable.c similarity index 100% rename from src/host/lua-5.1.4/src/ltable.c rename to src/host/lua/src/ltable.c diff --git a/src/host/lua-5.1.4/src/ltable.h b/src/host/lua/src/ltable.h similarity index 100% rename from src/host/lua-5.1.4/src/ltable.h rename to src/host/lua/src/ltable.h diff --git a/src/host/lua-5.1.4/src/ltablib.c b/src/host/lua/src/ltablib.c similarity index 100% rename from src/host/lua-5.1.4/src/ltablib.c rename to src/host/lua/src/ltablib.c diff --git a/src/host/lua-5.1.4/src/ltm.c b/src/host/lua/src/ltm.c similarity index 100% rename from src/host/lua-5.1.4/src/ltm.c rename to src/host/lua/src/ltm.c diff --git a/src/host/lua-5.1.4/src/ltm.h b/src/host/lua/src/ltm.h similarity index 100% rename from src/host/lua-5.1.4/src/ltm.h rename to src/host/lua/src/ltm.h diff --git a/src/host/lua-5.1.4/src/lua.c b/src/host/lua/src/lua.c similarity index 100% rename from src/host/lua-5.1.4/src/lua.c rename to src/host/lua/src/lua.c diff --git a/src/host/lua-5.1.4/src/lua.h b/src/host/lua/src/lua.h similarity index 100% rename from src/host/lua-5.1.4/src/lua.h rename to src/host/lua/src/lua.h diff --git a/src/host/lua-5.1.4/src/luac.c b/src/host/lua/src/luac.c similarity index 100% rename from src/host/lua-5.1.4/src/luac.c rename to src/host/lua/src/luac.c diff --git a/src/host/lua-5.1.4/src/luaconf.h b/src/host/lua/src/luaconf.h similarity index 100% rename from src/host/lua-5.1.4/src/luaconf.h rename to src/host/lua/src/luaconf.h diff --git a/src/host/lua-5.1.4/src/lualib.h b/src/host/lua/src/lualib.h similarity index 100% rename from src/host/lua-5.1.4/src/lualib.h rename to src/host/lua/src/lualib.h diff --git a/src/host/lua-5.1.4/src/lundump.c b/src/host/lua/src/lundump.c similarity index 100% rename from src/host/lua-5.1.4/src/lundump.c rename to src/host/lua/src/lundump.c diff --git a/src/host/lua-5.1.4/src/lundump.h b/src/host/lua/src/lundump.h similarity index 100% rename from src/host/lua-5.1.4/src/lundump.h rename to src/host/lua/src/lundump.h diff --git a/src/host/lua-5.1.4/src/lvm.c b/src/host/lua/src/lvm.c similarity index 100% rename from src/host/lua-5.1.4/src/lvm.c rename to src/host/lua/src/lvm.c diff --git a/src/host/lua-5.1.4/src/lvm.h b/src/host/lua/src/lvm.h similarity index 100% rename from src/host/lua-5.1.4/src/lvm.h rename to src/host/lua/src/lvm.h diff --git a/src/host/lua-5.1.4/src/lzio.c b/src/host/lua/src/lzio.c similarity index 100% rename from src/host/lua-5.1.4/src/lzio.c rename to src/host/lua/src/lzio.c diff --git a/src/host/lua-5.1.4/src/lzio.h b/src/host/lua/src/lzio.h similarity index 100% rename from src/host/lua-5.1.4/src/lzio.h rename to src/host/lua/src/lzio.h diff --git a/src/host/lua-5.1.4/src/print.c b/src/host/lua/src/print.c similarity index 100% rename from src/host/lua-5.1.4/src/print.c rename to src/host/lua/src/print.c diff --git a/src/host/lua-5.1.4/test/README b/src/host/lua/test/README similarity index 100% rename from src/host/lua-5.1.4/test/README rename to src/host/lua/test/README diff --git a/src/host/lua-5.1.4/test/bisect.lua b/src/host/lua/test/bisect.lua similarity index 100% rename from src/host/lua-5.1.4/test/bisect.lua rename to src/host/lua/test/bisect.lua diff --git a/src/host/lua-5.1.4/test/cf.lua b/src/host/lua/test/cf.lua similarity index 100% rename from src/host/lua-5.1.4/test/cf.lua rename to src/host/lua/test/cf.lua diff --git a/src/host/lua-5.1.4/test/echo.lua b/src/host/lua/test/echo.lua similarity index 100% rename from src/host/lua-5.1.4/test/echo.lua rename to src/host/lua/test/echo.lua diff --git a/src/host/lua-5.1.4/test/env.lua b/src/host/lua/test/env.lua similarity index 100% rename from src/host/lua-5.1.4/test/env.lua rename to src/host/lua/test/env.lua diff --git a/src/host/lua-5.1.4/test/factorial.lua b/src/host/lua/test/factorial.lua similarity index 100% rename from src/host/lua-5.1.4/test/factorial.lua rename to src/host/lua/test/factorial.lua diff --git a/src/host/lua-5.1.4/test/fib.lua b/src/host/lua/test/fib.lua similarity index 100% rename from src/host/lua-5.1.4/test/fib.lua rename to src/host/lua/test/fib.lua diff --git a/src/host/lua-5.1.4/test/fibfor.lua b/src/host/lua/test/fibfor.lua similarity index 100% rename from src/host/lua-5.1.4/test/fibfor.lua rename to src/host/lua/test/fibfor.lua diff --git a/src/host/lua-5.1.4/test/globals.lua b/src/host/lua/test/globals.lua similarity index 100% rename from src/host/lua-5.1.4/test/globals.lua rename to src/host/lua/test/globals.lua diff --git a/src/host/lua-5.1.4/test/hello.lua b/src/host/lua/test/hello.lua similarity index 100% rename from src/host/lua-5.1.4/test/hello.lua rename to src/host/lua/test/hello.lua diff --git a/src/host/lua-5.1.4/test/life.lua b/src/host/lua/test/life.lua similarity index 100% rename from src/host/lua-5.1.4/test/life.lua rename to src/host/lua/test/life.lua diff --git a/src/host/lua-5.1.4/test/luac.lua b/src/host/lua/test/luac.lua similarity index 100% rename from src/host/lua-5.1.4/test/luac.lua rename to src/host/lua/test/luac.lua diff --git a/src/host/lua-5.1.4/test/printf.lua b/src/host/lua/test/printf.lua similarity index 100% rename from src/host/lua-5.1.4/test/printf.lua rename to src/host/lua/test/printf.lua diff --git a/src/host/lua-5.1.4/test/readonly.lua b/src/host/lua/test/readonly.lua similarity index 100% rename from src/host/lua-5.1.4/test/readonly.lua rename to src/host/lua/test/readonly.lua diff --git a/src/host/lua-5.1.4/test/sieve.lua b/src/host/lua/test/sieve.lua similarity index 100% rename from src/host/lua-5.1.4/test/sieve.lua rename to src/host/lua/test/sieve.lua diff --git a/src/host/lua-5.1.4/test/sort.lua b/src/host/lua/test/sort.lua similarity index 100% rename from src/host/lua-5.1.4/test/sort.lua rename to src/host/lua/test/sort.lua diff --git a/src/host/lua-5.1.4/test/table.lua b/src/host/lua/test/table.lua similarity index 100% rename from src/host/lua-5.1.4/test/table.lua rename to src/host/lua/test/table.lua diff --git a/src/host/lua-5.1.4/test/trace-calls.lua b/src/host/lua/test/trace-calls.lua similarity index 100% rename from src/host/lua-5.1.4/test/trace-calls.lua rename to src/host/lua/test/trace-calls.lua diff --git a/src/host/lua-5.1.4/test/trace-globals.lua b/src/host/lua/test/trace-globals.lua similarity index 100% rename from src/host/lua-5.1.4/test/trace-globals.lua rename to src/host/lua/test/trace-globals.lua diff --git a/src/host/lua-5.1.4/test/xd.lua b/src/host/lua/test/xd.lua similarity index 100% rename from src/host/lua-5.1.4/test/xd.lua rename to src/host/lua/test/xd.lua diff --git a/src/host/lua_auxlib.c b/src/host/lua_auxlib.c index eb5d4920..58e4906e 100644 --- a/src/host/lua_auxlib.c +++ b/src/host/lua_auxlib.c @@ -15,7 +15,7 @@ static int chunk_wrapper(lua_State* L); * can replace it with my own implementation. */ #define luaL_loadfile original_luaL_loadfile -#include "lua-5.1.4/src/lauxlib.c" +#include "lua/src/lauxlib.c" #undef luaL_loadfile