** 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.
| 952 | ** If there is no script name, assume interpreter's name as base. |
| 953 | */ |
| 954 | static void createargtable(lua_State *L, char **argv, int argc, int script) { |
| 955 | int i, narg; |
| 956 | if (script == argc) script = 0; /* no script name? */ |
| 957 | narg = argc - (script + 1); /* number of positive indices */ |
| 958 | lua_createtable(L, narg, script + 1); |
| 959 | for (i = 0; i < argc; i++) { |
| 960 | lua_pushstring(L, argv[i]); |
| 961 | lua_rawseti(L, -2, i - script); |
| 962 | } |
| 963 | lua_setglobal(L, "arg"); |
| 964 | } |
| 965 | |
| 966 | static int handle_luainit(lua_State *L) { |
| 967 | const char *name = "=" LUA_INITVARVERSION; |
no test coverage detected