From: Arnaud Lacombe <lacombar@gmail.com>
To: binutils@sourceware.org
Cc: Arnaud Lacombe <lacombar@gmail.com>
Subject: [PATCH 1/3] binutils/ar: split ar/ranlib path
Date: Sat, 04 Dec 2010 03:37:00 -0000 [thread overview]
Message-ID: <1291433814-27666-1-git-send-email-lacombar@gmail.com> (raw)
In-Reply-To: <AANLkTi=8AJtMnjea3S=vA7zk0Ymm6iWVSoG+tM76k-5R@mail.gmail.com>
2010-12-02 Arnaud Lacombe <lacombar@gmail.com>
* ar.c (main): Split ranlib path.
(ranlib_usage): New
(ranlib_main): New
---
binutils/ar.c | 197 ++++++++++++++++++++++++++++++++-------------------------
1 files changed, 111 insertions(+), 86 deletions(-)
diff --git a/binutils/ar.c b/binutils/ar.c
index a08a991..29dcb4a 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -225,67 +225,78 @@ usage (int help)
s = help ? stdout : stderr;
- if (! is_ranlib)
- {
- /* xgettext:c-format */
- const char * command_line =
+ /* xgettext:c-format */
+ const char * command_line =
#if BFD_SUPPORTS_PLUGINS
_("Usage: %s [emulation options] [--plugin <name>] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n");
#else
_("Usage: %s [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n");
#endif
- fprintf (s, command_line, program_name);
-
- /* xgettext:c-format */
- fprintf (s, _(" %s -M [<mri-script]\n"), program_name);
- fprintf (s, _(" commands:\n"));
- fprintf (s, _(" d - delete file(s) from the archive\n"));
- fprintf (s, _(" m[ab] - move file(s) in the archive\n"));
- fprintf (s, _(" p - print file(s) found in the archive\n"));
- fprintf (s, _(" q[f] - quick append file(s) to the archive\n"));
- fprintf (s, _(" r[ab][f][u] - replace existing or insert new file(s) into the archive\n"));
- fprintf (s, _(" s - act as ranlib\n"));
- fprintf (s, _(" t - display contents of archive\n"));
- fprintf (s, _(" x[o] - extract file(s) from the archive\n"));
- fprintf (s, _(" command specific modifiers:\n"));
- fprintf (s, _(" [a] - put file(s) after [member-name]\n"));
- fprintf (s, _(" [b] - put file(s) before [member-name] (same as [i])\n"));
- fprintf (s, _(" [D] - use zero for timestamps and uids/gids\n"));
- fprintf (s, _(" [N] - use instance [count] of name\n"));
- fprintf (s, _(" [f] - truncate inserted file names\n"));
- fprintf (s, _(" [P] - use full path names when matching\n"));
- fprintf (s, _(" [o] - preserve original dates\n"));
- fprintf (s, _(" [u] - only replace files that are newer than current archive contents\n"));
- fprintf (s, _(" generic modifiers:\n"));
- fprintf (s, _(" [c] - do not warn if the library had to be created\n"));
- fprintf (s, _(" [s] - create an archive index (cf. ranlib)\n"));
- fprintf (s, _(" [S] - do not build a symbol table\n"));
- fprintf (s, _(" [T] - make a thin archive\n"));
- fprintf (s, _(" [v] - be verbose\n"));
- fprintf (s, _(" [V] - display the version number\n"));
- fprintf (s, _(" @<file> - read options from <file>\n"));
+ fprintf (s, command_line, program_name);
+
+ /* xgettext:c-format */
+ fprintf (s, _(" %s -M [<mri-script]\n"), program_name);
+ fprintf (s, _(" commands:\n"));
+ fprintf (s, _(" d - delete file(s) from the archive\n"));
+ fprintf (s, _(" m[ab] - move file(s) in the archive\n"));
+ fprintf (s, _(" p - print file(s) found in the archive\n"));
+ fprintf (s, _(" q[f] - quick append file(s) to the archive\n"));
+ fprintf (s, _(" r[ab][f][u] - replace existing or insert new file(s) into the archive\n"));
+ fprintf (s, _(" s - act as ranlib\n"));
+ fprintf (s, _(" t - display contents of archive\n"));
+ fprintf (s, _(" x[o] - extract file(s) from the archive\n"));
+ fprintf (s, _(" command specific modifiers:\n"));
+ fprintf (s, _(" [a] - put file(s) after [member-name]\n"));
+ fprintf (s, _(" [b] - put file(s) before [member-name] (same as [i])\n"));
+ fprintf (s, _(" [D] - use zero for timestamps and uids/gids\n"));
+ fprintf (s, _(" [N] - use instance [count] of name\n"));
+ fprintf (s, _(" [f] - truncate inserted file names\n"));
+ fprintf (s, _(" [P] - use full path names when matching\n"));
+ fprintf (s, _(" [o] - preserve original dates\n"));
+ fprintf (s, _(" [u] - only replace files that are newer than current archive contents\n"));
+ fprintf (s, _(" generic modifiers:\n"));
+ fprintf (s, _(" [c] - do not warn if the library had to be created\n"));
+ fprintf (s, _(" [s] - create an archive index (cf. ranlib)\n"));
+ fprintf (s, _(" [S] - do not build a symbol table\n"));
+ fprintf (s, _(" [T] - make a thin archive\n"));
+ fprintf (s, _(" [v] - be verbose\n"));
+ fprintf (s, _(" [V] - display the version number\n"));
+ fprintf (s, _(" @<file> - read options from <file>\n"));
#if BFD_SUPPORTS_PLUGINS
- fprintf (s, _(" optional:\n"));
- fprintf (s, _(" --plugin <p> - load the specified plugin\n"));
+ fprintf (s, _(" optional:\n"));
+ fprintf (s, _(" --plugin <p> - load the specified plugin\n"));
#endif
- ar_emul_usage (s);
- }
- else
- {
- /* xgettext:c-format */
- fprintf (s, _("Usage: %s [options] archive\n"), program_name);
- fprintf (s, _(" Generate an index to speed access to archives\n"));
- fprintf (s, _(" The options are:\n\
+
+ ar_emul_usage (s);
+
+ 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"));
+ fprintf (s, _(" The options are:\n\
@<file> Read options from <file>\n"));
#if BFD_SUPPORTS_PLUGINS
- fprintf (s, _("\
+ fprintf (s, _("\
--plugin <name> Load the specified plugin\n"));
#endif
- fprintf (s, _("\
+ fprintf (s, _("\
-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)
+ ranlib_main(argc, argv);
+
+ if (argc > 1 && argv[1][0] == '-')
{
- int status = 0;
- bfd_boolean touch = FALSE;
-
- 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)
- {
- ++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)
--
1.7.2.30.gc37d7.dirty
next prev parent reply other threads:[~2010-12-04 3:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-01 19:27 Using binutils with all target enabled Arnaud Lacombe
2010-12-01 20:56 ` Andreas Schwab
2010-12-01 22:06 ` Mike Frysinger
2010-12-01 23:16 ` Arnaud Lacombe
2010-12-04 3:37 ` Arnaud Lacombe [this message]
2010-12-04 10:45 ` [PATCH 1/3] binutils/ar: split ar/ranlib path Mike Frysinger
2010-12-04 3:37 ` [PATCH 2/3] binutils/ar: use getopt_long() for options parsing Arnaud Lacombe
2010-12-04 3:38 ` [PATCH 3/3] binutils/ar: learn --target Arnaud Lacombe
2010-12-08 5:08 ` Alan Modra
2010-12-15 19:58 ` H.J. Lu
2010-12-15 20:09 ` Arnaud Lacombe
2010-12-16 1:23 ` H.J. Lu
2010-12-04 3:47 ` Using binutils with all target enabled Arnaud Lacombe
2010-12-02 0:10 ` Joseph S. Myers
2010-12-02 0:17 ` Arnaud Lacombe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291433814-27666-1-git-send-email-lacombar@gmail.com \
--to=lacombar@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).