repo.or.cz
/
libc-test.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
functional: add mntent test
[libc-test.git]
/
src
/
common
/
path.c
blob
6ca99510b7caf2af1f51aa4917c7a6a69b1aa69a
1
#include <string.h>
2
#include <stdio.h>
3
#include
"test.h"
4
5
/* relative path to p */
6
char
*
t_pathrel
(
char
*
buf
,
size_t
n
,
char
*
argv0
,
char
*
p
)
7
{
8
char
*
s
=
strrchr
(
argv0
,
'/'
);
9
int
k
;
10
11
if
(
s
)
12
k
=
snprintf
(
buf
,
n
,
"%.*s/%s"
, (
int
)(
s
-
argv0
),
argv0
,
p
);
13
else
14
k
=
snprintf
(
buf
,
n
,
"./%s"
,
p
);
15
if
((
size_t
)
k
>=
n
)
16
return
0
;
17
return
buf
;
18
}