mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
^D in interactive mode finish interaction (no questions asked)
This commit is contained in:
parent
12bee999dd
commit
ac7006d374
9
lua.c
9
lua.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.c,v 1.95 2002/07/09 18:19:44 roberto Exp roberto $
|
** $Id: lua.c,v 1.96 2002/07/10 20:44:34 roberto Exp roberto $
|
||||||
** Lua stand-alone interpreter
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -218,7 +218,6 @@ static int incomplete (int status) {
|
|||||||
|
|
||||||
static int load_string (void) {
|
static int load_string (void) {
|
||||||
int status;
|
int status;
|
||||||
int moreinput = 1;
|
|
||||||
lua_settop(L, 0);
|
lua_settop(L, 0);
|
||||||
if (read_line(get_prompt(1)) == 0) /* no input? */
|
if (read_line(get_prompt(1)) == 0) /* no input? */
|
||||||
return -1;
|
return -1;
|
||||||
@ -228,10 +227,10 @@ static int load_string (void) {
|
|||||||
}
|
}
|
||||||
for (;;) { /* repeat until gets a complete line */
|
for (;;) { /* repeat until gets a complete line */
|
||||||
status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
|
status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
|
||||||
if (!moreinput || !incomplete(status)) /* cannot try to add lines? */
|
if (!incomplete(status)) break; /* cannot try to add lines? */
|
||||||
break;
|
|
||||||
lua_pushliteral(L, "\n"); /* no; add line separator */
|
lua_pushliteral(L, "\n"); /* no; add line separator */
|
||||||
moreinput = read_line(get_prompt(0));
|
if (read_line(get_prompt(0)) == 0) /* no more input? */
|
||||||
|
return -1;
|
||||||
lua_concat(L, lua_gettop(L)); /* join lines and line separator */
|
lua_concat(L, lua_gettop(L)); /* join lines and line separator */
|
||||||
}
|
}
|
||||||
save_line(lua_tostring(L, 1));
|
save_line(lua_tostring(L, 1));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user