Lines Matching full:state
61 #define PRINT_ERROR ((state->opterr) && (*options != ':'))
169 parse_long_options(struct getopt_state *state, char * const *nargv, in parse_long_options() argument
180 current_argv = state->place; in parse_long_options()
202 state->optind++; in parse_long_options()
252 state->optopt = 0; in parse_long_options()
270 state->optopt = long_options[match].val; in parse_long_options()
272 state->optopt = 0; in parse_long_options()
283 state->optarg = has_equal; in parse_long_options()
288 state->optarg = nargv[state->optind++]; in parse_long_options()
292 && (state->optarg == NULL)) { in parse_long_options()
308 state->optopt = long_options[match].val; in parse_long_options()
310 state->optopt = 0; in parse_long_options()
312 --state->optind; in parse_long_options()
317 --state->optind; in parse_long_options()
327 state->optopt = 0; in parse_long_options()
346 getopt_internal(struct getopt_state *state, int nargc, char * const *nargv, argument
381 if (state->optind == 0) {
382 state->optind = state->optreset = 1;
385 state->optarg = NULL;
386 if (state->optreset) {
387 state->nonopt_start = state->nonopt_end = -1;
390 if (state->optreset || !*(state->place)) {/* update scanning pointer */
391 state->optreset = 0;
392 if (state->optind >= nargc) { /* end of argument vector */
393 state->place = EMSG;
394 if (state->nonopt_end != -1) {
396 permute_args(state->nonopt_start,
397 state->nonopt_end,
398 state->optind, nargv);
399 state->optind -= state->nonopt_end -
400 state->nonopt_start;
401 } else if (state->nonopt_start != -1) {
406 state->optind = state->nonopt_start;
408 state->nonopt_start = state->nonopt_end = -1;
411 state->place = nargv[state->optind];
412 if (*(state->place) != '-' ||
414 state->place[1] == '\0') {
416 (state->place[1] == '\0' && strchr(options, '-') == NULL)) {
418 state->place = EMSG; /* found non-option */
424 state->optarg = nargv[state->optind++];
435 if (state->nonopt_start == -1) {
436 state->nonopt_start = state->optind;
437 } else if (state->nonopt_end != -1) {
438 permute_args(state->nonopt_start,
439 state->nonopt_end,
440 state->optind,
442 state->nonopt_start = state->optind -
443 (state->nonopt_end - state->nonopt_start);
444 state->nonopt_end = -1;
446 state->optind++;
450 if (state->nonopt_start != -1 && state->nonopt_end == -1) {
451 state->nonopt_end = state->optind;
457 if (state->place[1] != '\0' && *++(state->place) == '-' &&
458 state->place[1] == '\0') {
459 state->optind++;
460 state->place = EMSG;
465 if (state->nonopt_end != -1) {
466 permute_args(state->nonopt_start,
467 state->nonopt_end,
468 state->optind,
470 state->optind -= state->nonopt_end -
471 state->nonopt_start;
473 state->nonopt_start = state->nonopt_end = -1;
484 if (long_options != NULL && state->place != nargv[state->optind] &&
485 (*(state->place) == '-' || (flags & FLAG_LONGONLY))) {
490 if (*(state->place) == '-') {
491 state->place++; /* --foo long option */
495 } else if (*(state->place) != ':' && strchr(options, *(state->place)) != NULL) {
499 optchar = parse_long_options(state, nargv, options,
503 state->place = EMSG;
507 optchar = (int)*(state->place)++;
510 (optchar == (int)'-' && *(state->place) != '\0') ||
517 if (optchar == (int)'-' && *(state->place) == '\0') {
520 if (!*(state->place)) {
521 ++state->optind;
532 state->optopt = optchar;
537 if (*(state->place)) { /* no space */
539 } else if (++(state->optind) >= nargc) { /* no arg */
540 state->place = EMSG;
544 state->optopt = optchar;
546 } else if ((state->optind) < nargc) {
547 state->place = nargv[state->optind];
552 optchar = parse_long_options(state, nargv, options,
554 state->place = EMSG;
558 if (!*(state->place)) {
559 ++state->optind;
562 state->optarg = NULL;
563 if (*(state->place)) { /* no white space */
564 state->optarg = state->place;
566 if (++state->optind >= nargc) { /* no arg */
567 state->place = EMSG;
571 state->optopt = optchar;
574 state->optarg = nargv[state->optind];
576 state->place = EMSG;
577 ++state->optind;
592 struct getopt_state *state; local
595 /* Get state of the current thread */
596 state = getopt_state_get();
598 ret = getopt_internal(state, nargc, nargv, options, long_options, idx,
601 z_getopt_global_state_update(state);
615 struct getopt_state *state; local
618 /* Get state of the current thread */
619 state = getopt_state_get();
621 ret = getopt_internal(state, nargc, nargv, options, long_options, idx,
624 z_getopt_global_state_update(state);