summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-10-13 07:18:09 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-10-13 07:18:09 +0000
commitbe42b79e157ac1134a151f87888d4fbb9fb92f56 (patch)
treed82bdc095f3ee358e76597880d215b849bf37621 /libiberty
parent944a8036de4896296c3601e353662b4fc78335f3 (diff)
downloadgcc-be42b79e157ac1134a151f87888d4fbb9fb92f56.tar.gz
* basename.c (DIR_SEPARATOR): New macro.
(DIR_SEPARATOR_2): Likewise. (HAVE_DOS_BASED_FILESYSTEM): Likewise. (IS_DIR_SEPARATOR): Likewise. (main): Handle MSDOS style pathname. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29937 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog8
-rw-r--r--libiberty/basename.c39
2 files changed, 42 insertions, 5 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 05dfb36b937..fcbc104b11a 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,11 @@
+Wed Oct 13 01:16:47 1999 Mumit Khan <khan@xraylith.wisc.edu>
+
+ * basename.c (DIR_SEPARATOR): New macro.
+ (DIR_SEPARATOR_2): Likewise.
+ (HAVE_DOS_BASED_FILESYSTEM): Likewise.
+ (IS_DIR_SEPARATOR): Likewise.
+ (main): Handle MSDOS style pathname.
+
1999-10-11 Mark Mitchell <mark@codesourcery.com>
* cplus-dem.c (do_type): Handle pointer to member types whose
diff --git a/libiberty/basename.c b/libiberty/basename.c
index f544c853910..7698f06f8ae 100644
--- a/libiberty/basename.c
+++ b/libiberty/basename.c
@@ -14,24 +14,53 @@ DESCRIPTION
last component of the pathname ("ls.c" in this case).
BUGS
- Presumes a UNIX style path with UNIX style separators.
+ Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows
+ style separators.
*/
#include "ansidecl.h"
#include "libiberty.h"
+#include <ctype.h>
+
+#ifndef DIR_SEPARATOR
+#define DIR_SEPARATOR '/'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+ defined (__OS2__)
+#define HAVE_DOS_BASED_FILE_SYSTEM
+#ifndef DIR_SEPARATOR_2
+#define DIR_SEPARATOR_2 '\\'
+#endif
+#endif
+
+/* Define IS_DIR_SEPARATOR. */
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
char *
basename (name)
const char *name;
{
- const char *base = name;
+ const char *base;
- while (*name)
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (isalpha (name[0]) && name[1] == ':')
+ name += 2;
+#endif
+
+ for (base = name; *name; name++)
{
- if (*name++ == '/')
+ if (IS_DIR_SEPARATOR (*name))
{
- base = name;
+ base = name + 1;
}
}
return (char *) base;
}
+