repo.or.cz
/
minix3.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Uninitialized vector entry?
[minix3.git]
/
lib
/
other
/
basename.c
blob
5de8f7af5b1ff3642ca068ba51de15adade85a5b
1
/*
2
basename.c
3
*/
4
5
#include <libgen.h>
6
#include <string.h>
7
8
char
*
basename
(
path
)
9
char
*
path
;
10
{
11
size_t
len
;
12
char
*
cp
;
13
14
if
(
path
==
NULL
)
15
return
"."
;
16
len
=
strlen
(
path
);
17
if
(
len
==
0
)
18
return
"."
;
19
while
(
path
[
len
-
1
] ==
'/'
)
20
{
21
if
(
len
==
1
)
22
return
path
;
/* just "/" */
23
len
--;
24
path
[
len
]=
'\0'
;
25
}
26
cp
=
strrchr
(
path
,
'/'
);
27
if
(
cp
!=
NULL
)
28
return
cp
+
1
;
29
return
path
;
30
}