From 2cd2156f48361fa342ce1ad18cead5cae6ce4af5 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Sat, 24 Apr 2010 01:03:21 +0000 Subject: merge from gcc --- libiberty/ChangeLog | 8 ++++++++ libiberty/Makefile.in | 2 +- libiberty/lbasename.c | 28 ++++++++++++++++++++++++---- 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'libiberty') 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 + + * 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 * 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 +} -- cgit v1.1