References _, _getopt_initialize(), cob_getopt_initialized, cob_optarg, cob_opterr, cob_optind, cob_optopt, exchange(), first_nonopt, option::flag, option::has_arg, last_nonopt, option::name, nextchar, NONOPTION_P, NULL, ordering, p, PERMUTE, REQUIRE_ORDER, seen_short, and option::val.
Referenced by cob_sys_getopt_long_long(), and process_command_line().
393 if (cob_optind == argc)
435 if (longopts !=
NULL && (argv[cob_optind][1] ==
'-'
436 || (long_only && !
seen_short && (argv[cob_optind][2] || !strchr (optstring, argv[cob_optind][1])))))
446 for (nameend =
nextchar; *nameend && *nameend !=
'='; nameend++)
451 for (p = longopts, option_index = 0; p->
name; p++, option_index++)
454 if ((
unsigned int) (nameend -
nextchar)
455 == (
unsigned int) strlen (p->
name))
459 indfound = option_index;
463 else if (pfound ==
NULL)
467 indfound = option_index;
485 fprintf (stderr,
_(
"%s: option `%s' is ambiguous\n"),
486 argv[0], argv[cob_optind]);
496 option_index = indfound;
508 if (argv[cob_optind - 1][1] ==
'-')
512 _(
"%s: option `--%s' doesn't allow an argument\n"),
513 argv[0], pfound->
name);
519 _(
"%s: option `%c%s' doesn't allow an argument\n"),
520 argv[0], argv[cob_optind - 1][0], pfound->
name);
532 if (cob_optind < argc)
539 _(
"%s: option `%s' requires an argument\n"),
540 argv[0], argv[cob_optind - 1]);
544 return optstring[0] ==
':' ?
':' :
'?';
549 *longind = option_index;
562 if (!long_only || argv[cob_optind][1] ==
'-'
567 if (argv[cob_optind][1] ==
'-')
570 fprintf (stderr,
_(
"%s: unrecognized option `--%s'\n"),
576 fprintf (stderr,
_(
"%s: unrecognized option `%c%s'\n"),
577 argv[0], argv[cob_optind][0],
nextchar);
591 char *temp = strchr (optstring, c);
600 if (temp ==
NULL || c ==
':')
604 fprintf (stderr,
_(
"%s: invalid option -- %c\n"), argv[0], c);
611 if (temp[0] ==
'W' && temp[1] ==
';')
629 else if (cob_optind == argc)
634 fprintf (stderr,
_(
"%s: option requires an argument -- %c\n"),
638 if (optstring[0] ==
':')
658 for (p = longopts, option_index = 0; p->
name; p++, option_index++)
661 if ((
unsigned int) (nameend -
nextchar) == strlen (p->
name))
665 indfound = option_index;
669 else if (pfound ==
NULL)
673 indfound = option_index;
683 fprintf (stderr,
_(
"%s: option `-W %s' is ambiguous\n"),
684 argv[0], argv[cob_optind]);
693 option_index = indfound;
704 fprintf (stderr,
_(
"\
705 %s: option `-W %s' doesn't allow an argument\n"),
706 argv[0], pfound->
name);
716 if (cob_optind < argc)
723 _(
"%s: option `%s' requires an argument\n"),
724 argv[0], argv[cob_optind - 1]);
728 return optstring[0] ==
':' ?
':' :
'?';
733 *longind = option_index;
768 else if (cob_optind == argc)
774 _(
"%s: option requires an argument -- %c\n"),
779 if (optstring[0] ==
':')