X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Flbasename.c;h=7aefbb493613219d82209ab65677ba1d064727a4;hb=deeafabb678e59d8585be6d765c7fbd0e7060b6c;hp=4afe890013efc67f419ded9c1e9322b7ab4de2bd;hpb=49b1fae4309ab5b9833f0af388483c2b6b4b3d50;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/lbasename.c b/libiberty/lbasename.c index 4afe890013..7aefbb4936 100644 --- a/libiberty/lbasename.c +++ b/libiberty/lbasename.c @@ -1,6 +1,6 @@ /* Libiberty basename. Like basename, but is not overridden by the system C library. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001-2019 Free Software Foundation, Inc. This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or @@ -15,8 +15,8 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with libiberty; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ +not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, +Boston, MA 02110-1301, USA. */ /* @@ -37,25 +37,48 @@ and a path ending in @code{/} returns the empty string after it. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "ansidecl.h" #include "libiberty.h" #include "safe-ctype.h" #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 +}