dirname.c\misc\src - musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/misc/dirname.c
blob: dd570883d8ac672716adaab40dce4bf34be1ddf7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <string.h>
#include <libgen.h>
char *dirname(char *s)
{
	size_t i;
	if (!s || !*s) return ".";
	i = strlen(s)-1;
	for (; s[i]=='/'; i--) if (!i) return "/";
	for (; s[i]!='/'; i--) if (!i) return ".";
	for (; s[i]=='/'; i--) if (!i) return "/";
	s[i+1] = 0;
	return s;
}
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月09日 19:03:31 +0000

AltStyle によって変換されたページ (->オリジナル) /