aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/StringUtil.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc
index 00d2e88..9cd2c9a 100644
--- a/src/FbTk/StringUtil.cc
+++ b/src/FbTk/StringUtil.cc
@@ -69,6 +69,9 @@ using std::transform;
69 69
70namespace { 70namespace {
71 71
72const size_t DIGITS10_ULONGLONGINT = 20; // ULLONG_MAX = 18446744073709551615
73const size_t DIGITS16_ULONGLONGINT = 18; // ULLONG_MAX = 0xffffffffffffffff
74
72template <typename T> 75template <typename T>
73int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) { 76int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) {
74 77
@@ -170,14 +173,14 @@ int extractNumber(const std::string& in, unsigned long long& out) {
170 173
171 174
172std::string number2String(long long num) { 175std::string number2String(long long num) {
173 char s[128]; 176 char s[DIGITS10_ULONGLONGINT];
174 snprintf(s, sizeof(s), "%lld", num); 177 snprintf(s, sizeof(s), "%lld", num);
175 return std::string(s); 178 return std::string(s);
176} 179}
177 180
178std::string number2HexString(long long num) { 181std::string number2HexString(long long num) {
179 char s[17]; 182 char s[DIGITS16_ULONGLONGINT];
180 snprintf(s, sizeof(s), "%lx", num); 183 snprintf(s, sizeof(s), "%llx", num);
181 return std::string(s); 184 return std::string(s);
182} 185}
183 186