** Prompt the user, read a line, and push it into the Lua stack. */
| 565 | ** Prompt the user, read a line, and push it into the Lua stack. |
| 566 | */ |
| 567 | static int pushline (lua_State *L, int firstline) { |
| 568 | char buffer[LUA_MAXINPUT]; |
| 569 | size_t l; |
| 570 | const char *prmt = get_prompt(L, firstline); |
| 571 | char *b = lua_readline(buffer, prmt); |
| 572 | lua_pop(L, 1); /* remove prompt */ |
| 573 | if (b == NULL) |
| 574 | return 0; /* no input */ |
| 575 | l = strlen(b); |
| 576 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ |
| 577 | b[--l] = '\0'; /* remove it */ |
| 578 | lua_pushlstring(L, b, l); |
| 579 | lua_freeline(b); |
| 580 | return 1; |
| 581 | } |
| 582 | |
| 583 | |
| 584 | /* |
no test coverage detected