| 190 | |
| 191 | |
| 192 | static int getargs (lua_State *L, char **argv, int n) { |
| 193 | int narg; |
| 194 | int i; |
| 195 | int argc = 0; |
| 196 | while (argv[argc]) argc++; /* count total number of arguments */ |
| 197 | narg = argc - (n + 1); /* number of arguments to the script */ |
| 198 | luaL_checkstack(L, narg + 3, "too many arguments to script"); |
| 199 | for (i=n+1; i < argc; i++) |
| 200 | lua_pushstring(L, argv[i]); |
| 201 | lua_createtable(L, narg, n + 1); |
| 202 | for (i=0; i < argc; i++) { |
| 203 | lua_pushstring(L, argv[i]); |
| 204 | lua_rawseti(L, -2, i - n); |
| 205 | } |
| 206 | return narg; |
| 207 | } |
| 208 | |
| 209 | |
| 210 | static int dofile (lua_State *L, const char *name) { |
no test coverage detected