out_file_name = strdup (optarg); if (!out_file_name) as_fatal ("virtual memory exhausted");
out_file_name = xstrdup (optarg);
parse_args (pargc, pargv)     int *pargc;     char ***pargv;{  int old_argc, new_argc;  char **old_argv, **new_argv;  /* Starting the short option string with '-' is for programs that     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.  */  char *shortopts;  extern CONST char *md_shortopts;  static const char std_shortopts[] =    {      '-', 'J',#ifndef WORKING_DOT_WORD      /* -K is not meaningful if .word is not being hacked.  */      'K',#endif      'L', 'M', 'R', 'W', 'Z', 'f', 'a', ':', ':', 'D', 'I', ':', 'o', ':',#ifndef VMS      /* -v takes an argument on VMS, so we don't make it a generic         option.  */      'v',#endif      'w', 'X',      '\0'    };  struct option *longopts;  extern struct option md_longopts[];  extern size_t md_longopts_size;  static const struct option std_longopts[] = {#define OPTION_HELP (OPTION_STD_BASE)    {"help", no_argument, NULL, OPTION_HELP},    {"mri", no_argument, NULL, 'M'},#define OPTION_NOCPP (OPTION_STD_BASE + 1)    {"nocpp", no_argument, NULL, OPTION_NOCPP},#define OPTION_STATISTICS (OPTION_STD_BASE + 2)    {"statistics", no_argument, NULL, OPTION_STATISTICS},#define OPTION_VERSION (OPTION_STD_BASE + 3)    {"version", no_argument, NULL, OPTION_VERSION},#define OPTION_DUMPCONFIG (OPTION_STD_BASE + 4)    {"dump-config", no_argument, NULL, OPTION_DUMPCONFIG},#define OPTION_VERBOSE (OPTION_STD_BASE + 5)    {"verbose", no_argument, NULL, OPTION_VERBOSE},#define OPTION_EMULATION (OPTION_STD_BASE + 6)    {"emulation", required_argument, NULL, OPTION_EMULATION},#define OPTION_DEFSYM (OPTION_STD_BASE + 7)    {"defsym", required_argument, NULL, OPTION_DEFSYM}  };  /* 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;  old_argv = *pargv;  /* Initialize a new argv that contains no options.  */  new_argv = (char **) xmalloc (sizeof (char *) * (old_argc + 1));  new_argv[0] = old_argv[0];  new_argc = 1;  new_argv[new_argc] = NULL;  while (1)    {      /* getopt_long_only is like getopt_long, but '-' as well as '--' can	 indicate a long option.  */      int longind;      int optc = getopt_long_only (old_argc, old_argv, shortopts, longopts,				   &longind);      if (optc == -1)	break;      switch (optc)	{	default:	  /* md_parse_option should return 1 if it recognizes optc,	     0 if not.  */	  if (md_parse_option (optc, optarg) != 0)	    break;	  /* `-v' isn't included in the general short_opts list, so check for	     it explicity here before deciding we've gotten a bad argument.  */	  if (optc == 'v')	    {#ifdef VMS	      /* Telling getopt to treat -v's value as optional can result		 in it picking up a following filename argument here.  The		 VMS code in md_parse_option can return 0 in that case,		 but it has no way of pushing the filename argument back.  */	      if (optarg && *optarg)		new_argv[new_argc++] = optarg,  new_argv[new_argc] = NULL;	      else#else	      case 'v':#endif	      case OPTION_VERBOSE:		print_version_id ();	      break;	    }	  /*FALLTHRU*/	case '?':	  exit (EXIT_FAILURE);	case 1:			/* File name.  */	  if (!strcmp (optarg, "-"))	    optarg = "";	  new_argv[new_argc++] = optarg;	  new_argv[new_argc] = NULL;	  break;	case OPTION_HELP:	  show_usage (stdout);	  exit (EXIT_SUCCESS);	case OPTION_NOCPP:	  break;	case OPTION_STATISTICS:	  flag_print_statistics = 1;	  break;	case OPTION_VERSION:	  print_version_id ();	  exit (EXIT_SUCCESS);	case OPTION_EMULATION:#ifdef USE_EMULATIONS	  if (strcmp (optarg, this_emulation->name))	    as_fatal ("multiple emulation names specified");#else	  as_fatal ("emulations not handled in this configuration");#endif	  break;	case OPTION_DUMPCONFIG:	  fprintf (stderr, "alias = %s\n", TARGET_ALIAS);	  fprintf (stderr, "canonical = %s\n", TARGET_CANONICAL);	  fprintf (stderr, "cpu-type = %s\n", TARGET_CPU);#ifdef TARGET_OBJ_FORMAT	  fprintf (stderr, "format = %s\n", TARGET_OBJ_FORMAT);#endif#ifdef TARGET_FORMAT	  fprintf (stderr, "bfd-target = %s\n", TARGET_FORMAT);#endif	  exit (EXIT_SUCCESS);	case OPTION_DEFSYM:	  {	    char *s;	    long i;	    symbolS *sym;	    for (s = optarg; *s != '\0' && *s != '='; s++)	      ;	    if (*s == '\0')	      as_fatal ("bad defsym; format is --defsym name=value");	    *s++ = '\0';	    i = strtol (s, (char **) NULL, 0);	    sym = symbol_new (optarg, absolute_section, (valueT) i,			      &zero_address_frag);	    symbol_table_insert (sym);	  }	  break;	case 'J':	  flag_signed_overflow_ok = 1;	  break;#ifndef WORKING_DOT_WORD	case 'K':	  flag_warn_displacement = 1;	  break;#endif	case 'L':	  flag_keep_locals = 1;	  break;	case 'M':	  flag_mri = 1;	  break;	case 'R':	  flag_readonly_data_in_text = 1;	  break;	case 'W':	  flag_no_warnings = 1;	  break;	case 'Z':	  flag_always_generate_output = 1;	  break;	case 'a':	  if (optarg)	    {	      while (*optarg)		{		  switch (*optarg)		    {		    case 'd':		      listing |= LISTING_NODEBUG;		      break;		    case 'h':		      listing |= LISTING_HLL;		      break;		    case 'l':		      listing |= LISTING_LISTING;		      break;		    case 'n':		      listing |= LISTING_NOFORM;		      break;		    case 's':		      listing |= LISTING_SYMBOLS;		      break;		    case '=':		      listing_filename = strdup (optarg + 1);		      if (listing_filename == NULL)			as_fatal ("virtual memory exhausted");		      optarg += strlen (listing_filename);		      break;		    default:		      as_fatal ("invalid listing option `%c'", *optarg);		      break;		    }		  optarg++;		}	    }	  if (!listing)	    listing = LISTING_DEFAULT;	  break;	case 'D':	  /* DEBUG is implemented: it debugs different */	  /* things from other people's assemblers. */	  flag_debug = 1;	  break;	case 'f':	  flag_no_comments = 1;	  break;	case 'I':	  {			/* Include file directory */	    char *temp = strdup (optarg);	    if (!temp)	      as_fatal ("virtual memory exhausted");	    add_include_dir (temp);	    break;	  }	case 'o':	  out_file_name = strdup (optarg);	  if (!out_file_name)	    as_fatal ("virtual memory exhausted");	  break;	case 'w':	  break;	case 'X':	  /* -X means treat warnings as errors */	  break;	}    }  free (shortopts);  free (longopts);  *pargc = new_argc;  *pargv = new_argv;}