MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / pushline

Function pushline

extlibs/lua/src/lua.c:454–472  ·  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

452** Prompt the user, read a line, and push it into the Lua stack.
453*/
454static int pushline (lua_State *L, int firstline) {
455 char buffer[LUA_MAXINPUT];
456 char *b = buffer;
457 size_t l;
458 const char *prmt = get_prompt(L, firstline);
459 int readstatus = lua_readline(L, b, prmt);
460 if (readstatus == 0)
461 return 0; /* no input (prompt will be popped by caller) */
462 lua_pop(L, 1); /* remove prompt */
463 l = strlen(b);
464 if (l > 0 && b[l-1] == '\n') /* line ends with newline? */
465 b[--l] = '\0'; /* remove it */
466 if (firstline && b[0] == '=') /* for compatibility with 5.2, ... */
467 lua_pushfstring(L, "return %s", b + 1); /* change '=' to 'return' */
468 else
469 lua_pushlstring(L, b, l);
470 lua_freeline(L, b);
471 return 1;
472}
473
474
475/*

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