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
/
print.c
blob
b9088badb2f6d35c2188442f8e56ad4d009598f8
1
#include <stdio.h>
2
#include <stdarg.h>
3
#include <unistd.h>
4
#include
"test.h"
5
6
volatile
int
t_status
=
0
;
7
8
int
t_printf
(
const char
*
s
, ...)
9
{
10
va_list
ap
;
11
char
buf
[
512
];
12
int
n
;
13
14
t_status
=
1
;
15
va_start
(
ap
,
s
);
16
n
=
vsnprintf
(
buf
,
sizeof
buf
,
s
,
ap
);
17
va_end
(
ap
);
18
if
(
n
<
0
)
19
n
=
0
;
20
else if
(
n
>=
sizeof
buf
) {
21
n
=
sizeof
buf
;
22
buf
[
n
-
1
] =
'
\n
'
;
23
buf
[
n
-
2
] =
'.'
;
24
buf
[
n
-
3
] =
'.'
;
25
buf
[
n
-
4
] =
'.'
;
26
}
27
return
write
(
1
,
buf
,
n
);
28
}