This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Patch] bfd/archive.c: uses lbasename
- From: Tristan Gingold <gingold at adacore dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Tue, 12 Jan 2010 11:51:40 +0100
- Subject: [Patch] bfd/archive.c: uses lbasename
Hi,
did I miss the obvious ? It looks like lbasename could be used to simplify the code.
Tristan.
bfd/
2010-01-12 Tristan Gingold <gingold@adacore.com>
* archive.c (normalize): Use lbasename.
(bfd_bsd_truncate_arname): Ditto.
(bfd_gnu_truncate_arname): Ditto.
*** archive.c 11 Jan 2010 15:29:36 -0000 1.62
--- archive.c 12 Jan 2010 10:49:25 -0000
***************
*** 1312,1334 ****
static const char *
normalize (bfd *abfd ATTRIBUTE_UNUSED, const char *file)
{
! const char *filename = strrchr (file, '/');
!
! #ifdef HAVE_DOS_BASED_FILE_SYSTEM
! {
! /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
! char *bslash = strrchr (file, '\\');
! if (filename == NULL || (bslash != NULL && bslash > filename))
! filename = bslash;
! if (filename == NULL && file[0] != '\0' && file[1] == ':')
! filename = file + 1;
! }
! #endif
! if (filename != NULL)
! filename++;
! else
! filename = file;
! return filename;
}
#endif
--- 1312,1318 ----
static const char *
normalize (bfd *abfd ATTRIBUTE_UNUSED, const char *file)
{
! return lbasename (file);
}
#endif
***************
*** 1820,1844 ****
{
struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
size_t length;
! const char *filename = strrchr (pathname, '/');
size_t maxlen = ar_maxnamelen (abfd);
- #ifdef HAVE_DOS_BASED_FILE_SYSTEM
- {
- /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
- char *bslash = strrchr (pathname, '\\');
- if (filename == NULL || (bslash != NULL && bslash > filename))
- filename = bslash;
- if (filename == NULL && pathname[0] != '\0' && pathname[1] == ':')
- filename = pathname + 1;
- }
- #endif
-
- if (filename == NULL)
- filename = pathname;
- else
- ++filename;
-
length = strlen (filename);
if (length <= maxlen)
--- 1804,1812 ----
{
struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
size_t length;
! const char *filename = lbasename (pathname);
size_t maxlen = ar_maxnamelen (abfd);
length = strlen (filename);
if (length <= maxlen)
***************
*** 1868,1893 ****
{
struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
size_t length;
! const char *filename = strrchr (pathname, '/');
size_t maxlen = ar_maxnamelen (abfd);
- #ifdef HAVE_DOS_BASED_FILE_SYSTEM
- {
- /* We could have foo/bar\\baz, or foo\\bar, or d:bar. */
- char *bslash = strrchr (pathname, '\\');
-
- if (filename == NULL || (bslash != NULL && bslash > filename))
- filename = bslash;
- if (filename == NULL && pathname[0] != '\0' && pathname[1] == ':')
- filename = pathname + 1;
- }
- #endif
-
- if (filename == NULL)
- filename = pathname;
- else
- ++filename;
-
length = strlen (filename);
if (length <= maxlen)
--- 1836,1844 ----
{
struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
size_t length;
! const char *filename = lbasename (pathname);
size_t maxlen = ar_maxnamelen (abfd);
length = strlen (filename);
if (length <= maxlen)