]> git.sesse.net Git - vlc/blobdiff - src/config/getopt.c
getopt: remove unused ordering modes
[vlc] / src / config / getopt.c
index 8c5b89099a74aaea068ad8d51b5c5c4b3a8357df..24406ccdebf53679b95802a6874bab19efb1907d 100644 (file)
@@ -45,9 +45,7 @@
 
 /* For communication from `getopt' to the caller.
    When `getopt' finds an option that takes an argument,
-   the argument value is returned here.
-   Also, when `ordering' is RETURN_IN_ORDER,
-   each non-option ARGV-element is returned here.  */
+   the argument value is returned here.  */
 
 char *vlc_optarg = NULL;
 
@@ -99,26 +97,15 @@ int vlc_optopt = '?';
    to be given in any order, even with programs that were not written to
    expect this.
 
-   RETURN_IN_ORDER is an option available to programs that were written
-   to expect options and other ARGV-elements in any order and that care about
-   the ordering of the two.  We describe each non-option ARGV-element
-   as if it were the argument of an option with character code 1.
-   Using `-' as the first character of the list of option characters
-   selects this mode of operation.
-
    The special argument `--' forces an end of option-scanning regardless
-   of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
-   `--' can cause `getopt' to return -1 with `optind' != ARGC.  */
+   of the value of `ordering'.  */
 
 static enum
 {
-    REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+    REQUIRE_ORDER, PERMUTE
 }
 ordering;
 
-/* Value of POSIXLY_CORRECT environment variable.  */
-static char *posixly_correct;
-
 /* Handle permutation of arguments.  */
 
 /* Describe the part of ARGV that contains non-options that have
@@ -197,16 +184,8 @@ static void
 
 /* Initialize the internal data when the first call is made.  */
 
-static const char *vlc_getopt_initialize(int, char *const *, const char *);
-
-static const char *
-     vlc_getopt_initialize(argc, argv, optstring)
-     int argc;
-     char *const *argv;
-     const char *optstring;
+static const char *vlc_getopt_initialize(const char *optstring)
 {
-    (void)argc;
-    (void)argv;
     /* Start processing options with ARGV-element 1 (since ARGV-element 0
        is the program name); the sequence of previously skipped
        non-option ARGV-elements is empty.  */
@@ -215,21 +194,11 @@ static const char *
 
     nextchar = NULL;
 
-    posixly_correct = getenv("POSIXLY_CORRECT");
+    const char *posixly_correct = getenv("POSIXLY_CORRECT");
 
     /* Determine how to handle the ordering of options and nonoptions.  */
 
-    if (optstring[0] == '-')
-    {
-        ordering = RETURN_IN_ORDER;
-        ++optstring;
-    }
-    else if (optstring[0] == '+')
-    {
-        ordering = REQUIRE_ORDER;
-        ++optstring;
-    }
-    else if (posixly_correct != NULL)
+    if (posixly_correct != NULL)
         ordering = REQUIRE_ORDER;
     else
         ordering = PERMUTE;
@@ -265,7 +234,7 @@ static const char *
 
    If OPTSTRING starts with `-' or `+', it requests different methods of
    handling the non-option ARGV-elements.
-   See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+   See the comments about REQUIRE_ORDER, above.
 
    Long-named options begin with `--' instead of `-'.
    Their names may be abbreviated as long as the abbreviation is unique
@@ -299,7 +268,7 @@ int
 
     if (vlc_optind == 0)
     {
-        optstring = vlc_getopt_initialize(argc, argv, optstring);
+        optstring = vlc_getopt_initialize(optstring);
         vlc_optind = 1;    /* Don't scan ARGV[0], the program name.  */
     }