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

Function addreturn

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

** Try to compile line on the stack as 'return ;'; on return, stack ** has either compiled chunk or original line (if compilation failed). */

Source from the content-addressed store, hash-verified

328** has either compiled chunk or original line (if compilation failed).
329*/
330static int addreturn(lua_State *L) {
331 const char *line = lua_tostring(L, -1); /* original line */
332 const char *retline = lua_pushfstring(L, "return %s;", line);
333 int status = luaL_loadbuffer(L, retline, strlen(retline), "=stdin");
334 if (status == LUA_OK) {
335 lua_remove(L, -2); /* remove modified line */
336 if (line[0] != '\0') /* non empty? */
337 lua_saveline(L, line); /* keep history */
338 }
339 else
340 lua_pop(L, 2); /* pop result from 'luaL_loadbuffer' and modified line */
341 return status;
342}
343
344
345/*

Callers 1

loadlineFunction · 0.70

Calls 1

lua_pushfstringFunction · 0.85

Tested by

no test coverage detected