MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / pushline

Function pushline

3rd/lua-5.4.3/src/lua.c:479–497  ·  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

477** Prompt the user, read a line, and push it into the Lua stack.
478*/
479static int pushline (lua_State *L, int firstline) {
480 char buffer[LUA_MAXINPUT];
481 char *b = buffer;
482 size_t l;
483 const char *prmt = get_prompt(L, firstline);
484 int readstatus = lua_readline(L, b, prmt);
485 if (readstatus == 0)
486 return 0; /* no input (prompt will be popped by caller) */
487 lua_pop(L, 1); /* remove prompt */
488 l = strlen(b);
489 if (l > 0 && b[l-1] == '\n') /* line ends with newline? */
490 b[--l] = '\0'; /* remove it */
491 if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */
492 lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */
493 else
494 lua_pushlstring(L, b, l);
495 lua_freeline(L, b);
496 return 1;
497}
498
499
500/*

Callers 2

multilineFunction · 0.85
loadlineFunction · 0.85

Calls 3

get_promptFunction · 0.85
lua_pushfstringFunction · 0.85
lua_pushlstringFunction · 0.85

Tested by

no test coverage detected