| 258 | |
| 259 | |
| 260 | static int pushline (lua_State *L, int firstline) { |
| 261 | char buffer[LUA_MAXINPUT]; |
| 262 | char *b = buffer; |
| 263 | size_t l; |
| 264 | const char *prmt = get_prompt(L, firstline); |
| 265 | int readstatus = lua_readline(L, b, prmt); |
| 266 | lua_pop(L, 1); /* remove result from 'get_prompt' */ |
| 267 | if (readstatus == 0) |
| 268 | return 0; /* no input */ |
| 269 | l = strlen(b); |
| 270 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ |
| 271 | b[l-1] = '\0'; /* remove it */ |
| 272 | if (firstline && b[0] == '=') /* first line starts with `=' ? */ |
| 273 | lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ |
| 274 | else |
| 275 | lua_pushstring(L, b); |
| 276 | lua_freeline(L, b); |
| 277 | return 1; |
| 278 | } |
| 279 | |
| 280 | |
| 281 | static int loadline (lua_State *L) { |
no test coverage detected