MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / multiline

Function multiline

lib/lua/src/lua.c:548–561  ·  view source on GitHub ↗

** Read multiple lines until a complete Lua statement */

Source from the content-addressed store, hash-verified

546** Read multiple lines until a complete Lua statement
547*/
548static int multiline (lua_State *L) {
549 for (;;) { /* repeat until gets a complete statement */
550 size_t len;
551 const char *line = lua_tolstring(L, 1, &len); /* get what it has */
552 int status = luaL_loadbuffer(L, line, len, "=stdin"); /* try it */
553 if (!incomplete(L, status) || !pushline(L, 0)) {
554 lua_saveline(L, line); /* keep history */
555 return status; /* cannot or should not try to add continuation line */
556 }
557 lua_pushliteral(L, "\n"); /* add newline... */
558 lua_insert(L, -2); /* ...between the two lines */
559 lua_concat(L, 3); /* join them */
560 }
561}
562
563
564/*

Callers 1

loadlineFunction · 0.85

Calls 4

lua_tolstringFunction · 0.85
incompleteFunction · 0.85
pushlineFunction · 0.85
lua_concatFunction · 0.85

Tested by

no test coverage detected