diff options
Diffstat (limited to 'lua.c')
| -rw-r--r-- | lua.c | 11 |
1 files changed, 5 insertions, 6 deletions
| @@ -490,10 +490,8 @@ static int incomplete (lua_State *L, int status) { | |||
| 490 | if (status == LUA_ERRSYNTAX) { | 490 | if (status == LUA_ERRSYNTAX) { |
| 491 | size_t lmsg; | 491 | size_t lmsg; |
| 492 | const char *msg = lua_tolstring(L, -1, &lmsg); | 492 | const char *msg = lua_tolstring(L, -1, &lmsg); |
| 493 | if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) { | 493 | if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) |
| 494 | lua_pop(L, 1); | ||
| 495 | return 1; | 494 | return 1; |
| 496 | } | ||
| 497 | } | 495 | } |
| 498 | return 0; /* else... */ | 496 | return 0; /* else... */ |
| 499 | } | 497 | } |
| @@ -508,9 +506,9 @@ static int pushline (lua_State *L, int firstline) { | |||
| 508 | size_t l; | 506 | size_t l; |
| 509 | const char *prmt = get_prompt(L, firstline); | 507 | const char *prmt = get_prompt(L, firstline); |
| 510 | int readstatus = lua_readline(L, b, prmt); | 508 | int readstatus = lua_readline(L, b, prmt); |
| 511 | if (readstatus == 0) | ||
| 512 | return 0; /* no input (prompt will be popped by caller) */ | ||
| 513 | lua_pop(L, 1); /* remove prompt */ | 509 | lua_pop(L, 1); /* remove prompt */ |
| 510 | if (readstatus == 0) | ||
| 511 | return 0; /* no input */ | ||
| 514 | l = strlen(b); | 512 | l = strlen(b); |
| 515 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ | 513 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ |
| 516 | b[--l] = '\0'; /* remove it */ | 514 | b[--l] = '\0'; /* remove it */ |
| @@ -552,8 +550,9 @@ static int multiline (lua_State *L) { | |||
| 552 | int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ | 550 | int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ |
| 553 | if (!incomplete(L, status) || !pushline(L, 0)) { | 551 | if (!incomplete(L, status) || !pushline(L, 0)) { |
| 554 | lua_saveline(L, line); /* keep history */ | 552 | lua_saveline(L, line); /* keep history */ |
| 555 | return status; /* cannot or should not try to add continuation line */ | 553 | return status; /* should not or cannot try to add continuation line */ |
| 556 | } | 554 | } |
| 555 | lua_remove(L, -2); /* remove error message (from incomplete line) */ | ||
| 557 | lua_pushliteral(L, "\n"); /* add newline... */ | 556 | lua_pushliteral(L, "\n"); /* add newline... */ |
| 558 | lua_insert(L, -2); /* ...between the two lines */ | 557 | lua_insert(L, -2); /* ...between the two lines */ |
| 559 | lua_concat(L, 3); /* join them */ | 558 | lua_concat(L, 3); /* join them */ |
