diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-22 11:12:07 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-22 11:12:07 -0200 |
commit | 29ede6aa13144ff7b69c57a87be1ee93f57ae896 (patch) | |
tree | adcfb5dcff7db55481cd675349e23dec0e63c939 /lua.c | |
parent | 951897c09319ae5474a4b86bb7d615136577caa0 (diff) | |
download | lua-29ede6aa13144ff7b69c57a87be1ee93f57ae896.tar.gz lua-29ede6aa13144ff7b69c57a87be1ee93f57ae896.tar.bz2 lua-29ede6aa13144ff7b69c57a87be1ee93f57ae896.zip |
first implementation of multiple states (reentrant code).
Diffstat (limited to 'lua.c')
-rw-r--r-- | lua.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.25 1999/11/12 13:54:44 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.26 1999/11/16 12:50:48 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 | */ |
@@ -21,7 +21,6 @@ | |||
21 | static int isatty (int x) { return x==0; } /* assume stdin is a tty */ | 21 | static int isatty (int x) { return x==0; } /* assume stdin is a tty */ |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | |||
25 | typedef void (*handler)(int); /* type for signal actions */ | 24 | typedef void (*handler)(int); /* type for signal actions */ |
26 | 25 | ||
27 | static void laction (int i); | 26 | static void laction (int i); |
@@ -37,8 +36,8 @@ static handler lreset (void) { | |||
37 | 36 | ||
38 | 37 | ||
39 | static void lstop (void) { | 38 | static void lstop (void) { |
40 | lua_setlinehook(old_linehook); | 39 | lua_setlinehook(lua_state, old_linehook); |
41 | lua_setcallhook(old_callhook); | 40 | lua_setcallhook(lua_state, old_callhook); |
42 | lreset(); | 41 | lreset(); |
43 | lua_error("interrupted!"); | 42 | lua_error("interrupted!"); |
44 | } | 43 | } |
@@ -48,15 +47,15 @@ static void laction (int i) { | |||
48 | (void)i; /* to avoid warnings */ | 47 | (void)i; /* to avoid warnings */ |
49 | signal(SIGINT, SIG_DFL); /* if another SIGINT happens before lstop, | 48 | signal(SIGINT, SIG_DFL); /* if another SIGINT happens before lstop, |
50 | terminate process (default action) */ | 49 | terminate process (default action) */ |
51 | old_linehook = lua_setlinehook((lua_LHFunction)lstop); | 50 | old_linehook = lua_setlinehook(lua_state, (lua_LHFunction)lstop); |
52 | old_callhook = lua_setcallhook((lua_CHFunction)lstop); | 51 | old_callhook = lua_setcallhook(lua_state, (lua_CHFunction)lstop); |
53 | } | 52 | } |
54 | 53 | ||
55 | 54 | ||
56 | static int ldo (int (*f)(const char *), const char *name) { | 55 | static int ldo (int (*f)(lua_State *L, const char *), const char *name) { |
57 | int res; | 56 | int res; |
58 | handler h = lreset(); | 57 | handler h = lreset(); |
59 | res = f(name); /* dostring | dofile */ | 58 | res = f(lua_state, name); /* dostring | dofile */ |
60 | signal(SIGINT, h); /* restore old action */ | 59 | signal(SIGINT, h); /* restore old action */ |
61 | return res; | 60 | return res; |
62 | } | 61 | } |
@@ -172,7 +171,7 @@ int main (int argc, char *argv[]) { | |||
172 | manual_input(0); | 171 | manual_input(0); |
173 | break; | 172 | break; |
174 | case 'd': | 173 | case 'd': |
175 | lua_setdebug(1); | 174 | lua_setdebug(lua_state, 1); |
176 | break; | 175 | break; |
177 | case 'v': | 176 | case 'v': |
178 | printf("%s %s\n(written by %s)\n", | 177 | printf("%s %s\n(written by %s)\n", |