mirror of
https://github.com/bitwiseworks/gcc-os2.git
synced 2026-02-04 00:54:37 +00:00
Note: This is a cumulative patch containing the work of several people
which is impossible to separate now.
This patch contains a number of '#ifdef 0'-like hacks that need to be
reviewed and fixed properly as they are unlikely to be accepted upstream
in the current form. Also, some patches may be not relevant any more.
(cherry picked from commit 25ebd257ce836444e0914e35a7baf3fdff67e3b9)
Conflicts:
Makefile.in
gcc/Makefile.in
gcc/config.build
gcc/config.gcc
gcc/config.host
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/i386/i386.md
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/error.c
gcc/cp/g++spec.c
gcc/cp/mangle.c
gcc/cppdefault.c
gcc/fix-header.c
gcc/gcc.c
gcc/gengtype.c
gcc/gthr.h
gcc/langhooks.c
gcc/libgcc2.c
gcc/target-def.h
include/filenames.h
libgcc/config.host
libiberty/configure
libiberty/configure.ac
libstdc++-v3/include/bits/stringfwd.h
libstdc++-v3/libsupc++/typeinfo
(cherry picked from commit 02bd882d6c317ed56da4a4d4d8af54e2687d3001)
Conflicts:
fixincludes/fixlib.h
gcc/Makefile.in
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/cp/dump.c
gcc/cp/error.c
gcc/cp/g++spec.c
gcc/ggc-zone.c
libstdc++-v3/include/bits/stringfwd.h
libstdc++-v3/include/parallel/compatibility.h
libstdc++-v3/libsupc++/typeinfo
(cherry picked from commit b183829f9258cb3bb22117c32d610a18b1ba5359
and f0f959360a8b8fe0cb4276c695e60fdfff41f81f)
Conflicts:
gcc/config.gcc
gcc/config.host
gcc/config/i386/i386-protos.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/cp/dump.c
gcc/cp/except.c
gcc/dbxout.c
gcc/gcc.c
gcc/langhooks.c
gcc/toplev.c
63 lines
1.3 KiB
C
63 lines
1.3 KiB
C
/* Return the basename of a pathname.
|
|
This file is in the public domain. */
|
|
|
|
/*
|
|
|
|
@deftypefn Supplemental char* basename (const char *@var{name})
|
|
|
|
Returns a pointer to the last component of pathname @var{name}.
|
|
Behavior is undefined if the pathname ends in a directory separator.
|
|
|
|
@end deftypefn
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
#include "ansidecl.h"
|
|
#include "libiberty.h"
|
|
#include "safe-ctype.h"
|
|
|
|
#ifndef DIR_SEPARATOR
|
|
#define DIR_SEPARATOR '/'
|
|
#endif
|
|
|
|
#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
|
|
defined (__OS2__) || defined (__EMX__)
|
|
#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 (const char *name)
|
|
{
|
|
const char *base;
|
|
|
|
#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 (IS_DIR_SEPARATOR (*name))
|
|
{
|
|
base = name + 1;
|
|
}
|
|
}
|
|
return (char *) base;
|
|
}
|
|
|