repo.or.cz
/
musl.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
powerpc-sf longjmp clobbering of val argument
[musl.git]
/
src
/
misc
/
dirname.c
blob
dd570883d8ac672716adaab40dce4bf34be1ddf7
1
#include <string.h>
2
#include <libgen.h>
3
4
char
*
dirname
(
char
*
s
)
5
{
6
size_t
i
;
7
if
(!
s
|| !*
s
)
return
"."
;
8
i
=
strlen
(
s
)-
1
;
9
for
(;
s
[
i
]==
'/'
;
i
--)
if
(!
i
)
return
"/"
;
10
for
(;
s
[
i
]!=
'/'
;
i
--)
if
(!
i
)
return
"."
;
11
for
(;
s
[
i
]==
'/'
;
i
--)
if
(!
i
)
return
"/"
;
12
s
[
i
+
1
] =
0
;
13
return
s
;
14
}