| 175 | |
| 176 | |
| 177 | static int pushline (lua_State *L, int firstline) { |
| 178 | char buffer[LUA_MAXINPUT]; |
| 179 | char *b = buffer; |
| 180 | size_t l; |
| 181 | const char *prmt = get_prompt(L, firstline); |
| 182 | if (lua_readline(L, b, prmt) == 0) |
| 183 | return 0; /* no input */ |
| 184 | l = strlen(b); |
| 185 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ |
| 186 | b[l-1] = '\0'; /* remove it */ |
| 187 | if (firstline && b[0] == '=') /* first line starts with `=' ? */ |
| 188 | lua_pushfstring(L, "return %s", b+1); /* change it to `return' */ |
| 189 | else |
| 190 | lua_pushstring(L, b); |
| 191 | lua_freeline(L, b); |
| 192 | return 1; |
| 193 | } |
| 194 | |
| 195 | |
| 196 | static int loadline (lua_State *L) { |
no test coverage detected