MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / pushline

Function pushline

third-party/lua-5.4.6/src/lua.c:503–521  ·  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

501** Prompt the user, read a line, and push it into the Lua stack.
502*/
503static int pushline (lua_State *L, int firstline) {
504 char buffer[LUA_MAXINPUT];
505 char *b = buffer;
506 size_t l;
507 const char *prmt = get_prompt(L, firstline);
508 int readstatus = lua_readline(L, b, prmt);
509 lua_pop(L, 1); /* remove prompt */
510 if (readstatus == 0)
511 return 0; /* no input */
512 l = strlen(b);
513 if (l > 0 && b[l-1] == '\n') /* line ends with newline? */
514 b[--l] = '\0'; /* remove it */
515 if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */
516 lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */
517 else
518 lua_pushlstring(L, b, l);
519 lua_freeline(L, b);
520 return 1;
521}
522
523
524/*

Callers 2

multilineFunction · 0.70
loadlineFunction · 0.70

Calls 5

lua_readlineFunction · 0.85
lua_freelineFunction · 0.85
get_promptFunction · 0.70
lua_pushfstringFunction · 0.70
lua_pushlstringFunction · 0.70

Tested by

no test coverage detected