aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2010-04-24 00:55:41 +0000
committerDJ Delorie <dj@gcc.gnu.org>2010-04-23 20:55:41 -0400
commit3009276c375bf3aa661dba71a1968ecfa41396a5 (patch)
tree69200e3764b98a3e99f34a5565afb55749e7ce70 /libiberty
parent5b29e4f6dde3163cf40ee14282008d6566281d6a (diff)
downloadgcc-3009276c375bf3aa661dba71a1968ecfa41396a5.zip
gcc-3009276c375bf3aa661dba71a1968ecfa41396a5.tar.gz
gcc-3009276c375bf3aa661dba71a1968ecfa41396a5.tar.bz2
filenames.h (IS_DIR_SEPARATOR_1): Rename from IS_DIR_SEPARATOR...
2010-04-23 Pedro Alves <pedro@codesourcery.com> include/ * filenames.h (IS_DIR_SEPARATOR_1): Rename from IS_DIR_SEPARATOR, always define it independently of host, add `dos_based' parameter, and handle it. (HAS_DRIVE_SPEC_1): Rename from HAS_DRIVE_SPEC, always define it independently of host, add `dos_based' parameter, and handle it. (IS_ABSOLUTE_PATH_1): Rename from IS_ABSOLUTE_PATH, always define it independently of host, add `dos_based' parameter, and handle it. (IS_DOS_DIR_SEPARATOR, IS_DOS_ABSOLUTE_PATH) (IS_UNIX_DIR_SEPARATOR, IS_UNIX_ABSOLUTE_PATH) (HAS_DOS_DRIVE_SPEC): New. (HAS_DRIVE_SPEC): Reimplement on top of HAS_DRIVE_SPEC_1. (IS_DIR_SEPARATOR): Reimplement on top of IS_DIR_SEPARATOR_1. (IS_ABSOLUTE_PATH): Reimplement on top of IS_ABSOLUTE_PATH_1. * libiberty.h (dos_lbasename, unix_lbasename): Declare. libiberty/ * lbasename.c (lbasename): Split into ... (unix_lbasename, dos_basename): ... these. (lbasename): ... and reimplement on top of them. * Makefile.in (lbasename.o): Add dependency on $(INCDIR)/filenames.h. From-SVN: r158681
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog8
-rw-r--r--libiberty/Makefile.in2
-rw-r--r--libiberty/lbasename.c28
3 files changed, 33 insertions, 5 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index eb47537..cf4cdc4 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,11 @@
+2010-04-23 Pedro Alves <pedro@codesourcery.com>
+
+ * lbasename.c (lbasename): Split into ...
+ (unix_lbasename, dos_basename): ... these.
+ (lbasename): ... and reimplement on top of them.
+ * Makefile.in (lbasename.o): Add dependency on
+ $(INCDIR)/filenames.h.
+
2010-04-07 Jakub Jelinek <jakub@redhat.com>
* regex.c (byte_re_match_2_internal): Avoid set but not used
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index f22d3a3..fbce3cd 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -724,7 +724,7 @@ $(CONFIGURED_OFILES): stamp-picdir
./lbasename.o: $(srcdir)/lbasename.c config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/filenames.h $(INCDIR)/libiberty.h \
- $(INCDIR)/safe-ctype.h
+ $(INCDIR)/safe-ctype.h $(INCDIR)/filenames.h
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $(srcdir)/lbasename.c -o pic/$@; \
else true; fi
diff --git a/libiberty/lbasename.c b/libiberty/lbasename.c
index 56fcd62..ed1dd1f 100644
--- a/libiberty/lbasename.c
+++ b/libiberty/lbasename.c
@@ -46,19 +46,39 @@ and a path ending in @code{/} returns the empty string after it.
#include "filenames.h"
const char *
-lbasename (const char *name)
+unix_lbasename (const char *name)
+{
+ const char *base;
+
+ for (base = name; *name; name++)
+ if (IS_UNIX_DIR_SEPARATOR (*name))
+ base = name + 1;
+
+ return base;
+}
+
+const char *
+dos_lbasename (const char *name)
{
const char *base;
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
/* Skip over a possible disk name. */
if (ISALPHA (name[0]) && name[1] == ':')
name += 2;
-#endif
for (base = name; *name; name++)
- if (IS_DIR_SEPARATOR (*name))
+ if (IS_DOS_DIR_SEPARATOR (*name))
base = name + 1;
return base;
}
+
+const char *
+lbasename (const char *name)
+{
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ return dos_lbasename (name);
+#else
+ return unix_lbasename (name);
+#endif
+}