diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-07-10 17:49:01 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-07-10 17:49:01 -0300 |
| commit | ac7006d374928651874babf046030ba212290416 (patch) | |
| tree | b9f4c651c009c72b65e319405d77f5d9d0de3894 | |
| parent | 12bee999dd652f43dfff682319696bea47464b18 (diff) | |
| download | lua-ac7006d374928651874babf046030ba212290416.tar.gz lua-ac7006d374928651874babf046030ba212290416.tar.bz2 lua-ac7006d374928651874babf046030ba212290416.zip | |
^D in interactive mode finish interaction (no questions asked)
| -rw-r--r-- | lua.c | 9 |
1 files changed, 4 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.c,v 1.95 2002/07/09 18:19:44 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.96 2002/07/10 20:44:34 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 | */ |
| @@ -218,7 +218,6 @@ static int incomplete (int status) { | |||
| 218 | 218 | ||
| 219 | static int load_string (void) { | 219 | static int load_string (void) { |
| 220 | int status; | 220 | int status; |
| 221 | int moreinput = 1; | ||
| 222 | lua_settop(L, 0); | 221 | lua_settop(L, 0); |
| 223 | if (read_line(get_prompt(1)) == 0) /* no input? */ | 222 | if (read_line(get_prompt(1)) == 0) /* no input? */ |
| 224 | return -1; | 223 | return -1; |
| @@ -228,10 +227,10 @@ static int load_string (void) { | |||
| 228 | } | 227 | } |
| 229 | for (;;) { /* repeat until gets a complete line */ | 228 | for (;;) { /* repeat until gets a complete line */ |
| 230 | status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); | 229 | status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); |
| 231 | if (!moreinput || !incomplete(status)) /* cannot try to add lines? */ | 230 | if (!incomplete(status)) break; /* cannot try to add lines? */ |
| 232 | break; | ||
| 233 | lua_pushliteral(L, "\n"); /* no; add line separator */ | 231 | lua_pushliteral(L, "\n"); /* no; add line separator */ |
| 234 | moreinput = read_line(get_prompt(0)); | 232 | if (read_line(get_prompt(0)) == 0) /* no more input? */ |
| 233 | return -1; | ||
| 235 | lua_concat(L, lua_gettop(L)); /* join lines and line separator */ | 234 | lua_concat(L, lua_gettop(L)); /* join lines and line separator */ |
| 236 | } | 235 | } |
| 237 | save_line(lua_tostring(L, 1)); | 236 | save_line(lua_tostring(L, 1)); |
