Skip to content

Commit

Permalink
Fixed CORE-1781 - LIKE, STARTING WITH and CONTAINING may incorrect re…
Browse files Browse the repository at this point in the history
…turn true
  • Loading branch information
asfernandes committed Mar 31, 2008
1 parent 45a1919 commit 16bcb63
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 39 deletions.
79 changes: 41 additions & 38 deletions src/intl/lc_narrow.cpp
Expand Up @@ -749,13 +749,10 @@ ULONG LC_NARROW_canonical(texttype* obj, ULONG srcLen, const UCHAR* src, ULONG d

USHORT primary = coll->Primary;

if (obj->texttype_impl->texttype_flags & TEXTTYPE_specials_first)
{
if (coll->IsExpand && coll->IsCompress)
primary += obj->texttype_impl->ignore_sum;
else
primary += obj->texttype_impl->primary_sum;
}
if (coll->IsExpand && coll->IsCompress)
primary += obj->texttype_impl->ignore_sum_canonic;
else
primary += obj->texttype_impl->primary_sum_canonic;

if ((obj->texttype_impl->texttype_flags & (TEXTTYPE_secondary_insensitive | TEXTTYPE_tertiary_insensitive)) == 0)
{
Expand Down Expand Up @@ -859,47 +856,47 @@ bool LC_NARROW_family2(
tt->texttype_impl->texttype_flags |= TEXTTYPE_disable_expansions;
}

if (map.get("SPECIALS-FIRST", value) && (value == "0" || value == "1"))
{
int maxPrimary = 0;
int minPrimary = INT_MAX;
int maxIgnore = 0;
int minPrimary = INT_MAX;
int maxIgnore = 0;
int maxPrimary = 0;

if (!(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))
if (!(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))
{
while (compressTbl->CharPair[0])
{
while (compressTbl->CharPair[0])
{
if (compressTbl->NoCaseWeight.Primary > maxPrimary)
maxPrimary = compressTbl->NoCaseWeight.Primary;
if (compressTbl->NoCaseWeight.Primary > maxPrimary)
maxPrimary = compressTbl->NoCaseWeight.Primary;

if (compressTbl->NoCaseWeight.Primary < minPrimary)
minPrimary = compressTbl->NoCaseWeight.Primary;
if (compressTbl->NoCaseWeight.Primary < minPrimary)
minPrimary = compressTbl->NoCaseWeight.Primary;

++compressTbl;
}
++compressTbl;
}
}

for (int ch = 0; ch <= 255; ++ch)
{
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*)tt->texttype_impl->texttype_collation_table)[ch];
for (int ch = 0; ch <= 255; ++ch)
{
const SortOrderTblEntry* coll =
&((const SortOrderTblEntry*)tt->texttype_impl->texttype_collation_table)[ch];

if (coll->IsExpand && coll->IsCompress)
{
if (coll->Primary > maxIgnore)
maxIgnore = coll->Primary;
}
else if (!((coll->IsExpand && !(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(coll->IsCompress && !(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))))
{
if (coll->Primary > maxPrimary)
maxPrimary = coll->Primary;
if (coll->IsExpand && coll->IsCompress)
{
if (coll->Primary > maxIgnore)
maxIgnore = coll->Primary;
}
else if (!((coll->IsExpand && !(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_expansions)) ||
(coll->IsCompress && !(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))))
{
if (coll->Primary > maxPrimary)
maxPrimary = coll->Primary;

if (coll->Primary < minPrimary)
minPrimary = coll->Primary;
}
if (coll->Primary < minPrimary)
minPrimary = coll->Primary;
}
}

if (map.get("SPECIALS-FIRST", value) && (value == "0" || value == "1"))
{
if (maxIgnore > 0 && maxPrimary + maxIgnore - 1 <= 255)
{
++validAttributeCount;
Expand All @@ -913,6 +910,12 @@ bool LC_NARROW_family2(
}
}

if (maxIgnore > 0 && maxPrimary + maxIgnore - 1 <= 255)
{
tt->texttype_impl->ignore_sum_canonic = minPrimary - 1;
tt->texttype_impl->primary_sum_canonic = maxIgnore - 1;
}

if (map.count() - validAttributeCount != 0)
return false;

Expand Down
6 changes: 5 additions & 1 deletion src/intl/lc_narrow.h
Expand Up @@ -45,7 +45,9 @@ namespace
texttype_toupper_table(NULL),
texttype_tolower_table(NULL),
ignore_sum(0),
primary_sum(0)
primary_sum(0),
ignore_sum_canonic(0),
primary_sum_canonic(0)
{
}

Expand All @@ -58,6 +60,8 @@ namespace
const BYTE* texttype_tolower_table;
int ignore_sum;
int primary_sum;
int ignore_sum_canonic;
int primary_sum_canonic;
};
}

Expand Down

0 comments on commit 16bcb63

Please sign in to comment.