From 264028c42170b9a4a58d292cc4fc9f80d9691931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Fri, 3 Dec 2021 19:23:03 -0800 Subject: [PATCH] Cleanup. --- src/string.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/string.cpp b/src/string.cpp index d086bc8..a8ca115 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -887,10 +887,11 @@ namespace bx const char* dot = strFind(str, INT32_MAX, '.'); if (NULL != dot) { - const int32_t prec = INT32_MAX == _param.prec ? 6 : _param.prec; - const char* strEnd = str + len; + const int32_t prec = INT32_MAX == _param.prec ? 6 : _param.prec; + const char* strEnd = str + len; const char* exponent = strFind(str, INT32_MAX, 'e'); - const char* fracEnd = NULL != exponent ? exponent : strEnd; + const char* fracEnd = NULL != exponent ? exponent : strEnd; + char* fracBegin = &str[dot - str + min(prec + _param.spec, 1)]; const int32_t curPrec = int32_t(fracEnd - fracBegin); @@ -899,7 +900,8 @@ namespace bx { const int32_t exponentLen = int32_t(strEnd - fracEnd); char* finalExponentPtr = &fracBegin[prec]; - memMove(finalExponentPtr, fracEnd, exponentLen); // NOTE: Use memMove because there may be overlap. + memMove(finalExponentPtr, fracEnd, exponentLen); + finalExponentPtr[exponentLen] = '\0'; len = int32_t(&finalExponentPtr[exponentLen] - str); }