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

Function collectargs

src/Chain/libraries/glua/lua.cpp:464–506  ·  view source on GitHub ↗

** Traverses all arguments from 'argv', returning a mask with those ** needed before running any Lua code (or an error code if it finds ** any invalid argument). 'first' returns the first not-handled argument ** (either the script name or a bad argument in case of error). */

Source from the content-addressed store, hash-verified

462** (either the script name or a bad argument in case of error).
463*/
464static int collectargs(char **argv, int *first) {
465 int args = 0;
466 int i;
467 for (i = 1; argv[i] != nullptr; i++) {
468 *first = i;
469 if (argv[i][0] != '-') /* not an option? */
470 return args; /* stop handling options */
471 switch (argv[i][1]) { /* else check option */
472 case '-': /* '--' */
473 if (argv[i][2] != '\0') /* extra characters after '--'? */
474 return has_error; /* invalid option */
475 *first = i + 1;
476 return args;
477 case '\0': /* '-' */
478 return args; /* script "name" is '-' */
479 case 'E':
480 if (argv[i][2] != '\0') /* extra characters after 1st? */
481 return has_error; /* invalid option */
482 args |= has_E;
483 break;
484 case 'i':
485 args |= has_i; /* (-i implies -v) *//* FALLTHROUGH */
486 case 'v':
487 if (argv[i][2] != '\0') /* extra characters after 1st? */
488 return has_error; /* invalid option */
489 args |= has_v;
490 break;
491 case 'e':
492 args |= has_e; /* FALLTHROUGH */
493 case 'l': /* both options need an argument */
494 if (argv[i][2] == '\0') { /* no concatenated argument? */
495 i++; /* try next 'argv' */
496 if (argv[i] == nullptr || argv[i][0] == '-')
497 return has_error; /* no next argument or it is another option */
498 }
499 break;
500 default: /* invalid option */
501 return has_error;
502 }
503 }
504 *first = i; /* no script name */
505 return args;
506}
507
508
509/*

Callers 1

pmainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected