** 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.
| 224 | ** If there is no script name, assume interpreter's name as base. |
| 225 | */ |
| 226 | static void createargtable (lua_State *L, char **argv, int argc, int script) { |
| 227 | int i, narg; |
| 228 | if (script == argc) script = 0; /* no script name? */ |
| 229 | narg = argc - (script + 1); /* number of positive indices */ |
| 230 | lua_createtable(L, narg, script + 1); |
| 231 | for (i = 0; i < argc; i++) { |
| 232 | lua_pushstring(L, argv[i]); |
| 233 | lua_rawseti(L, -2, i - script); |
| 234 | } |
| 235 | lua_setglobal(L, "arg"); |
| 236 | } |
| 237 | |
| 238 | |
| 239 | static int dochunk (lua_State *L, int status) { |
no test coverage detected