+ /* Convert old-style tar call by exploding option element and rearranging
+ options accordingly. */
+
+ if (argc > 1 && argv[1][0] != '-')
+ {
+ int new_argc; /* argc value for rearranged arguments */
+ char **new_argv; /* argv value for rearranged arguments */
+ char *const *in; /* cursor into original argv */
+ char **out; /* cursor into rearranged argv */
+ const char *letter; /* cursor into old option letters */
+ char buffer[3]; /* constructed option buffer */
+
+ /* Initialize a constructed option. */
+
+ buffer[0] = '-';
+ buffer[2] = '\0';
+
+ /* Allocate a new argument array, and copy program name in it. */
+
+ new_argc = argc - 1 + strlen (argv[1]);
+ new_argv = xmalloc ((new_argc + 1) * sizeof (*argv));
+ in = argv;
+ out = new_argv;
+ *out++ = *in++;
+
+ /* Copy each old letter option as a separate option. */
+
+ for (letter = *in++; *letter; letter++)
+ {
+ buffer[1] = *letter;
+ *out++ = xstrdup (buffer);
+ }
+
+ /* Copy all remaining options. */
+
+ while (in < argv + argc)
+ *out++ = *in++;
+ *out = NULL;
+
+ /* Replace the old option list by the new one. */
+
+ argc = new_argc;
+ argv = new_argv;
+ }
+
+ while ((c = getopt_long (argc, argv, "hdmpqrtxlcoVsSuvabiMNfPTDU",
+ long_options, NULL)) != EOF)
+ {
+ switch (c)
+ {
+ case 'd':
+ case 'm':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 't':
+ case 'x':
+ if (operation != none)
+ fatal (_("two different operation options specified"));
+ break;
+ }
+
+ switch (c)
+ {
+ case 'h':
+ show_help = 1;
+ break;
+ case 'd':
+ operation = del;
+ operation_alters_arch = TRUE;
+ break;
+ case 'm':
+ operation = move;
+ operation_alters_arch = TRUE;
+ break;
+ case 'p':
+ operation = print_files;
+ break;
+ case 'q':
+ operation = quick_append;
+ operation_alters_arch = TRUE;
+ break;
+ case 'r':
+ operation = replace;
+ operation_alters_arch = TRUE;
+ break;
+ case 't':
+ operation = print_table;
+ break;
+ case 'x':
+ operation = extract;
+ break;
+ case 'l':
+ break;
+ case 'c':
+ silent_create = 1;
+ break;
+ case 'o':
+ preserve_dates = 1;
+ break;
+ case 'V':
+ show_version = TRUE;
+ break;
+ case 's':
+ write_armap = 1;
+ break;
+ case 'S':
+ write_armap = -1;
+ break;
+ case 'u':
+ newer_only = 1;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'a':
+ postype = pos_after;
+ break;
+ case 'b':
+ postype = pos_before;
+ break;
+ case 'i':
+ postype = pos_before;
+ break;
+ case 'M':
+ mri_mode = 1;
+ break;
+ case 'N':
+ counted_name_mode = TRUE;
+ break;
+ case 'f':
+ ar_truncate = TRUE;
+ break;
+ case 'P':
+ full_pathname = TRUE;
+ break;
+ case 'T':
+ make_thin_archive = TRUE;
+ break;
+ case 'D':
+ deterministic = TRUE;
+ break;
+ case 'U':
+ deterministic = FALSE;
+ break;
+ case OPTION_PLUGIN:
+#if BFD_SUPPORTS_PLUGINS
+ plugin_target = "plugin";
+ bfd_plugin_set_plugin (optarg);
+#else
+ fprintf (stderr, _("sorry - this program has been built without plugin support\n"));
+ xexit (1);
+#endif
+ break;
+ case OPTION_TARGET:
+ target = optarg;
+ break;
+ case 0: /* A long option that just sets a flag. */
+ break;
+ default:
+ usage (0);
+ }
+ }
+
+ return &argv[optind];
+}
+
+/* If neither -D nor -U was not specified explicitly,
+ then use the configured default. */
+static void
+default_deterministic (void)
+{
+ if (deterministic < 0)
+ deterministic = DEFAULT_AR_DETERMINISTIC;
+}
+
+static void
+ranlib_main (int argc, char **argv)