* ar.c (main): Split ranlib path.

(ranlib_usage): New
	(ranlib_main): New
This commit is contained in:
Alan Modra 2010-12-08 04:58:23 +00:00
parent 4937863dfe
commit 1154c3efa1
2 changed files with 116 additions and 85 deletions

View file

@ -1,3 +1,9 @@
2010-12-08 Arnaud Lacombe <lacombar@gmail.com>
* ar.c (main): Split ranlib path.
(ranlib_usage): New
(ranlib_main): New
2010-12-03 Doug Evans <dje@google.com>
* dwarf.c: #include "bfd_stdint.h".

View file

@ -225,8 +225,6 @@ usage (int help)
s = help ? stdout : stderr;
if (! is_ranlib)
{
/* xgettext:c-format */
const char * command_line =
#if BFD_SUPPORTS_PLUGINS
@ -268,10 +266,24 @@ usage (int help)
fprintf (s, _(" optional:\n"));
fprintf (s, _(" --plugin <p> - load the specified plugin\n"));
#endif
ar_emul_usage (s);
}
else
{
list_supported_targets (program_name, s);
if (REPORT_BUGS_TO[0] && help)
fprintf (s, _("Report bugs to %s\n"), REPORT_BUGS_TO);
xexit (help ? 0 : 1);
}
static void
ranlib_usage(int help)
{
FILE *s;
s = help ? stdout : stderr;
/* xgettext:c-format */
fprintf (s, _("Usage: %s [options] archive\n"), program_name);
fprintf (s, _(" Generate an index to speed access to archives\n"));
@ -285,7 +297,6 @@ usage (int help)
-t Update the archive's symbol map timestamp\n\
-h --help Print this help message\n\
-v --version Print version information\n"));
}
list_supported_targets (program_name, s);
@ -343,6 +354,52 @@ remove_output (void)
}
}
static void
ranlib_main(int argc, char **argv)
{
int arg_index, status = 0;
bfd_boolean touch = FALSE;
if (argc > 1 && argv[1][0] == '-')
{
if (strcmp (argv[1], "--help") == 0)
ranlib_usage (1);
else if (strcmp (argv[1], "--version") == 0)
{
print_version ("ranlib");
}
}
if (argc < 2
|| strcmp (argv[1], "--help") == 0
|| strcmp (argv[1], "-h") == 0
|| strcmp (argv[1], "-H") == 0)
ranlib_usage (0);
if (strcmp (argv[1], "-V") == 0
|| strcmp (argv[1], "-v") == 0
|| CONST_STRNEQ (argv[1], "--v"))
print_version ("ranlib");
arg_index = 1;
if (strcmp (argv[1], "-t") == 0)
{
++arg_index;
touch = TRUE;
}
while (arg_index < argc)
{
if (! touch)
status |= ranlib_only (argv[arg_index]);
else
status |= ranlib_touch (argv[arg_index]);
++arg_index;
}
xexit (status);
}
/* The option parsing should be in its own function.
It will be when I have getopt working. */
@ -394,18 +451,6 @@ main (int argc, char **argv)
is_ranlib = 0;
}
if (argc > 1 && argv[1][0] == '-')
{
if (strcmp (argv[1], "--help") == 0)
usage (1);
else if (strcmp (argv[1], "--version") == 0)
{
if (is_ranlib)
print_version ("ranlib");
else
print_version ("ar");
}
}
START_PROGRESS (program_name, 0);
@ -423,34 +468,14 @@ main (int argc, char **argv)
argc -= (i - 1);
if (is_ranlib)
{
int status = 0;
bfd_boolean touch = FALSE;
ranlib_main(argc, argv);
if (argc < 2
|| strcmp (argv[1], "--help") == 0
|| strcmp (argv[1], "-h") == 0
|| strcmp (argv[1], "-H") == 0)
usage (0);
if (strcmp (argv[1], "-V") == 0
|| strcmp (argv[1], "-v") == 0
|| CONST_STRNEQ (argv[1], "--v"))
print_version ("ranlib");
arg_index = 1;
if (strcmp (argv[1], "-t") == 0)
if (argc > 1 && argv[1][0] == '-')
{
++arg_index;
touch = TRUE;
}
while (arg_index < argc)
{
if (! touch)
status |= ranlib_only (argv[arg_index]);
else
status |= ranlib_touch (argv[arg_index]);
++arg_index;
}
xexit (status);
if (strcmp (argv[1], "--help") == 0)
usage (1);
else if (strcmp (argv[1], "--version") == 0)
print_version ("ar");
}
if (argc == 2 && strcmp (argv[1], "-M") == 0)