summaryrefslogtreecommitdiff
path: root/source3/lua-5.1.4/etc
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lua-5.1.4/etc')
-rw-r--r--source3/lua-5.1.4/etc/Makefile44
-rw-r--r--source3/lua-5.1.4/etc/README36
-rw-r--r--source3/lua-5.1.4/etc/all.c38
-rw-r--r--source3/lua-5.1.4/etc/lua.hpp9
-rw-r--r--source3/lua-5.1.4/etc/lua.icobin0 -> 1078 bytes
-rw-r--r--source3/lua-5.1.4/etc/luavs.bat28
-rw-r--r--source3/lua-5.1.4/etc/min.c39
-rw-r--r--source3/lua-5.1.4/etc/noparser.c50
-rw-r--r--source3/lua-5.1.4/etc/strict.lua40
9 files changed, 284 insertions, 0 deletions
diff --git a/source3/lua-5.1.4/etc/Makefile b/source3/lua-5.1.4/etc/Makefile
new file mode 100644
index 0000000000..20c147932f
--- /dev/null
+++ b/source3/lua-5.1.4/etc/Makefile
@@ -0,0 +1,44 @@
+# 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/source3/lua-5.1.4/etc/README b/source3/lua-5.1.4/etc/README
new file mode 100644
index 0000000000..c892fe1d16
--- /dev/null
+++ b/source3/lua-5.1.4/etc/README
@@ -0,0 +1,36 @@
+This directory contains some useful files and code.
+Unlike the code in ../src, everything here is in the public domain.
+
+If any of the makes fail, you're probably not using the same libraries
+used to build Lua. Set MYLIBS in Makefile accordingly.
+
+all.c
+ Full Lua interpreter in a single file.
+ Do "make one" for a demo.
+
+lua.hpp
+ Lua header files for C++ using 'extern "C"'.
+
+lua.ico
+ A Lua icon for Windows (and web sites: save as favicon.ico).
+ Drawn by hand by Markus Gritsch <gritsch@iue.tuwien.ac.at>.
+
+lua.pc
+ pkg-config data for Lua
+
+luavs.bat
+ Script to build Lua under "Visual Studio .NET Command Prompt".
+ Run it from the toplevel as etc\luavs.bat.
+
+min.c
+ A minimal Lua interpreter.
+ Good for learning and for starting your own.
+ Do "make min" for a demo.
+
+noparser.c
+ Linking with noparser.o avoids loading the parsing modules in lualib.a.
+ Do "make noparser" for a demo.
+
+strict.lua
+ Traps uses of undeclared global variables.
+ Do "make strict" for a demo.
diff --git a/source3/lua-5.1.4/etc/all.c b/source3/lua-5.1.4/etc/all.c
new file mode 100644
index 0000000000..dab68fac58
--- /dev/null
+++ b/source3/lua-5.1.4/etc/all.c
@@ -0,0 +1,38 @@
+/*
+* all.c -- Lua core, libraries and interpreter in a single file
+*/
+
+#define luaall_c
+
+#include "lapi.c"
+#include "lcode.c"
+#include "ldebug.c"
+#include "ldo.c"
+#include "ldump.c"
+#include "lfunc.c"
+#include "lgc.c"
+#include "llex.c"
+#include "lmem.c"
+#include "lobject.c"
+#include "lopcodes.c"
+#include "lparser.c"
+#include "lstate.c"
+#include "lstring.c"
+#include "ltable.c"
+#include "ltm.c"
+#include "lundump.c"
+#include "lvm.c"
+#include "lzio.c"
+
+#include "lauxlib.c"
+#include "lbaselib.c"
+#include "ldblib.c"
+#include "liolib.c"
+#include "linit.c"
+#include "lmathlib.c"
+#include "loadlib.c"
+#include "loslib.c"
+#include "lstrlib.c"
+#include "ltablib.c"
+
+#include "lua.c"
diff --git a/source3/lua-5.1.4/etc/lua.hpp b/source3/lua-5.1.4/etc/lua.hpp
new file mode 100644
index 0000000000..ec417f5946
--- /dev/null
+++ b/source3/lua-5.1.4/etc/lua.hpp
@@ -0,0 +1,9 @@
+// lua.hpp
+// Lua header files for C++
+// <<extern "C">> not supplied automatically because Lua also compiles as C++
+
+extern "C" {
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+}
diff --git a/source3/lua-5.1.4/etc/lua.ico b/source3/lua-5.1.4/etc/lua.ico
new file mode 100644
index 0000000000..ccbabc4e20
--- /dev/null
+++ b/source3/lua-5.1.4/etc/lua.ico
Binary files differ
diff --git a/source3/lua-5.1.4/etc/luavs.bat b/source3/lua-5.1.4/etc/luavs.bat
new file mode 100644
index 0000000000..054b4625c5
--- /dev/null
+++ b/source3/lua-5.1.4/etc/luavs.bat
@@ -0,0 +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 ..
diff --git a/source3/lua-5.1.4/etc/min.c b/source3/lua-5.1.4/etc/min.c
new file mode 100644
index 0000000000..6a85a4d10e
--- /dev/null
+++ b/source3/lua-5.1.4/etc/min.c
@@ -0,0 +1,39 @@
+/*
+* min.c -- a minimal Lua interpreter
+* loads stdin only with minimal error handling.
+* no interaction, and no standard library, only a "print" function.
+*/
+
+#include <stdio.h>
+
+#include "lua.h"
+#include "lauxlib.h"
+
+static int print(lua_State *L)
+{
+ int n=lua_gettop(L);
+ int i;
+ for (i=1; i<=n; i++)
+ {
+ if (i>1) printf("\t");
+ if (lua_isstring(L,i))
+ printf("%s",lua_tostring(L,i));
+ else if (lua_isnil(L,i))
+ printf("%s","nil");
+ else if (lua_isboolean(L,i))
+ printf("%s",lua_toboolean(L,i) ? "true" : "false");
+ else
+ printf("%s:%p",luaL_typename(L,i),lua_topointer(L,i));
+ }
+ printf("\n");
+ return 0;
+}
+
+int main(void)
+{
+ lua_State *L=lua_open();
+ lua_register(L,"print",print);
+ if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1));
+ lua_close(L);
+ return 0;
+}
diff --git a/source3/lua-5.1.4/etc/noparser.c b/source3/lua-5.1.4/etc/noparser.c
new file mode 100644
index 0000000000..13ba546239
--- /dev/null
+++ b/source3/lua-5.1.4/etc/noparser.c
@@ -0,0 +1,50 @@
+/*
+* The code below can be used to make a Lua core that does not contain the
+* parsing modules (lcode, llex, lparser), which represent 35% of the total core.
+* You'll only be able to load binary files and strings, precompiled with luac.
+* (Of course, you'll have to build luac with the original parsing modules!)
+*
+* To use this module, simply compile it ("make noparser" does that) and list
+* its object file before the Lua libraries. The linker should then not load
+* the parsing modules. To try it, do "make luab".
+*
+* If you also want to avoid the dump module (ldump.o), define NODUMP.
+* #define NODUMP
+*/
+
+#define LUA_CORE
+
+#include "llex.h"
+#include "lparser.h"
+#include "lzio.h"
+
+LUAI_FUNC void luaX_init (lua_State *L) {
+ UNUSED(L);
+}
+
+LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
+ UNUSED(z);
+ UNUSED(buff);
+ UNUSED(name);
+ lua_pushliteral(L,"parser not loaded");
+ lua_error(L);
+ return NULL;
+}
+
+#ifdef NODUMP
+#include "lundump.h"
+
+LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) {
+ UNUSED(f);
+ UNUSED(w);
+ UNUSED(data);
+ UNUSED(strip);
+#if 1
+ UNUSED(L);
+ return 0;
+#else
+ lua_pushliteral(L,"dumper not loaded");
+ lua_error(L);
+#endif
+}
+#endif
diff --git a/source3/lua-5.1.4/etc/strict.lua b/source3/lua-5.1.4/etc/strict.lua
new file mode 100644
index 0000000000..3ec2ab2ae5
--- /dev/null
+++ b/source3/lua-5.1.4/etc/strict.lua
@@ -0,0 +1,40 @@
+--
+-- strict.lua
+-- checks uses of undeclared global variables
+-- All global variables must be 'declared' through a regular assignment
+-- (even assigning nil will do) in a main chunk before being used
+-- anywhere or assigned to inside a function.
+--
+
+local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget
+
+local mt = getmetatable(_G)
+if mt == nil then
+ mt = {}
+ setmetatable(_G, mt)
+end
+
+mt.__declared = {}
+
+local function what ()
+ local d = getinfo(3, "S")
+ return d and d.what or "C"
+end
+
+mt.__newindex = function (t, n, v)
+ if not mt.__declared[n] then
+ local w = what()
+ if w ~= "main" and w ~= "C" then
+ error("assign to undeclared variable '"..n.."'", 2)
+ end
+ mt.__declared[n] = true
+ end
+ rawset(t, n, v)
+end
+
+mt.__index = function (t, n)
+ if not mt.__declared[n] and what() ~= "C" then
+ error("variable '"..n.."' is not declared", 2)
+ end
+ return rawget(t, n)
+end