** Read multiple lines until a complete Lua statement */
| 546 | ** Read multiple lines until a complete Lua statement |
| 547 | */ |
| 548 | static int multiline (lua_State *L) { |
| 549 | for (;;) { /* repeat until gets a complete statement */ |
| 550 | size_t len; |
| 551 | const char *line = lua_tolstring(L, 1, &len); /* get what it has */ |
| 552 | int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ |
| 553 | if (!incomplete(L, status) || !pushline(L, 0)) { |
| 554 | lua_saveline(L, line); /* keep history */ |
| 555 | return status; /* cannot or should not try to add continuation line */ |
| 556 | } |
| 557 | lua_pushliteral(L, "\n"); /* add newline... */ |
| 558 | lua_insert(L, -2); /* ...between the two lines */ |
| 559 | lua_concat(L, 3); /* join them */ |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | |
| 564 | /* |
no test coverage detected