new macros + new names to facilitate compilation of threaded version

This commit is contained in:
Roberto Ierusalimschy
2001-01-26 09:45:51 -02:00
parent a53d9b66ca
commit bce6572579
9 changed files with 190 additions and 176 deletions

36
lua.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lua.c,v 1.56 2001/01/10 16:58:11 roberto Exp roberto $
** $Id: lua.c,v 1.57 2001/01/22 18:01:38 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -16,17 +16,27 @@
#include "lualib.h"
static lua_State *L = NULL;
#ifdef _POSIX_SOURCE
#include <unistd.h>
#else
static int isatty (int x) { return x==0; } /* assume stdin is a tty */
#endif
#ifndef PROMPT
#define PROMPT "> "
#endif
#ifdef _POSIX_SOURCE
#include <unistd.h>
#else
static int isatty (int x) { return x==0; } /* assume stdin is a tty */
#ifndef LUA_USERINIT
#define LUA_USERINIT(L) (lua_baselibopen(L), lua_iolibopen(L), \
lua_strlibopen(L), lua_mathlibopen(L), lua_dblibopen(L))
#endif
#ifndef LUA_USERFINI
#define LUA_USERFINI
#endif
@@ -39,6 +49,9 @@ struct Options {
};
static lua_State *L = NULL;
typedef void (*handler)(int); /* type for signal actions */
static void laction (int i);
@@ -48,15 +61,6 @@ static lua_Hook old_linehook = NULL;
static lua_Hook old_callhook = NULL;
static void userinit (void) {
lua_baselibopen(L);
lua_iolibopen(L);
lua_strlibopen(L);
lua_mathlibopen(L);
lua_dblibopen(L);
/* add your libraries here */
}
static handler lreset (void) {
return signal(SIGINT, laction);
@@ -312,7 +316,7 @@ int main (int argc, char *argv[]) {
opt.toclose = 0;
getstacksize(argc, argv, &opt); /* handle option `-s' */
L = lua_open(NULL, opt.stacksize); /* create state */
userinit(); /* open libraries */
LUA_USERINIT(L); /* open libraries */
register_getargs(argv); /* create `getargs' function */
status = handle_argv(argv+1, &opt);
if (opt.toclose)