diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-26 09:45:51 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-26 09:45:51 -0200 |
commit | bce6572579a7e6c7a96895d9280396b3b33b8f3f (patch) | |
tree | a937d0366ae9d9e37e6320b347ec463f337ceb1b /lua.c | |
parent | a53d9b66ca6247818acaf41e28cdf123082a272b (diff) | |
download | lua-bce6572579a7e6c7a96895d9280396b3b33b8f3f.tar.gz lua-bce6572579a7e6c7a96895d9280396b3b33b8f3f.tar.bz2 lua-bce6572579a7e6c7a96895d9280396b3b33b8f3f.zip |
new macros + new names to facilitate compilation of threaded version
Diffstat (limited to 'lua.c')
-rw-r--r-- | lua.c | 36 |
1 files changed, 20 insertions, 16 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.56 2001/01/10 16:58:11 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.57 2001/01/22 18:01:38 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -16,17 +16,27 @@ | |||
16 | #include "lualib.h" | 16 | #include "lualib.h" |
17 | 17 | ||
18 | 18 | ||
19 | static lua_State *L = NULL; | 19 | #ifdef _POSIX_SOURCE |
20 | #include <unistd.h> | ||
21 | #else | ||
22 | static int isatty (int x) { return x==0; } /* assume stdin is a tty */ | ||
23 | #endif | ||
24 | |||
20 | 25 | ||
21 | 26 | ||
22 | #ifndef PROMPT | 27 | #ifndef PROMPT |
23 | #define PROMPT "> " | 28 | #define PROMPT "> " |
24 | #endif | 29 | #endif |
25 | 30 | ||
26 | #ifdef _POSIX_SOURCE | 31 | |
27 | #include <unistd.h> | 32 | #ifndef LUA_USERINIT |
28 | #else | 33 | #define LUA_USERINIT(L) (lua_baselibopen(L), lua_iolibopen(L), \ |
29 | static int isatty (int x) { return x==0; } /* assume stdin is a tty */ | 34 | lua_strlibopen(L), lua_mathlibopen(L), lua_dblibopen(L)) |
35 | #endif | ||
36 | |||
37 | |||
38 | #ifndef LUA_USERFINI | ||
39 | #define LUA_USERFINI | ||
30 | #endif | 40 | #endif |
31 | 41 | ||
32 | 42 | ||
@@ -39,6 +49,9 @@ struct Options { | |||
39 | }; | 49 | }; |
40 | 50 | ||
41 | 51 | ||
52 | static lua_State *L = NULL; | ||
53 | |||
54 | |||
42 | typedef void (*handler)(int); /* type for signal actions */ | 55 | typedef void (*handler)(int); /* type for signal actions */ |
43 | 56 | ||
44 | static void laction (int i); | 57 | static void laction (int i); |
@@ -48,15 +61,6 @@ static lua_Hook old_linehook = NULL; | |||
48 | static lua_Hook old_callhook = NULL; | 61 | static lua_Hook old_callhook = NULL; |
49 | 62 | ||
50 | 63 | ||
51 | static void userinit (void) { | ||
52 | lua_baselibopen(L); | ||
53 | lua_iolibopen(L); | ||
54 | lua_strlibopen(L); | ||
55 | lua_mathlibopen(L); | ||
56 | lua_dblibopen(L); | ||
57 | /* add your libraries here */ | ||
58 | } | ||
59 | |||
60 | 64 | ||
61 | static handler lreset (void) { | 65 | static handler lreset (void) { |
62 | return signal(SIGINT, laction); | 66 | return signal(SIGINT, laction); |
@@ -312,7 +316,7 @@ int main (int argc, char *argv[]) { | |||
312 | opt.toclose = 0; | 316 | opt.toclose = 0; |
313 | getstacksize(argc, argv, &opt); /* handle option `-s' */ | 317 | getstacksize(argc, argv, &opt); /* handle option `-s' */ |
314 | L = lua_open(NULL, opt.stacksize); /* create state */ | 318 | L = lua_open(NULL, opt.stacksize); /* create state */ |
315 | userinit(); /* open libraries */ | 319 | LUA_USERINIT(L); /* open libraries */ |
316 | register_getargs(argv); /* create `getargs' function */ | 320 | register_getargs(argv); /* create `getargs' function */ |
317 | status = handle_argv(argv+1, &opt); | 321 | status = handle_argv(argv+1, &opt); |
318 | if (opt.toclose) | 322 | if (opt.toclose) |