commit e238efc5367a8d88757dd84df0683e1d8d9f9211
parent fdd04e7a7f624dad1a1443e08193241dea935287
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 9 Aug 2000 16:16:35 -0300
default now is multi-state
Diffstat:
30 files changed, 228 insertions(+), 210 deletions(-)
diff --git a/lapi.c b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 1.84 2000/06/08 17:48:31 roberto Exp roberto $
+** $Id: lapi.c,v 1.85 2000/06/12 13:52:05 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lapi.h"
diff --git a/lauxlib.c b/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.28 2000/05/24 13:54:49 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.29 2000/06/12 13:52:05 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -14,8 +14,6 @@
** With care, these functions can be used by other libraries.
*/
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/lauxlib.h b/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.17 1999/12/29 16:24:03 roberto Exp roberto $
+** $Id: lauxlib.h,v 1.18 2000/05/24 13:54:49 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -45,7 +45,7 @@ void luaL_oldbuffer (lua_State *L, size_t old);
char *luaL_buffer (lua_State *L);
-#ifdef LUA_REENTRANT
+#ifndef LUA_SINGLESTATE
/*
** ===============================================================
diff --git a/lbuffer.c b/lbuffer.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbuffer.c,v 1.13 2000/05/24 13:54:49 roberto Exp roberto $
+** $Id: lbuffer.c,v 1.14 2000/06/12 13:52:05 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <stdio.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/lbuiltin.c b/lbuiltin.c
@@ -1,5 +1,5 @@
/*
-** $Id: lbuiltin.c,v 1.117 2000/06/30 14:35:17 roberto Exp roberto $
+** $Id: lbuiltin.c,v 1.118 2000/08/04 19:38:35 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@@ -19,8 +19,6 @@
#include <stdlib.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lapi.h"
diff --git a/lcode.c b/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 1.44 2000/08/08 20:42:07 roberto Exp roberto $
+** $Id: lcode.c,v 1.45 2000/08/09 14:49:13 roberto Exp roberto $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include "stdlib.h"
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lcode.h"
diff --git a/ldblib.c b/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.16 2000/05/24 13:54:49 roberto Exp roberto $
+** $Id: ldblib.c,v 1.17 2000/06/12 13:52:05 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -9,8 +9,6 @@
#include <stdlib.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/ldebug.c b/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 1.29 2000/08/08 18:26:05 roberto Exp roberto $
+** $Id: ldebug.c,v 1.30 2000/08/08 20:42:07 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <stdlib.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lapi.h"
diff --git a/ldo.c b/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 1.82 2000/08/04 19:38:35 roberto Exp roberto $
+** $Id: ldo.c,v 1.83 2000/08/08 20:42:07 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -10,8 +10,6 @@
#include <stdlib.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/lfunc.c b/lfunc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lfunc.c,v 1.27 2000/08/08 18:26:05 roberto Exp roberto $
+** $Id: lfunc.c,v 1.28 2000/08/08 20:42:07 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <stdlib.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lfunc.h"
diff --git a/lgc.c b/lgc.c
@@ -1,11 +1,9 @@
/*
-** $Id: lgc.c,v 1.60 2000/08/07 20:21:34 roberto Exp roberto $
+** $Id: lgc.c,v 1.61 2000/08/08 20:42:07 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
-#define LUA_REENTRANT
-
#include "lua.h"
#include "ldo.h"
diff --git a/liolib.c b/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 1.67 2000/06/12 13:52:05 roberto Exp roberto $
+** $Id: liolib.c,v 1.68 2000/06/20 17:13:21 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -11,8 +11,6 @@
#include <string.h>
#include <time.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/llex.c b/llex.c
@@ -1,5 +1,5 @@
/*
-** $Id: llex.c,v 1.65 2000/06/21 18:13:56 roberto Exp roberto $
+** $Id: llex.c,v 1.66 2000/08/08 20:42:07 roberto Exp roberto $
** Lexical Analyzer
** See Copyright Notice in lua.h
*/
@@ -9,8 +9,6 @@
#include <stdio.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/lmathlib.c b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.24 2000/03/10 18:37:44 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.25 2000/06/12 13:52:05 roberto Exp roberto $
** Standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -8,8 +8,6 @@
#include <stdlib.h>
#include <math.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/lmem.c b/lmem.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.c,v 1.34 2000/06/26 19:28:31 roberto Exp roberto $
+** $Id: lmem.c,v 1.35 2000/08/04 19:38:35 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <stdlib.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "ldo.h"
diff --git a/lobject.c b/lobject.c
@@ -1,5 +1,5 @@
/*
-** $Id: lobject.c,v 1.42 2000/06/26 19:28:31 roberto Exp roberto $
+** $Id: lobject.c,v 1.43 2000/06/30 14:35:17 roberto Exp roberto $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <ctype.h>
#include <stdlib.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lobject.h"
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 1.105 2000/08/08 20:48:55 roberto Exp roberto $
+** $Id: lparser.c,v 1.106 2000/08/09 14:49:13 roberto Exp roberto $
** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -8,8 +8,6 @@
#include <stdio.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lcode.h"
diff --git a/lref.c b/lref.c
@@ -1,12 +1,10 @@
/*
-** $Id: lref.c,v 1.15 2000/06/30 14:35:17 roberto Exp roberto $
+** $Id: lref.c,v 1.16 2000/08/07 20:21:34 roberto Exp roberto $
** reference mechanism
** See Copyright Notice in lua.h
*/
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lapi.h"
diff --git a/lstate.c b/lstate.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.c,v 1.30 2000/08/04 19:38:35 roberto Exp roberto $
+** $Id: lstate.c,v 1.31 2000/08/08 20:42:07 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <stdarg.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
@@ -24,9 +22,6 @@
#include "ltm.h"
-lua_State *lua_state = NULL;
-
-
lua_State *lua_newstate (int stacksize, int put_builtin) {
struct lua_longjmp myErrorJmp;
lua_State *L = luaM_new(NULL, lua_State);
@@ -75,6 +70,8 @@ lua_State *lua_newstate (int stacksize, int put_builtin) {
}
+extern lua_State *lua_state;
+
void lua_close (lua_State *L) {
luaC_collect(L, 1); /* collect all elements */
LUA_ASSERT(L->rootproto == NULL, "list should be empty");
diff --git a/lstring.c b/lstring.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstring.c,v 1.40 2000/06/30 14:35:17 roberto Exp $
+** $Id: lstring.c,v 1.41 2000/08/04 19:38:35 roberto Exp roberto $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lmem.h"
diff --git a/lstrlib.c b/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.44 2000/06/12 13:52:05 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.45 2000/06/12 14:37:18 roberto Exp roberto $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -11,8 +11,6 @@
#include <stdlib.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/ltable.c b/ltable.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltable.c,v 1.51 2000/08/04 19:38:35 roberto Exp roberto $
+** $Id: ltable.c,v 1.52 2000/08/07 20:21:34 roberto Exp roberto $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/
@@ -18,8 +18,6 @@
*/
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/ltests.c b/ltests.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltests.c,v 1.31 2000/08/08 18:26:05 roberto Exp roberto $
+** $Id: ltests.c,v 1.32 2000/08/08 20:42:07 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h
*/
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
+#define LUA_SINGLESTATE
#include "lua.h"
diff --git a/ltm.c b/ltm.c
@@ -1,5 +1,5 @@
/*
-** $Id: ltm.c,v 1.44 2000/08/04 19:38:35 roberto Exp roberto $
+** $Id: ltm.c,v 1.45 2000/08/07 20:21:34 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -8,8 +8,6 @@
#include <stdio.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/lua.c b/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.42 2000/06/30 19:17:08 roberto Exp roberto $
+** $Id: lua.c,v 1.43 2000/08/04 19:38:35 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -10,11 +10,15 @@
#include <stdlib.h>
#include <string.h>
+#define LUA_SINGLESTATE
+
#include "lua.h"
#include "luadebug.h"
#include "lualib.h"
+lua_State *lua_state = NULL;
+
#ifndef PROMPT
#define PROMPT "> "
@@ -26,6 +30,16 @@
static int isatty (int x) { return x==0; } /* assume stdin is a tty */
#endif
+
+/*
+** global options
+*/
+struct Options {
+ int toclose;
+ int stacksize;
+};
+
+
typedef void (*handler)(int); /* type for signal actions */
static void laction (int i);
@@ -35,6 +49,19 @@ static lua_Hook old_linehook = NULL;
static lua_Hook old_callhook = NULL;
+#ifdef USERINIT
+extern void USERINIT (void);
+#else
+#define USERINIT userinit
+void userinit (void) {
+ lua_iolibopen();
+ lua_strlibopen();
+ lua_mathlibopen();
+ lua_dblibopen();
+}
+#endif
+
+
static handler lreset (void) {
return signal(SIGINT, laction);
}
@@ -75,7 +102,6 @@ static void print_message (void) {
"usage: lua [options]. Available options are:\n"
" - execute stdin as a file\n"
" -c close lua when exiting\n"
- " -d turn debug on\n"
" -e stat execute string `stat'\n"
" -f name execute file `name' with remaining arguments in table `arg'\n"
" -i enter interactive mode with prompt\n"
@@ -122,17 +148,20 @@ static void l_getargs (void) {
}
-static void file_input (const char *argv) {
+static int file_input (const char *argv) {
int result = ldo(lua_dofile, argv);
if (result) {
if (result == LUA_ERRFILE) {
fprintf(stderr, "lua: cannot execute file ");
perror(argv);
}
- exit(1);
+ return EXIT_FAILURE;
}
+ else
+ return EXIT_SUCCESS;
}
+
/* maximum length of an input string */
#ifndef MAXINPUT
#define MAXINPUT BUFSIZ
@@ -175,92 +204,114 @@ static void manual_input (int version, int prompt) {
}
-int main (int argc, char *argv[]) {
- int toclose = 0;
- int status = EXIT_SUCCESS;
- int i = 1;
- int stacksize = 0;
- if (i < argc && argv[1][0] == '-' && argv[1][1] == 's') {
- stacksize = atoi(&argv[1][2]);
- if (stacksize == 0) {
- fprintf(stderr, "lua: invalid stack size ('%s')\n", &argv[1][2]);
- exit(EXIT_FAILURE);
- }
- i++;
- }
- lua_state = lua_newstate(stacksize, 1);
- lua_userinit();
- lua_pushuserdata(argv);
- lua_pushcclosure(l_getargs, 1);
- lua_setglobal("getargs");
- if (i >= argc) { /* no other arguments? */
+static int handle_argv (char *argv[], struct Options *opt) {
+ if (opt->stacksize > 0) argv++; /* skip option `-s' (if present) */
+ if (*argv == NULL) { /* no more arguments? */
if (isatty(0)) {
manual_input(1, 1);
}
else
ldo(lua_dofile, NULL); /* executes stdin as a file */
}
- else for (; i<argc; i++) {
- if (argv[i][0] == '-') { /* option? */
- switch (argv[i][1]) {
- case 0:
- ldo(lua_dofile, NULL); /* executes stdin as a file */
- break;
- case 'i':
- manual_input(0, 1);
- break;
- case 'q':
- manual_input(0, 0);
- break;
- case 'd':
- lua_setdebug(lua_state, 1);
- if (i+1 >= argc) { /* last argument? */
- manual_input(1, 1);
+ else { /* other arguments; loop over them */
+ int i;
+ for (i = 0; argv[i] != NULL; i++) {
+ if (argv[i][0] != '-') { /* not an option? */
+ if (strchr(argv[i], '='))
+ assign(argv[i]);
+ else
+ if (file_input(argv[i]) != EXIT_SUCCESS)
+ return EXIT_FAILURE; /* stop if file fails */
+ }
+ else switch (argv[i][1]) { /* option */
+ case 0: {
+ ldo(lua_dofile, NULL); /* executes stdin as a file */
+ break;
}
- break;
- case 'c':
- toclose = 1;
- break;
- case 'v':
- print_version();
- break;
- case 'e':
- i++;
- if (i >= argc) {
- print_message();
- status = EXIT_FAILURE; goto endloop;
+ case 'i': {
+ manual_input(0, 1);
+ break;
+ }
+ case 'q': {
+ manual_input(0, 0);
+ break;
}
- if (ldo(lua_dostring, argv[i]) != 0) {
- fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
- status = EXIT_FAILURE; goto endloop;
+ case 'c': {
+ opt->toclose = 1;
+ break;
}
- break;
- case 'f':
- i++;
- if (i >= argc) {
+ case 'v': {
+ print_version();
+ break;
+ }
+ case 'e': {
+ i++;
+ if (argv[i] == NULL) {
+ print_message();
+ return EXIT_FAILURE;
+ }
+ if (ldo(lua_dostring, argv[i]) != 0) {
+ fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
+ return EXIT_FAILURE;
+ }
+ break;
+ }
+ case 'f': {
+ i++;
+ if (argv[i] == NULL) {
+ print_message();
+ return EXIT_FAILURE;
+ }
+ lua_pushobject(getargs(argv+i)); /* collect remaining arguments */
+ lua_setglobal("arg");
+ return file_input(argv[i]); /* stop scanning arguments */
+ }
+ case 's': {
+ fprintf(stderr, "lua: stack size (`-s') must be the first option\n");
+ return EXIT_FAILURE;
+ }
+ default: {
print_message();
- status = EXIT_FAILURE; goto endloop;
+ return EXIT_FAILURE;
}
- lua_pushobject(getargs(argv+i)); /* collect remaining arguments */
- lua_setglobal("arg");
- file_input(argv[i]);
- goto endloop; /* stop scanning arguments */
- break;
- case 's':
- fprintf(stderr, "lua: stack size (`-s') must be the first option\n");
- status = EXIT_FAILURE; goto endloop;
- default:
- print_message();
- status = EXIT_FAILURE; goto endloop;
- }
+ }
}
- else if (strchr(argv[i], '='))
- assign(argv[i]);
- else
- file_input(argv[i]);
}
- endloop:
- if (toclose)
+ return EXIT_SUCCESS;
+}
+
+
+static void getstacksize (int argc, char *argv[], struct Options *opt) {
+ if (argc >= 2 && argv[1][0] == '-' && argv[1][1] == 's') {
+ int stacksize = atoi(&argv[1][2]);
+ if (stacksize == 0) {
+ fprintf(stderr, "lua: invalid stack size ('%s')\n", &argv[1][2]);
+ exit(EXIT_FAILURE);
+ }
+ opt->stacksize = stacksize;
+ }
+ else
+ opt->stacksize = 0; /* no stack size */
+}
+
+
+static void register_getargs (char *argv[]) {
+ lua_pushuserdata(argv);
+ lua_pushcclosure(l_getargs, 1);
+ lua_setglobal("getargs");
+}
+
+
+int main (int argc, char *argv[]) {
+ struct Options opt;
+ int status;
+ opt.toclose = 0;
+ getstacksize(argc, argv, &opt); /* handle option `-s' */
+ lua_state = lua_newstate(opt.stacksize, 1); /* create state */
+ USERINIT(); /* open libraries */
+ register_getargs(argv); /* create `getargs' function */
+ status = handle_argv(argv+1, &opt);
+ if (opt.toclose)
lua_close();
return status;
}
diff --git a/lua.h b/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.55 2000/06/30 19:17:08 roberto Exp roberto $
+** $Id: lua.h,v 1.56 2000/08/07 18:39:16 roberto Exp roberto $
** Lua - An Extensible Extension Language
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
** e-mail: lua@tecgraf.puc-rio.br
@@ -16,7 +16,7 @@
#include <stddef.h>
-#define LUA_VERSION "Lua 4.0 (alpha)"
+#define LUA_VERSION "Lua 4.0 (beta)"
#define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio"
#define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
@@ -137,7 +137,7 @@ long lua_collectgarbage (lua_State *L, long limit);
** ===============================================================
*/
-#ifdef LUA_REENTRANT
+#ifndef LUA_SINGLESTATE
#define lua_call(L,name) lua_callfunction(L, lua_getglobal(L, name))
#define lua_pushref(L,ref) lua_pushobject(L, lua_getref(L, ref))
@@ -161,7 +161,7 @@ long lua_collectgarbage (lua_State *L, long limit);
-#ifndef LUA_REENTRANT
+#ifdef LUA_SINGLESTATE
/*
** {==============================================================
** Macros for single-state use
@@ -248,7 +248,7 @@ extern lua_State *lua_state;
lua_Object lua_rawgetglobal (lua_State *L, const char *name);
void lua_rawsetglobal (lua_State *L, const char *name);/* In: value */
-#ifndef LUA_REENTRANT
+#ifdef LUA_SINGLESTATE
#define lua_rawgetglobal(name) (lua_rawgetglobal(lua_state, name))
#define lua_rawsetglobal(name) (lua_rawsetglobal(lua_state, name))
#endif
diff --git a/lualib.h b/lualib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lualib.h,v 1.8 1999/11/22 13:12:07 roberto Exp roberto $
+** $Id: lualib.h,v 1.9 2000/06/16 17:22:43 roberto Exp roberto $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
@@ -23,7 +23,7 @@ void lua_dblibopen (lua_State *L);
** ===============================================================
*/
-#ifndef LUA_REENTRANT
+#ifdef LUA_SINGLESTATE
#define lua_iolibopen() (lua_iolibopen)(lua_state)
#define lua_strlibopen() (lua_strlibopen)(lua_state)
diff --git a/lundump.c b/lundump.c
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 1.22 2000/06/12 13:52:05 roberto Exp roberto $
+** $Id: lundump.c,v 1.23 2000/06/26 19:28:31 roberto Exp roberto $
** load bytecodes from files
** See Copyright Notice in lua.h
*/
@@ -7,8 +7,6 @@
#include <stdio.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lauxlib.h"
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.122 2000/08/08 20:42:07 roberto Exp roberto $
+** $Id: lvm.c,v 1.123 2000/08/09 14:49:41 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -9,8 +9,6 @@
#include <stdlib.h>
#include <string.h>
-#define LUA_REENTRANT
-
#include "lua.h"
#include "lapi.h"
diff --git a/makefile b/makefile
@@ -1,5 +1,5 @@
#
-## $Id: makefile,v 1.24 2000/04/14 17:52:09 roberto Exp roberto $
+## $Id: makefile,v 1.25 2000/04/24 21:05:11 roberto Exp roberto $
## Makefile
## See Copyright Notice in lua.h
#
@@ -17,17 +17,32 @@
#
# define LUA_NUM_TYPE if you need numbers to be different from double
# (for instance, -DLUA_NUM_TYPE=float)
+# you may need to adapat the code, too.
#
# define LUA_COMPAT_READPATTERN if you need read patterns
# (only for compatibility with previous versions)
+# define LUA_COMPAT_ARGRET for compatibility in the way function results
+# are passed as arguments
+# define LUA_DEPRECATETFUNCS to include obsolete functions
-CONFIG = -DPOPEN -D_POSIX_SOURCE
-#CONFIG = -DOLD_ANSI -DDEBUG -DLUA_COMPAT_READPATTERN
+CONFIG = -DPOPEN -D_POSIX_SOURCE -DDEBUG
+#CONFIG = -DOLD_ANSI -DDEBUG -DLUA_COMPAT_READPATTERN -DLUA_COMPAT_ARGRET
+# -DLUA_DEPRECATETFUNCS
# Compilation parameters
-CC = gcc
-CWARNS = -Wall -W -Wmissing-prototypes -Wshadow -pedantic -Wpointer-arith -Wcast-align -Waggregate-return -Wcast-qual -Wnested-externs -Wwrite-strings
+CC = g++
+CWARNS = -Wall -W -pedantic \
+ -Waggregate-return \
+ -Wcast-align \
+ -Wmissing-prototypes \
+ -Wnested-externs \
+ -Wpointer-arith \
+ -Wshadow \
+ -Wwrite-strings
+# -Wcast-qual
+# -Wtraditional
+
CFLAGS = $(CONFIG) $(CWARNS) -ansi -O2
@@ -68,8 +83,7 @@ LIBOBJS = \
liolib.o \
lmathlib.o \
lstrlib.o \
- ldblib.o \
- linit.o
+ ldblib.o
lua : lua.o liblua.a liblualib.a
@@ -99,56 +113,57 @@ clear :
co $(CO_OPTIONS) $@
-lapi.o: lapi.c lapi.h lobject.h llimits.h lua.h lauxlib.h ldo.h \
+lapi.o: lapi.c lua.h lapi.h lobject.h llimits.h lauxlib.h ldo.h \
lstate.h luadebug.h lfunc.h lgc.h lmem.h lref.h lstring.h ltable.h \
ltm.h lvm.h
-lauxlib.o: lauxlib.c lauxlib.h lua.h luadebug.h
-lbuffer.o: lbuffer.c lauxlib.h lua.h lmem.h lstate.h lobject.h \
- llimits.h luadebug.h
-lbuiltin.o: lbuiltin.c lapi.h lobject.h llimits.h lua.h lauxlib.h \
+lauxlib.o: lauxlib.c lua.h lauxlib.h luadebug.h
+lbuffer.o: lbuffer.c lua.h lauxlib.h lmem.h llimits.h lstate.h \
+ lobject.h luadebug.h
+lbuiltin.o: lbuiltin.c lua.h lapi.h lobject.h llimits.h lauxlib.h \
lbuiltin.h ldo.h lstate.h luadebug.h lfunc.h lmem.h lstring.h \
ltable.h ltm.h lundump.h lzio.h lvm.h
-lcode.o: lcode.c /usr/include/stdlib.h lcode.h llex.h lobject.h \
- llimits.h lua.h lzio.h lopcodes.h lparser.h ldo.h lstate.h luadebug.h \
- lmem.h lstring.h
-ldblib.o: ldblib.c lauxlib.h lua.h luadebug.h lualib.h
-ldebug.o: ldebug.c lapi.h lobject.h llimits.h lua.h lauxlib.h ldebug.h \
- luadebug.h ldo.h lstate.h lfunc.h ltable.h ltm.h
-ldo.o: ldo.c lauxlib.h lua.h ldebug.h lobject.h llimits.h luadebug.h \
- ldo.h lstate.h lgc.h lmem.h lparser.h lzio.h lstring.h ltm.h \
- lundump.h lvm.h
-lfunc.o: lfunc.c lfunc.h lobject.h llimits.h lua.h lmem.h lstate.h \
+lcode.o: lcode.c /usr/include/stdlib.h lua.h lcode.h llex.h lobject.h \
+ llimits.h lzio.h lopcodes.h lparser.h ldo.h lstate.h luadebug.h \
+ lmem.h
+ldblib.o: ldblib.c lua.h lauxlib.h luadebug.h lualib.h
+ldebug.o: ldebug.c lua.h lapi.h lobject.h llimits.h lauxlib.h lcode.h \
+ llex.h lzio.h lopcodes.h lparser.h ldebug.h lstate.h luadebug.h ldo.h \
+ lfunc.h ltable.h ltm.h
+ldo.o: ldo.c lua.h lauxlib.h ldebug.h lstate.h lobject.h llimits.h \
+ luadebug.h ldo.h lgc.h lmem.h lparser.h lzio.h lstring.h ltable.h \
+ ltm.h lundump.h lvm.h
+lfunc.o: lfunc.c lua.h lfunc.h lobject.h llimits.h lmem.h lstate.h \
luadebug.h
-lgc.o: lgc.c ldo.h lobject.h llimits.h lua.h lstate.h luadebug.h \
+lgc.o: lgc.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \
lfunc.h lgc.h lmem.h lref.h lstring.h ltable.h ltm.h
-linit.o: linit.c lua.h lualib.h
-liolib.o: liolib.c lauxlib.h lua.h luadebug.h lualib.h
-llex.o: llex.c lauxlib.h lua.h llex.h lobject.h llimits.h lzio.h \
- lmem.h lparser.h lstate.h luadebug.h lstring.h
-lmathlib.o: lmathlib.c lauxlib.h lua.h lualib.h
-lmem.o: lmem.c lmem.h lua.h lobject.h llimits.h lstate.h luadebug.h
-lobject.o: lobject.c lobject.h llimits.h lua.h
-lparser.o: lparser.c lcode.h llex.h lobject.h llimits.h lua.h lzio.h \
- lopcodes.h lparser.h ldo.h lstate.h luadebug.h lfunc.h lmem.h \
- lstring.h
-lref.o: lref.c lapi.h lobject.h llimits.h lua.h lmem.h lref.h lstate.h \
+liolib.o: liolib.c lua.h lauxlib.h luadebug.h lualib.h
+llex.o: llex.c lua.h lauxlib.h llex.h lobject.h llimits.h lzio.h \
+ lmem.h lparser.h lstate.h luadebug.h lstring.h ltable.h
+lmathlib.o: lmathlib.c lua.h lauxlib.h lualib.h
+lmem.o: lmem.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \
+ lmem.h
+lobject.o: lobject.c lua.h lobject.h llimits.h
+lparser.o: lparser.c lua.h lcode.h llex.h lobject.h llimits.h lzio.h \
+ lopcodes.h lparser.h lfunc.h lmem.h lstate.h luadebug.h lstring.h
+lref.o: lref.c lua.h lapi.h lobject.h llimits.h lmem.h lref.h lstate.h \
luadebug.h
-lstate.o: lstate.c lauxlib.h lua.h lbuiltin.h ldo.h lobject.h \
+lstate.o: lstate.c lua.h lauxlib.h lbuiltin.h ldo.h lobject.h \
llimits.h lstate.h luadebug.h lgc.h llex.h lzio.h lmem.h lref.h \
- lstring.h ltm.h
-lstring.o: lstring.c lmem.h lua.h lobject.h llimits.h lstate.h \
+ lstring.h ltable.h ltm.h
+lstring.o: lstring.c lua.h lmem.h llimits.h lobject.h lstate.h \
luadebug.h lstring.h
-lstrlib.o: lstrlib.c lauxlib.h lua.h lualib.h
-ltable.o: ltable.c lauxlib.h lua.h lmem.h lobject.h llimits.h lstate.h \
- luadebug.h ltable.h
-ltests.o: ltests.c lapi.h lobject.h llimits.h lua.h lauxlib.h lmem.h \
- lopcodes.h lstate.h luadebug.h lstring.h ltable.h
-ltm.o: ltm.c lauxlib.h lua.h lmem.h lobject.h llimits.h lstate.h \
+lstrlib.o: lstrlib.c lua.h lauxlib.h lualib.h
+ltable.o: ltable.c lua.h lauxlib.h lmem.h llimits.h lobject.h lstate.h \
+ luadebug.h lstring.h ltable.h
+ltests.o: ltests.c lua.h lapi.h lobject.h llimits.h lauxlib.h lcode.h \
+ llex.h lzio.h lopcodes.h lparser.h ldebug.h lstate.h luadebug.h ldo.h \
+ lfunc.h lmem.h lstring.h ltable.h
+ltm.o: ltm.c lua.h lauxlib.h lmem.h llimits.h lobject.h lstate.h \
luadebug.h ltm.h
lua.o: lua.c lua.h luadebug.h lualib.h
-lundump.o: lundump.c lauxlib.h lua.h lfunc.h lobject.h llimits.h \
+lundump.o: lundump.c lua.h lauxlib.h lfunc.h lobject.h llimits.h \
lmem.h lopcodes.h lstring.h lstate.h luadebug.h lundump.h lzio.h
-lvm.o: lvm.c lauxlib.h lua.h ldebug.h lobject.h llimits.h luadebug.h \
- ldo.h lstate.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h ltm.h \
- lvm.h
-lzio.o: lzio.c lzio.h
+lvm.o: lvm.c lua.h lapi.h lobject.h llimits.h lauxlib.h ldebug.h \
+ lstate.h luadebug.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h \
+ ltm.h lvm.h
+lzio.o: lzio.c lua.h lzio.h