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

Function createargtable

src/Chain/libraries/glua/single_glua_src/main.cpp:169–179  ·  view source on GitHub ↗

** Create the 'arg' table, which stores all arguments from the ** command line ('argv'). It should be aligned so that, at index 0, ** it has 'argv[script]', which is the script name. The arguments ** to the script (everything after 'script') go to positive indices; ** other arguments (before the script name) go to negative indices. ** If there is no script name, assume interpreter's name as base.

Source from the content-addressed store, hash-verified

167** If there is no script name, assume interpreter's name as base.
168*/
169static void createargtable(lua_State *L, char **argv, int argc, int script) {
170 int i, narg;
171 if (script == argc) script = 0; /* no script name? */
172 narg = argc - (script + 1); /* number of positive indices */
173 lua_createtable(L, narg, script + 1);
174 for (i = 0; i < argc; i++) {
175 lua_pushstring(L, argv[i]);
176 lua_rawseti(L, -2, i - script);
177 }
178 lua_setglobal(L, "arg");
179}
180
181
182static int dochunk(lua_State *L, int status) {

Callers 1

pmainFunction · 0.70

Calls 4

lua_createtableFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawsetiFunction · 0.85
lua_setglobalFunction · 0.85

Tested by

no test coverage detected