diff options
-rw-r--r-- | lua.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.27 1999/11/22 13:12:07 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.28 1999/12/06 11:41:28 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 | */ |
@@ -15,6 +15,10 @@ | |||
15 | #include "lualib.h" | 15 | #include "lualib.h" |
16 | 16 | ||
17 | 17 | ||
18 | #ifndef PROMPT | ||
19 | #define PROMPT "> " | ||
20 | #endif | ||
21 | |||
18 | #ifdef _POSIX_SOURCE | 22 | #ifdef _POSIX_SOURCE |
19 | #include <unistd.h> | 23 | #include <unistd.h> |
20 | #else | 24 | #else |
@@ -119,8 +123,11 @@ static void manual_input (int prompt) { | |||
119 | char buffer[BUFSIZ]; | 123 | char buffer[BUFSIZ]; |
120 | int i = 0; | 124 | int i = 0; |
121 | lua_beginblock(); | 125 | lua_beginblock(); |
122 | if (prompt) | 126 | if (prompt) { |
123 | printf("%s", lua_getstring(lua_getglobal("_PROMPT"))); | 127 | const char *s = lua_getstring(lua_getglobal("_PROMPT")); |
128 | if (!s) s = PROMPT; | ||
129 | printf("%s", s); | ||
130 | } | ||
124 | for(;;) { | 131 | for(;;) { |
125 | int c = getchar(); | 132 | int c = getchar(); |
126 | if (c == EOF) { | 133 | if (c == EOF) { |
@@ -149,7 +156,6 @@ static void manual_input (int prompt) { | |||
149 | int main (int argc, char *argv[]) { | 156 | int main (int argc, char *argv[]) { |
150 | int i; | 157 | int i; |
151 | lua_state = lua_newstate("stack", 1024, "builtin", 1, NULL); | 158 | lua_state = lua_newstate("stack", 1024, "builtin", 1, NULL); |
152 | lua_pushstring("> "); lua_setglobal("_PROMPT"); | ||
153 | lua_userinit(); | 159 | lua_userinit(); |
154 | getargs(argc, argv); | 160 | getargs(argc, argv); |
155 | if (argc < 2) { /* no arguments? */ | 161 | if (argc < 2) { /* no arguments? */ |