Skip to content

Commit

Permalink
Backport fix for CORE-1781 - LIKE, STARTING WITH and CONTAINING may i…
Browse files Browse the repository at this point in the history
…ncorrect return true
  • Loading branch information
asfernandes committed May 1, 2008
1 parent 955272b commit 92cea80
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/intl/lc_narrow.cpp
Expand Up @@ -745,13 +745,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;
primary += obj->texttype_impl->ignore_sum_canonic;
else
primary += obj->texttype_impl->primary_sum;
}
primary += obj->texttype_impl->primary_sum_canonic;

if ((obj->texttype_impl->texttype_flags & (TEXTTYPE_secondary_insensitive | TEXTTYPE_tertiary_insensitive)) == 0)
{
Expand Down Expand Up @@ -855,11 +852,9 @@ 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 maxPrimary = 0;

if (!(tt->texttype_impl->texttype_flags & TEXTTYPE_disable_compressions))
{
Expand Down Expand Up @@ -896,6 +891,8 @@ bool LC_NARROW_family2(
}
}

if (map.get("SPECIALS-FIRST", value) && (value == "0" || value == "1"))
{
if (maxIgnore > 0 && maxPrimary + maxIgnore - 1 <= 255)
{
++validAttributeCount;
Expand All @@ -909,6 +906,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 92cea80

Please sign in to comment.