This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: VAX PATCH: remove FILE_NAME_NONDIRECTORY
- To: gcc-patches at gcc dot gnu dot org
- Subject: Re: VAX PATCH: remove FILE_NAME_NONDIRECTORY
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Thu, 22 Feb 2001 11:15:23 -0500 (EST)
Forwarded message:
>From dave Wed Feb 21 17:32:02 EST 2001
Subject: Re: VAX PATCH: remove FILE_NAME_NONDIRECTORY
To: lars.spam@nocrew.org (Lars Brinkhoff)
Date: Wed, 21 Feb 2001 17:32:02 -0500 (EST)
From: "John David Anglin" <dave@hiauly1>
In-Reply-To: <85itm37jwn.fsf@junk.nocrew.org> from "Lars Brinkhoff" at Feb 21, 2001 11:26:00 pm
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 1412
>
> "John David Anglin" <dave@hiauly1.hia.nrc.ca> writes:
> > I take back my comment about the return value. I think we should use
> > basename.
>
> Sounds good to me.
I looked at it some more. Here is what I suggest. I am going to try it
soon.
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
2001-02-21 John David Anglin <dave@hiauly1.hia.nrc.ca>
* toplev.c (file_name_nondirectory): Use FILE_NAME_NONDIRECTORY macro
if defined or basename algorithm from libiberty to extract the
nondirectory portion of a file name.
--- toplev.c.orig Mon Feb 19 16:39:55 2001
+++ toplev.c Wed Feb 21 17:15:17 2001
@@ -1731,13 +1731,23 @@
file_name_nondirectory (x)
const char *x;
{
- char *tmp = (char *) strrchr (x, '/');
- if (DIR_SEPARATOR != '/' && ! tmp)
- tmp = (char *) strrchr (x, DIR_SEPARATOR);
- if (tmp)
- return (char *) (tmp + 1);
- else
- return (char *) x;
+#ifndef FILE_NAME_NONDIRECTORY
+ const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (ISALPHA (x[0]) && x[1] == ':')
+ x += 2;
+#endif
+
+ for (base = x; *x; x++)
+ if (IS_DIR_SEPARATOR (*x))
+ base = x + 1;
+
+ return (char *) base;
+#else
+ return FILE_NAME_NONDIRECTORY (x);
+#endif
}
/* Output a quoted string. */
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)