Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
f49a8e5d
Commit
f49a8e5d
authored
May 18, 2018
by
Mark Andrews
Browse files
Merge branch '274-print-c-9-12-and-earlier-v9_11' into 'v9_11'
Resolve "print.c 9.12 and earlier" See merge request
!298
parents
28f17e82
7bbc0668
Pipeline
#1752
passed with stages
in 6 minutes and 9 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
f49a8e5d
4949. [bug] lib/isc/print.c failed to handle floating point
output correctly. [GL #261]
4939. [test] Add basic unit tests for update_sigs(). [GL #135]
4935. [func] Add support for LibreSSL >= 2.7.0 (some OpenSSL 1.1.0
...
...
configure.in
View file @
f49a8e5d
...
...
@@ -3773,12 +3773,14 @@ AC_CHECK_FUNC(vsnprintf, [],
AC_MSG_CHECKING(printf for %z support)
AC_TRY_RUN([
#include <stdio.h>
int
main() {
size_t j = 0;
char buf[100];
buf[0] = 0;
sprintf(buf, "%zu", j);
exit(strcmp(buf, "0") != 0
);
return ((buf[0] == '0' && buf[1] == '\0') ? 0 : 1
);
}
],
[AC_MSG_RESULT(yes)],
...
...
lib/isc/print.c
View file @
f49a8e5d
...
...
@@ -685,7 +685,7 @@ isc__print_printf(void (*emit)(char, void *), void *arg,
pad
--
;
}
cp
=
buf
;
while
(
*
cp
!=
'
'
)
while
(
*
cp
!=
'
\0
'
)
emit
(
*
cp
++
,
arg
);
while
(
pad
>
0
)
{
emit
(
' '
,
arg
);
...
...
lib/isc/tests/print_test.c
View file @
f49a8e5d
...
...
@@ -50,6 +50,7 @@ ATF_TC_BODY(snprintf, tc) {
isc_uint64_t
ll
=
8589934592ULL
;
isc_uint64_t
nn
=
20000000000000ULL
;
isc_uint64_t
zz
=
10000000000000000000ULL
;
float
pi
=
3
.
141
;
int
n
;
size_t
size
;
...
...
@@ -118,6 +119,25 @@ ATF_TC_BODY(snprintf, tc) {
n
=
isc_print_snprintf
(
buf
,
sizeof
(
buf
),
"0x%"
ISC_PRINT_QUADFORMAT
"x"
,
zz
);
ATF_CHECK_EQ
(
n
,
18
);
ATF_CHECK_STREQ
(
buf
,
"0xf5f5f5f5f5f5f5f5"
);
n
=
isc_print_snprintf
(
buf
,
sizeof
(
buf
),
"%.2f"
,
pi
);
ATF_CHECK_EQ
(
n
,
4
);
ATF_CHECK_STREQ
(
buf
,
"3.14"
);
/* Similar to the above, but additional characters follows */
n
=
isc_print_snprintf
(
buf
,
sizeof
(
buf
),
"%.2f1592"
,
pi
);
ATF_CHECK_EQ
(
n
,
8
);
ATF_CHECK_STREQ
(
buf
,
"3.141592"
);
/* Similar to the above, but with leading spaces */
n
=
isc_print_snprintf
(
buf
,
sizeof
(
buf
),
"% 8.2f1592"
,
pi
);
ATF_CHECK_EQ
(
n
,
12
);
ATF_CHECK_STREQ
(
buf
,
" 3.141592"
);
/* Similar to the above, but with trail spaces after the 4 */
n
=
isc_print_snprintf
(
buf
,
sizeof
(
buf
),
"%-8.2f1592"
,
pi
);
ATF_CHECK_EQ
(
n
,
12
);
ATF_CHECK_STREQ
(
buf
,
"3.14 1592"
);
}
ATF_TC
(
fprintf
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment