[rfa] as.c - always NULL terminate options list
Andrew Cagney
ac131313@cygnus.com
Mon Jul 3 22:17:00 GMT 2000
Hello,
Found that a target had forgotten to NULL (zero) terminate the machine
dependant option list. Rather than ``fix'' that target, I figured
making the code that constructs the long option list more robust would
be better.
Ok?
Andrew
Tue Jul 4 14:08:28 2000 Andrew Cagney <cagney@b1.cygnus.com>
* as.c (parse_args): Always NULL terminate the long option list.
Index: as.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/as.c,v
retrieving revision 1.134
diff -p -r1.134 as.c
*** as.c 2000/05/29 16:47:31 1.134
--- as.c 2000/07/04 05:11:29
*************** parse_args (pargc, pargv)
*** 431,443 ****
{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
};
! /* Construct the option lists from the standard list and the
! target dependent list. */
shortopts = concat (std_shortopts, md_shortopts, (char *) NULL);
! longopts = (struct option *) xmalloc (sizeof (std_longopts) + md_longopts_size);
memcpy (longopts, std_longopts, sizeof (std_longopts));
memcpy ((char *) longopts + sizeof (std_longopts),
md_longopts, md_longopts_size);
/* Make a local copy of the old argv. */
old_argc = *pargc;
--- 431,447 ----
{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
};
! /* Construct the option lists from the standard list and the target
! dependent list. Include space for an extra NULL option and
! always NULL terminate. */
shortopts = concat (std_shortopts, md_shortopts, (char *) NULL);
! longopts = (struct option *) xmalloc (sizeof (std_longopts)
! + md_longopts_size + 1);
memcpy (longopts, std_longopts, sizeof (std_longopts));
memcpy ((char *) longopts + sizeof (std_longopts),
md_longopts, md_longopts_size);
+ memset ((char *) longopts + sizeof (std_longopts) + md_longopts_size,
+ 0, sizeof (struct option));
/* Make a local copy of the old argv. */
old_argc = *pargc;
More information about the Binutils
mailing list