* lexsup.c (parse_args): Don't pass shortopts to second call to
authorAlan Modra <amodra@gmail.com>
Thu, 13 Dec 2001 09:38:11 +0000 (09:38 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 13 Dec 2001 09:38:11 +0000 (09:38 +0000)
getopt functions.  Restore optind rather than decrementing before
second call.  Remove errind as it now duplicates last_optind.

ld/ChangeLog
ld/lexsup.c

index 54739eea4bc128bc6cff923a7b27793991721fb5..9e05021beda3a2e7248cb71f803a37c8a237c90c 100644 (file)
@@ -1,3 +1,9 @@
+2001-12-13  Alan Modra  <amodra@bigpond.net.au>
+
+       * lexsup.c (parse_args): Don't pass shortopts to second call to
+       getopt functions.  Restore optind rather than decrementing before
+       second call.  Remove errind as it now duplicates last_optind.
+
 2001-12-11  Christopher Faylor  <cgf@redhat.com>
 
        * emultempl/pe.em (gld_${EMULATION_NAME}_list_options): Fix typo.
index b9b74bdf0b2aa1847927929c31fc08d99ec0ae9f..ca2e9a1a46cc42e22c37697321b923f85fd4f9ba 100644 (file)
@@ -542,7 +542,7 @@ parse_args (argc, argv)
   last_optind = -1;
   while (1)
     {
-      int longind, errind;
+      int longind;
       int optc;
 
       /* Using last_optind lets us avoid calling ldemul_parse_args
@@ -552,21 +552,18 @@ parse_args (argc, argv)
         -nx, in which the -n is parsed as a single option, and we
         loop around to pick up the -x.  */
       if (optind != last_optind)
-       {
-         if (ldemul_parse_args (argc, argv))
-           continue;
-         last_optind = optind;
-       }
+       if (ldemul_parse_args (argc, argv))
+         continue;
 
       /* getopt_long_only is like getopt_long, but '-' as well as '--'
         can indicate a long option.  */
       opterr = 0;
-      errind = optind;
+      last_optind = optind;
       optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
       if (optc == '?')
        {
-         --optind;
-         optc = getopt_long (argc, argv, shortopts, really_longopts, &longind);
+         optind = last_optind;
+         optc = getopt_long (argc, argv, "-", really_longopts, &longind);
        }
 
       if (optc == -1)
@@ -575,7 +572,7 @@ parse_args (argc, argv)
       switch (optc)
        {
        case '?':
-         einfo (_("%P: unrecognized option '%s'\n"), argv[errind]);
+         einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]);
        default:
          einfo (_("%P%F: use the --help option for usage information\n"));
 
This page took 0.029239 seconds and 4 git commands to generate.