summaryrefslogtreecommitdiffstats
path: root/libtests
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-02-28 22:20:45 +0100
committerJay Berkenbilt <ejb@ql.org>2013-03-05 19:35:46 +0100
commita51ae10b8ddada900c1abacd6284d35f6e65aa08 (patch)
treed49c868810ea244fe78228fbda180f776c238897 /libtests
parent66c3c8fdf7c60b34039bc9f70cd9bb00e0c0235d (diff)
downloadqpdf-a51ae10b8ddada900c1abacd6284d35f6e65aa08.tar.zst
Remove all calls to sprintf
Diffstat (limited to 'libtests')
-rw-r--r--libtests/qtest/qutil/qutil.out3
-rw-r--r--libtests/qutil.cc14
2 files changed, 10 insertions, 7 deletions
diff --git a/libtests/qtest/qutil/qutil.out b/libtests/qtest/qutil/qutil.out
index 737e4c72..ebbf97b5 100644
--- a/libtests/qtest/qutil/qutil.out
+++ b/libtests/qtest/qutil/qutil.out
@@ -8,6 +8,9 @@
0.00012
0.12346
0.00012
+16059
+37273
+3ebb
one
7
compare okay
diff --git a/libtests/qutil.cc b/libtests/qutil.cc
index 8d9c2383..dedd73d1 100644
--- a/libtests/qutil.cc
+++ b/libtests/qutil.cc
@@ -23,7 +23,10 @@ void string_conversion_test()
<< QUtil::double_to_string(.1234, 5) << std::endl
<< QUtil::double_to_string(.0001234, 5) << std::endl
<< QUtil::double_to_string(.123456, 5) << std::endl
- << QUtil::double_to_string(.000123456, 5) << std::endl;
+ << QUtil::double_to_string(.000123456, 5) << std::endl
+ << QUtil::int_to_string_base(16059, 10) << std::endl
+ << QUtil::int_to_string_base(16059, 8) << std::endl
+ << QUtil::int_to_string_base(16059, 16) << std::endl;
std::string embedded_null = "one";
embedded_null += '\0';
@@ -86,10 +89,8 @@ void getenv_test()
static void print_utf8(unsigned long val)
{
- char t[20];
- sprintf(t, "%lx", val); // XXXX
std::string result = QUtil::toUTF8(val);
- std::cout << "0x" << t << " ->";
+ std::cout << "0x" << QUtil::int_to_string_base(val, 16) << " ->";
if (val < 0xfffe)
{
std::cout << " " << result;
@@ -102,9 +103,8 @@ static void print_utf8(unsigned long val)
for (std::string::iterator iter = result.begin();
iter != result.end(); ++iter)
{
- char t[3];
- sprintf(t, "%02x", static_cast<unsigned char>(*iter)); // XXXX
- std::cout << " " << t;
+ std::cout << " " << QUtil::int_to_string_base(
+ static_cast<int>(static_cast<unsigned char>(*iter)), 16, 2);
}
}
std::cout << std::endl;