MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / addreturn

Function addreturn

libraries/AP_Scripting/lua/src/lua.c:333–345  ·  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

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

Callers 1

loadlineFunction · 0.85

Calls 2

lua_pushfstringFunction · 0.85
strlenFunction · 0.85

Tested by

no test coverage detected