+2015-03-30 Yaakov Selkowitz <yselkowi@redhat.com>
+
+ * common.din (__gnu_basename): Export.
+ * path.cc (__gnu_basename): New function.
+
2015-03-30 Corinna Vinschen <corinna@vinschen.de>
* cygheap.h (cygheap_domain_info::add_domain): Add prototype.
c: means c:\.
*/
+#define _BASENAME_DEFINED
#include "winsup.h"
#include "miscfuncs.h"
#include <ctype.h>
return path;
}
+/* The differences with the POSIX version above:
+ - declared in <string.h> (instead of <libgen.h>);
+ - the argument is never modified, and therefore is marked const;
+ - the empty string is returned if path is an empty string, "/", or ends
+ with a trailing slash. */
+extern "C" char *
+__gnu_basename (const char *path)
+{
+ static char buf[1];
+ char *c, *d, *bs = (char *)path;
+
+ if (!path || !*path)
+ return strcpy (buf, "");
+ if (isalpha (path[0]) && path[1] == ':')
+ bs += 2;
+ else if (strspn (path, "/\\") > 1)
+ ++bs;
+ c = strrchr (bs, '/');
+ if ((d = strrchr (c ?: bs, '\\')) > c)
+ c = d;
+ if (c)
+ return c + 1;
+ else if (!bs[0])
+ return strcpy (buf, "");
+ return (char *)path;
+}
+
/* No need to be reentrant or thread-safe according to SUSv3.
/ and \\ are treated equally. Leading drive specifiers and
leading double (back)slashes are kept intact as far as it
+2015-03-30 Yaakov Selkowitz <yselkowi@redhat.com>
+
+ * posix.xml (std-gnu): Add basename.
+ (std-notes): Add note about two forms of basename.
+
2015-03-13 Jon TURNEY <jon.turney@dronecode.org.uk>
* Makefile.in (prefix): Define.
atoi
atol
atoll
- basename
+ basename (see chapter "Implementation Notes")
bind
bsearch
btowc
asnprintf
asprintf
asprintf_r
+ basename (see chapter "Implementation Notes")
canonicalize_file_name
dremf
dup3
<para><function>qsort_r</function> is available in both BSD and GNU flavors,
depending on whether _BSD_SOURCE or _GNU_SOURCE is defined when compiling.</para>
+<para><function>basename</function> is available in both POSIX and GNU flavors,
+depending on whether libgen.h is included or not.</para>
+
</sect1>
</chapter>