** Read multiple lines until a complete Lua statement */
| 346 | ** Read multiple lines until a complete Lua statement |
| 347 | */ |
| 348 | static int multiline(lua_State *L) { |
| 349 | for (;;) { /* repeat until gets a complete statement */ |
| 350 | size_t len; |
| 351 | const char *line = lua_tolstring(L, 1, &len); /* get what it has */ |
| 352 | int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */ |
| 353 | if (!incomplete(L, status) || !pushline(L, 0)) { |
| 354 | lua_saveline(L, line); /* keep history */ |
| 355 | return status; /* cannot or should not try to add continuation line */ |
| 356 | } |
| 357 | lua_pushliteral(L, "\n"); /* add newline... */ |
| 358 | lua_insert(L, -2); /* ...between the two lines */ |
| 359 | lua_concat(L, 3); /* join them */ |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | |
| 364 | /* |
no test coverage detected