This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
A patch for lexsup.c
- To: binutils at sourceware dot cygnus dot com
- Subject: A patch for lexsup.c
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Wed, 13 Jun 2001 14:33:13 -0700
The current ld does
# ld -wfoo
ld: unrecognized option 'ld'
ld: use the --help option for usage information
# ld --wfoo
ld: unrecognized option '--wfoo'
ld: use the --help option for usage information
The problem is we are using wrong optind to report unrecognized
option with only one `-'. Here is a patch.
H.J.
----
2001-06-12 H.J. Lu <hjl@gnu.org>
* lexsup.c (parse_args); Save optind to report unrecognized
option.
Index: lexsup.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/lexsup.c,v
retrieving revision 1.31
diff -u -p -r1.31 lexsup.c
--- lexsup.c 2001/05/23 18:36:07 1.31
+++ lexsup.c 2001/06/13 21:28:50
@@ -540,7 +540,7 @@ parse_args (argc, argv)
last_optind = -1;
while (1)
{
- int longind;
+ int longind, errind;
int optc;
/* Using last_optind lets us avoid calling ldemul_parse_args
@@ -559,6 +559,7 @@ parse_args (argc, argv)
/* getopt_long_only is like getopt_long, but '-' as well as '--'
can indicate a long option. */
opterr = 0;
+ errind = optind;
optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
if (optc == '?')
{
@@ -573,7 +574,7 @@ parse_args (argc, argv)
{
case '?':
fprintf (stderr, _("%s: unrecognized option '%s'\n"),
- program_name, argv[optind - 1]);
+ program_name, argv[errind]);
default:
fprintf (stderr,
_("%s: use the --help option for usage information\n"),