diff options
Diffstat (limited to '')
-rw-r--r-- | libc-top-half/musl/src/misc/basename.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/misc/basename.c b/libc-top-half/musl/src/misc/basename.c new file mode 100644 index 0000000..438377b --- /dev/null +++ b/libc-top-half/musl/src/misc/basename.c @@ -0,0 +1,14 @@ +#include <string.h> +#include <libgen.h> + +char *basename(char *s) +{ + size_t i; + if (!s || !*s) return "."; + i = strlen(s)-1; + for (; i&&s[i]=='/'; i--) s[i] = 0; + for (; i&&s[i-1]!='/'; i--); + return s+i; +} + +weak_alias(basename, __xpg_basename); |