summaryrefslogtreecommitdiff
path: root/strings/ctype-uca.c
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2005-01-13 18:12:04 +0400
committerunknown <bar@mysql.com>2005-01-13 18:12:04 +0400
commit9842aca3ef48bf56a6c3ee5b9e1159e4249ce346 (patch)
tree89b4be1d3a807d6f2554dce92b0a5ecd0a9009ab /strings/ctype-uca.c
parentbcb3783c7c88b06a8417a5734103ae856a2f7dbc (diff)
downloadmariadb-git-9842aca3ef48bf56a6c3ee5b9e1159e4249ce346.tar.gz
bug#7284: strnxfrm returns different results for equal strings
Diffstat (limited to 'strings/ctype-uca.c')
-rw-r--r--strings/ctype-uca.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index 89c876ad10c..4992ef2dcd1 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -7214,8 +7214,7 @@ static int my_strnxfrm_uca(CHARSET_INFO *cs,
uchar *dst, uint dstlen,
const uchar *src, uint srclen)
{
- uchar *de = dst + dstlen;
- const uchar *dst_orig = dst;
+ uchar *de = dst + (dstlen & (uint) ~1); // add even length for easier code
int s_res;
my_uca_scanner scanner;
scanner_handler->init(&scanner, cs, src, srclen);
@@ -7226,8 +7225,17 @@ static int my_strnxfrm_uca(CHARSET_INFO *cs,
dst[1]= s_res & 0xFF;
dst+= 2;
}
- for ( ; dst < de; *dst++='\0');
- return dst - dst_orig;
+ s_res= cs->sort_order_big[0][0x20 * cs->sort_order[0]];
+ while (dst < de)
+ {
+ dst[0]= s_res >> 8;
+ dst[1]= s_res & 0xFF;
+ dst+= 2;
+ }
+ if (dstlen & 1) // if odd number then fill the last char
+ *dst= '\0';
+
+ return dstlen;
}