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

Function runargs

libraries/AP_Scripting/lua/src/lua.c:515–532  ·  view source on GitHub ↗

** Processes options 'e' and 'l', which involve running Lua code. ** Returns 0 if some code raises an error. */

Source from the content-addressed store, hash-verified

513** Returns 0 if some code raises an error.
514*/
515static int runargs (lua_State *L, char **argv, int n) {
516 int i;
517 for (i = 1; i < n; i++) {
518 int option = argv[i][1];
519 lua_assert(argv[i][0] == '-'); /* already checked */
520 if (option == 'e' || option == 'l') {
521 int status;
522 const char *extra = argv[i] + 2; /* both options need an argument */
523 if (*extra == '\0') extra = argv[++i];
524 lua_assert(extra != NULL);
525 status = (option == 'e')
526 ? dostring(L, extra, "=(command line)")
527 : dolibrary(L, extra);
528 if (status != LUA_OK) return 0;
529 }
530 }
531 return 1;
532}
533
534
535

Callers 1

pmainFunction · 0.85

Calls 2

dostringFunction · 0.85
dolibraryFunction · 0.85

Tested by

no test coverage detected