- /* Advance to the next ARGV-element. */
-
- /* Give FIRST_NONOPT & LAST_NONOPT rational values if GNoptind has been
- * moved back by the user (who may also have changed the arguments). */
- if (last_nonopt > GNoptind)
- last_nonopt = GNoptind;
- if (first_nonopt > GNoptind)
- first_nonopt = GNoptind;
-
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- * exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != GNoptind)
- exchange ((char **) argv);
- else if (last_nonopt != GNoptind)
- first_nonopt = GNoptind;
-
- /* Skip any additional non-options
- * and extend the range of non-options previously skipped. */
-
- while (GNoptind < argc && NONOPTION_P)
- GNoptind++;
- last_nonopt = GNoptind;
- }
-
- /* The special ARGV-element `--' means premature end of options.
- * Skip it like a null option,
- * then exchange with previous non-options as if it were an option,
- * then skip everything else like a non-option. */
- if (GNoptind != argc && !strcmp (argv[GNoptind], "--"))
- {
- GNoptind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != GNoptind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = GNoptind;
- last_nonopt = argc;
-
- GNoptind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- * and back over any non-options that we skipped and permuted. */
-
- if (GNoptind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- * that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- GNoptind = first_nonopt;
- return -1;
- }
-
- /* If we have come to a non-option and did not permute it,
- * either stop the scan or describe it to the caller and pass it by. */
-
- if (NONOPTION_P)
- {
- if (ordering == REQUIRE_ORDER)
- return -1;
- GNoptarg = argv[GNoptind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- * Skip the initial punctuation. */
-
- nextchar =
- (argv[GNoptind] + 1 + (longopts != NULL && argv[GNoptind][1] == '-'));