** Read multiple lines until a complete Lua statement */
| 520 | ** Read multiple lines until a complete Lua statement |
| 521 | */ |
| 522 | static int multiline (lua_State *L) { |
| 523 | for (;;) { /* repeat until gets a complete statement */ |
| 524 | size_t len; |
| 525 | const char *line = lua_tolstring(L, 1, &len); /* get what it has */ |
| 526 | int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ |
| 527 | if (!incomplete(L, status) || !pushline(L, 0)) { |
| 528 | lua_saveline(L, line); /* keep history */ |
| 529 | return status; /* cannot or should not try to add continuation line */ |
| 530 | } |
| 531 | lua_pushliteral(L, "\n"); /* add newline... */ |
| 532 | lua_insert(L, -2); /* ...between the two lines */ |
| 533 | lua_concat(L, 3); /* join them */ |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | |
| 538 | /* |
no test coverage detected