@@ -490,10 +490,8 @@ static int incomplete (lua_State *L, int status) {
490490 if (status == LUA_ERRSYNTAX ) {
491491 size_t lmsg ;
492492 const char * msg = lua_tolstring (L , -1 , & lmsg );
493- if (lmsg >= marklen && strcmp (msg + lmsg - marklen , EOFMARK ) == 0 ) {
494- lua_pop (L , 1 );
493+ if (lmsg >= marklen && strcmp (msg + lmsg - marklen , EOFMARK ) == 0 )
495494 return 1 ;
496- }
497495 }
498496 return 0 ; /* else... */
499497}
@@ -508,9 +506,9 @@ static int pushline (lua_State *L, int firstline) {
508506 size_t l ;
509507 const char * prmt = get_prompt (L , firstline );
510508 int readstatus = lua_readline (L , b , prmt );
511- if (readstatus == 0 )
512- return 0 ; /* no input (prompt will be popped by caller) */
513509 lua_pop (L , 1 ); /* remove prompt */
510+ if (readstatus == 0 )
511+ return 0 ; /* no input */
514512 l = strlen (b );
515513 if (l > 0 && b [l - 1 ] == '\n' ) /* line ends with newline? */
516514 b [-- l ] = '\0' ; /* remove it */
@@ -552,8 +550,9 @@ static int multiline (lua_State *L) {
552550 int status = luaL_loadbuffer (L , line , len , "=stdin" ); /* try it */
553551 if (!incomplete (L , status ) || !pushline (L , 0 )) {
554552 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 */
556554 }
555+ lua_remove (L , -2 ); /* remove error message (from incomplete line) */
557556 lua_pushliteral (L , "\n" ); /* add newline... */
558557 lua_insert (L , -2 ); /* ...between the two lines */
559558 lua_concat (L , 3 ); /* join them */
0 commit comments