diff options
author | Yaakov Selkowitz <yselkowi@redhat.com> | 2015-03-25 18:19:38 -0500 |
---|---|---|
committer | Yaakov Selkowitz <yselkowi@redhat.com> | 2015-03-30 13:10:40 -0500 |
commit | 779ddb0b4874afc80c13cb1c2afe45c68db2fdce (patch) | |
tree | b0a2f74ba00c1005bbb2cdec84ce209fc214e954 /newlib/libc/include/string.h | |
parent | 98209e8e304e40a352bac5703a597ed66628d084 (diff) | |
download | cygnal-779ddb0b4874afc80c13cb1c2afe45c68db2fdce.tar.gz cygnal-779ddb0b4874afc80c13cb1c2afe45c68db2fdce.tar.bz2 cygnal-779ddb0b4874afc80c13cb1c2afe45c68db2fdce.zip |
string: add GNU basename(3)
* libc/include/libgen.h (_BASENAME_DEFINED): Define.
* libc/include/string.h (basename): Declare.
* libc/string/Makefile.am (ELIX_4_SOURCES): Add gnu_basename.c.
* libc/string/Makefile.in: Regenerate.
* libc/string/gnu_basename.c: New file.
Diffstat (limited to 'newlib/libc/include/string.h')
-rw-r--r-- | newlib/libc/include/string.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index 43b36267d..9e11e5c51 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -163,6 +163,20 @@ int _EXFUN(strtosigno, (const char *__name)); (char *) memcpy (__out, __in, __len-1);})) #endif /* _GNU_SOURCE && __GNUC__ */ +/* There are two common basename variants. If you #include <libgen.h> + first, you get the POSIX version; otherwise you get the GNU version. + POSIX requires that #undef basename will still let you + invoke the underlying function, but that requires gcc support. */ +#if __GNU_VISIBLE && !defined(_BASENAME_DEFINED) +# ifdef __GNUC__ +char *_EXFUN(basename,(const char *)) + __asm__ (__ASMNAME ("__gnu_basename")) __nonnull(1); +# else +char *_EXFUN(__gnu_basename,(const char *)); +# define basename __gnu_basename +# endif +#endif + #include <sys/string.h> _END_STD_C |