** Read multiple lines until a complete Lua statement or an error not ** for an incomplete statement. Start with first line already read in ** the stack. */
| 615 | ** the stack. |
| 616 | */ |
| 617 | static int multiline (lua_State *L) { |
| 618 | size_t len; |
| 619 | const char *line = lua_tolstring(L, 1, &len); /* get first line */ |
| 620 | checklocal(line); |
| 621 | for (;;) { /* repeat until gets a complete statement */ |
| 622 | int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ |
| 623 | if (!incomplete(L, status) || !pushline(L, 0)) |
| 624 | return status; /* should not or cannot try to add continuation line */ |
| 625 | lua_remove(L, -2); /* remove error message (from incomplete line) */ |
| 626 | lua_pushliteral(L, "\n"); /* add newline... */ |
| 627 | lua_insert(L, -2); /* ...between the two lines */ |
| 628 | lua_concat(L, 3); /* join them */ |
| 629 | line = lua_tolstring(L, 1, &len); /* get what is has */ |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | |
| 634 | /* |
no test coverage detected