summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lua.c b/lua.c
index 395aaa51..026b0b70 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: $ 2** $Id: lua.c,v 1.1 1997/09/16 19:25:59 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*/
@@ -30,11 +30,15 @@ static void manual_input (void)
30{ 30{
31 if (isatty(0)) { 31 if (isatty(0)) {
32 char buffer[250]; 32 char buffer[250];
33 while (fgets(buffer, sizeof(buffer), stdin) != 0) { 33 while (1) {
34 lua_beginblock(); 34 lua_beginblock();
35 printf("%s", lua_getstring(lua_getglobal("_PROMPT")));
36 if (fgets(buffer, sizeof(buffer), stdin) == 0)
37 break;
35 lua_dostring(buffer); 38 lua_dostring(buffer);
36 lua_endblock(); 39 lua_endblock();
37 } 40 }
41 printf("\n");
38 } 42 }
39 else 43 else
40 lua_dofile(NULL); /* executes stdin as a file */ 44 lua_dofile(NULL); /* executes stdin as a file */
@@ -45,11 +49,14 @@ int main (int argc, char *argv[])
45{ 49{
46 int i; 50 int i;
47 setlocale(LC_ALL, ""); 51 setlocale(LC_ALL, "");
48 lua_iolibopen (); 52 lua_iolibopen();
49 lua_strlibopen (); 53 lua_strlibopen();
50 lua_mathlibopen (); 54 lua_mathlibopen();
51 if (argc < 2) 55 lua_pushstring("Lua> "); lua_setglobal("_PROMPT");
56 if (argc < 2) {
57 printf("%s %s\n", LUA_VERSION, LUA_COPYRIGHT);
52 manual_input(); 58 manual_input();
59 }
53 else for (i=1; i<argc; i++) { 60 else for (i=1; i<argc; i++) {
54 if (strcmp(argv[i], "-") == 0) 61 if (strcmp(argv[i], "-") == 0)
55 manual_input(); 62 manual_input();