diff options
Diffstat (limited to 'src/FbTk/StringUtil.cc')
-rw-r--r-- | src/FbTk/StringUtil.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index 9cd2c9a..d6f2c8f 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc | |||
@@ -70,7 +70,7 @@ using std::transform; | |||
70 | namespace { | 70 | namespace { |
71 | 71 | ||
72 | const size_t DIGITS10_ULONGLONGINT = 20; // ULLONG_MAX = 18446744073709551615 | 72 | const size_t DIGITS10_ULONGLONGINT = 20; // ULLONG_MAX = 18446744073709551615 |
73 | const size_t DIGITS16_ULONGLONGINT = 18; // ULLONG_MAX = 0xffffffffffffffff | 73 | const size_t DIGITS16_ULONGLONGINT = 16; // ULLONG_MAX = ffffffffffffffff |
74 | 74 | ||
75 | template <typename T> | 75 | template <typename T> |
76 | int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) { | 76 | int extractBigNumber(const char* in, T (*extractFunc)(const char*, char**, int), T& out) { |
@@ -173,15 +173,15 @@ int extractNumber(const std::string& in, unsigned long long& out) { | |||
173 | 173 | ||
174 | 174 | ||
175 | std::string number2String(long long num) { | 175 | std::string number2String(long long num) { |
176 | char s[DIGITS10_ULONGLONGINT]; | 176 | char s[DIGITS10_ULONGLONGINT+1]; |
177 | snprintf(s, sizeof(s), "%lld", num); | 177 | int n = snprintf(s, sizeof(s), "%lld", num); |
178 | return std::string(s); | 178 | return std::string(s, n); |
179 | } | 179 | } |
180 | 180 | ||
181 | std::string number2HexString(long long num) { | 181 | std::string number2HexString(long long num) { |
182 | char s[DIGITS16_ULONGLONGINT]; | 182 | char s[DIGITS16_ULONGLONGINT+1]; |
183 | snprintf(s, sizeof(s), "%llx", num); | 183 | int n = snprintf(s, sizeof(s), "%llx", num); |
184 | return std::string(s); | 184 | return std::string(s, n); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||