summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2010-01-08 12:00:00 +0000
committerrepogen <>2010-01-08 12:00:00 +0000
commit22912c77c80f8de8f7accd3319c726f7c5349fd3 (patch)
treecaf064ecca31cd2ef1c919c585ee6b3d5e6d25d6 /etc
parent300cd56eb905be061aa75bb665549b3b85109bbe (diff)
downloadlua-github-22912c77c80f8de8f7accd3319c726f7c5349fd3.tar.gz
Lua 5.2.0-work15.2.0-work1
Diffstat (limited to 'etc')
-rw-r--r--etc/README12
-rw-r--r--etc/all.c39
-rw-r--r--etc/lua.hpp9
-rw-r--r--etc/lua.icobin1078 -> 0 bytes
-rw-r--r--etc/lua.pc31
-rw-r--r--etc/min.c23
-rw-r--r--etc/noparser.c40
7 files changed, 78 insertions, 76 deletions
diff --git a/etc/README b/etc/README
index 5149fc91..99cbb523 100644
--- a/etc/README
+++ b/etc/README
@@ -2,22 +2,12 @@ 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.
+used to build Lua. Set MYLIBS in Makefile or in the command line 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.
diff --git a/etc/all.c b/etc/all.c
index dab68fac..a7f21b7d 100644
--- a/etc/all.c
+++ b/etc/all.c
@@ -1,11 +1,31 @@
/*
-* all.c -- Lua core, libraries and interpreter in a single file
+* all.c -- Lua core, libraries, and interpreter in a single file
*/
+/* default is to build the full interpreter */
+#ifndef MAKE_LIB
+#ifndef MAKE_LUAC
+#undef MAKE_LUA
+#define MAKE_LUA
+#endif
+#endif
+
+/* choose suitable platform-specific features */
+/* some of these may need extra libraries such as -ldl -lreadline -lncurses */
+#if 0
+#define LUA_USE_LINUX
+#define LUA_USE_MACOSX
+#define LUA_USE_POSIX
+#define LUA_USE_DLOPEN
+#define LUA_ANSI
+#endif
+
#define luaall_c
+/* core -- used by all */
#include "lapi.c"
#include "lcode.c"
+#include "lctype.c"
#include "ldebug.c"
#include "ldo.c"
#include "ldump.c"
@@ -24,15 +44,30 @@
#include "lvm.c"
#include "lzio.c"
+/* auxiliary library -- used by all */
#include "lauxlib.c"
+
+/* standard library -- not used by luac */
+#ifndef MAKE_LUAC
#include "lbaselib.c"
+#include "lbitlib.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"
+#endif
+/* lua */
+#ifdef MAKE_LUA
+#include "linit.c"
#include "lua.c"
+#endif
+
+/* luac */
+#ifdef MAKE_LUAC
+#include "print.c"
+#include "luac.c"
+#endif
diff --git a/etc/lua.hpp b/etc/lua.hpp
deleted file mode 100644
index ec417f59..00000000
--- a/etc/lua.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-// 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/etc/lua.ico b/etc/lua.ico
deleted file mode 100644
index ccbabc4e..00000000
--- a/etc/lua.ico
+++ /dev/null
Binary files differ
diff --git a/etc/lua.pc b/etc/lua.pc
deleted file mode 100644
index f52f55b0..00000000
--- a/etc/lua.pc
+++ /dev/null
@@ -1,31 +0,0 @@
-# lua.pc -- pkg-config data for Lua
-
-# vars from install Makefile
-
-# grep '^V=' ../Makefile
-V= 5.1
-# grep '^R=' ../Makefile
-R= 5.1.4
-
-# grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/'
-prefix= /usr/local
-INSTALL_BIN= ${prefix}/bin
-INSTALL_INC= ${prefix}/include
-INSTALL_LIB= ${prefix}/lib
-INSTALL_MAN= ${prefix}/man/man1
-INSTALL_LMOD= ${prefix}/share/lua/${V}
-INSTALL_CMOD= ${prefix}/lib/lua/${V}
-
-# canonical vars
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
-
-Name: Lua
-Description: An Extensible Extension Language
-Version: ${R}
-Requires:
-Libs: -L${libdir} -llua -lm
-Cflags: -I${includedir}
-
-# (end of lua.pc)
diff --git a/etc/min.c b/etc/min.c
index 6a85a4d1..81e3b73d 100644
--- a/etc/min.c
+++ b/etc/min.c
@@ -1,39 +1,36 @@
/*
* min.c -- a minimal Lua interpreter
-* loads stdin only with minimal error handling.
-* no interaction, and no standard library, only a "print" function.
+* runs one file from the command line or stdin if none given.
+* minimal error handling, no traceback, no interaction, no standard library,
+* only a "print" function.
*/
#include <stdio.h>
#include "lua.h"
#include "lauxlib.h"
+#include "lualib.h"
static int print(lua_State *L)
{
int n=lua_gettop(L);
int i;
+ const char *s="";
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("%s%s",s,luaL_tolstring(L,i,NULL));
+ s="\t";
}
printf("\n");
return 0;
}
-int main(void)
+int main(int argc, char *argv[])
{
lua_State *L=lua_open();
lua_register(L,"print",print);
- if (luaL_dofile(L,NULL)!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1));
+ luaL_openlibs(L);
+ if (luaL_dofile(L,argv[1])!=0) fprintf(stderr,"%s\n",lua_tostring(L,-1));
lua_close(L);
return 0;
}
diff --git a/etc/noparser.c b/etc/noparser.c
index 13ba5462..5e0e2031 100644
--- a/etc/noparser.c
+++ b/etc/noparser.c
@@ -4,16 +4,24 @@
* 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".
+* To use this module, simply compile it and list its object file before the
+* Lua libraries. The linker should then not load the parsing modules.
*
-* If you also want to avoid the dump module (ldump.o), define NODUMP.
-* #define NODUMP
+* If you want to avoid the dump module or the undump modules, use the
+* corresponding #define below.
+*
+#define NOPARSER
+#define NODUMP
+#define NOUNDUMP
*/
+#define NOPARSER
+
#define LUA_CORE
+#include "lua.h"
+/* --------------------------------------------------------------- noparser */
+#ifdef NOPARSER
#include "llex.h"
#include "lparser.h"
#include "lzio.h"
@@ -22,7 +30,7 @@ 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) {
+LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Varlist *varl, const char *name) {
UNUSED(z);
UNUSED(buff);
UNUSED(name);
@@ -30,7 +38,9 @@ LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *n
lua_error(L);
return NULL;
}
+#endif
+/* --------------------------------------------------------------- nodump */
#ifdef NODUMP
#include "lundump.h"
@@ -39,12 +49,22 @@ LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data,
UNUSED(w);
UNUSED(data);
UNUSED(strip);
-#if 1
- UNUSED(L);
- return 0;
-#else
lua_pushliteral(L,"dumper not loaded");
lua_error(L);
+ return 0;
+}
#endif
+
+/* --------------------------------------------------------------- noundump */
+#ifdef NOUNDUMP
+#include "lundump.h"
+
+LUAI_FUNC Proto *luaU_undump (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
+ UNUSED(z);
+ UNUSED(buff);
+ UNUSED(name);
+ lua_pushliteral(L,"cannot load binary chunks");
+ lua_error(L);
+ return NULL;
}
#endif