This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: infinite output
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: "I.S.Kuten" <vanokuten at hitron dot co dot kr>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 13 Dec 2001 20:06:28 +1030
- Subject: Re: infinite output
- References: <200112130633.fBD6X3M17397@hitron.co.kr>
On Thu, Dec 13, 2001 at 03:37:36PM +0900, I.S.Kuten wrote:
>
> but when I issue ./ld -Vv or certainly wrong option -vv
> I obtain infinite output , that i can't stop .
Hah, don't do that then. Here's a fix.
* 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.
--
Alan Modra
Index: lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.45
diff -u -p -r1.45 lexsup.c
--- lexsup.c 2001/12/07 12:41:21 1.45
+++ lexsup.c 2001/12/13 09:31:00
@@ -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"));