diff options
-rw-r--r-- | lua.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.157 2005/12/29 16:23:32 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.158 2006/04/10 18:27:23 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -252,17 +252,30 @@ static int handle_script (lua_State *L, char **argv, int n) { | |||
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | /* check that argument has no extra characters at the end */ | ||
256 | #define notail(x) {if ((x)[2] != '\0') return -1;} | ||
257 | |||
258 | |||
255 | static int collectargs (char **argv, int *pi, int *pv, int *pe) { | 259 | static int collectargs (char **argv, int *pi, int *pv, int *pe) { |
256 | int i; | 260 | int i; |
257 | for (i = 1; argv[i] != NULL; i++) { | 261 | for (i = 1; argv[i] != NULL; i++) { |
258 | if (argv[i][0] != '-') /* not an option? */ | 262 | if (argv[i][0] != '-') /* not an option? */ |
259 | return i; | 263 | return i; |
260 | switch (argv[i][1]) { /* option */ | 264 | switch (argv[i][1]) { /* option */ |
261 | case '-': return (argv[i+1] != NULL ? i+1 : 0); | 265 | case '-': |
262 | case '\0': return i; | 266 | notail(argv[i]); |
263 | case 'i': *pi = 1; /* go through */ | 267 | return (argv[i+1] != NULL ? i+1 : 0); |
264 | case 'v': *pv = 1; break; | 268 | case '\0': |
265 | case 'e': *pe = 1; /* go through */ | 269 | return i; |
270 | case 'i': | ||
271 | notail(argv[i]); | ||
272 | *pi = 1; /* go through */ | ||
273 | case 'v': | ||
274 | notail(argv[i]); | ||
275 | *pv = 1; | ||
276 | break; | ||
277 | case 'e': | ||
278 | *pe = 1; /* go through */ | ||
266 | case 'l': | 279 | case 'l': |
267 | if (argv[i][2] == '\0') { | 280 | if (argv[i][2] == '\0') { |
268 | i++; | 281 | i++; |