MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / pushline

Function pushline

src/Chain/libraries/glua/lua.cpp:305–323  ·  view source on GitHub ↗

** Prompt the user, read a line, and push it into the Lua stack. */

Source from the content-addressed store, hash-verified

303** Prompt the user, read a line, and push it into the Lua stack.
304*/
305static int pushline(lua_State *L, int firstline) {
306 char buffer[LUA_MAXINPUT];
307 char *b = buffer;
308 size_t l;
309 const char *prmt = get_prompt(L, firstline);
310 int readstatus = lua_readline(L, b, prmt);
311 if (readstatus == 0)
312 return 0; /* no input (prompt will be popped by caller) */
313 lua_pop(L, 1); /* remove prompt */
314 l = strlen(b);
315 if (l > 0 && b[l - 1] == '\n') /* line ends with newline? */
316 b[--l] = '\0'; /* remove it */
317 if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */
318 lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */
319 else
320 lua_pushlstring(L, b, l);
321 lua_freeline(L, b);
322 return 1;
323}
324
325
326/*

Callers 2

multilineFunction · 0.70
loadlineFunction · 0.70

Calls 3

lua_pushfstringFunction · 0.85
lua_pushlstringFunction · 0.85
get_promptFunction · 0.70

Tested by

no test coverage detected