Kaydet (Commit) 9123711d authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

tdf#117296 dbahsql: Fix migration of numeric

Change-Id: I9ca181c58cd73432c632147870d546d277893fdf
Reviewed-on: https://gerrit.libreoffice.org/53587Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst e606179d
......@@ -42,9 +42,8 @@ namespace
OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
{
size_t nbits = 8 * bytes.size(); // length of array in bits
size_t nscratch = nbits / 3; // length of scratch in bytes
size_t nscratch = nbits / 2; // length of scratch in bytes
std::vector<char> scratch(nscratch, 0);
size_t smin = nscratch - 2; // speed optimization
for (size_t i = 0; i < bytes.size(); ++i)
{
......@@ -54,13 +53,11 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
int shifted_in = (bytes[i] & (1 << (7 - j))) ? 1 : 0;
/* Add 3 everywhere that scratch[k] >= 5. */
for (size_t k = smin; k < nscratch; ++k)
for (size_t k = 0; k < nscratch; ++k)
scratch[k] += (scratch[k] >= 5) ? 3 : 0;
/* Shift scratch to the left by one position. */
if (scratch[smin] >= 8)
smin -= 1;
for (size_t k = smin; k < nscratch - 1; ++k)
for (size_t k = 0; k < nscratch - 1; ++k)
{
scratch[k] <<= 1;
scratch[k] &= 0xF;
......@@ -76,7 +73,7 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
auto it = scratch.begin();
/* Remove leading zeros from the scratch space. */
while (*it == 0)
while (*it == 0 && scratch.size() > 1)
{
it = scratch.erase(it);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment