summaryrefslogtreecommitdiff
path: root/strings/strcoll.ic
diff options
context:
space:
mode:
Diffstat (limited to 'strings/strcoll.ic')
-rw-r--r--strings/strcoll.ic47
1 files changed, 42 insertions, 5 deletions
diff --git a/strings/strcoll.ic b/strings/strcoll.ic
index 4bced593a23..a9693b1f3c0 100644
--- a/strings/strcoll.ic
+++ b/strings/strcoll.ic
@@ -210,17 +210,13 @@ MY_FUNCTION_NAME(strnncoll)(CHARSET_INFO *cs __attribute__((unused)),
@param a_length - the length of the left string
@param b - the right string
@param b_length - the length of the right string
- @param diff_if_only_endspace_difference - not used in the code.
- TODO: this should be eventually removed (in 10.2?)
@return - the comparison result
*/
static int
MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)),
const uchar *a, size_t a_length,
- const uchar *b, size_t b_length,
- my_bool diff_if_only_endspace_difference
- __attribute__((unused)))
+ const uchar *b, size_t b_length)
{
const uchar *a_end= a + a_length;
const uchar *b_end= b + b_length;
@@ -262,6 +258,45 @@ MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)),
return 0;
}
+
+#ifdef DEFINE_STRNXFRM
+#ifndef WEIGHT_MB2_FRM
+#define WEIGHT_MB2_FRM(x,y) WEIGHT_MB2(x,y)
+#endif
+
+static size_t
+MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs,
+ uchar *dst, size_t dstlen, uint nweights,
+ const uchar *src, size_t srclen, uint flags)
+{
+ uchar *d0= dst;
+ uchar *de= dst + dstlen;
+ const uchar *se= src + srclen;
+ const uchar *sort_order= cs->sort_order;
+
+ for (; dst < de && src < se && nweights; nweights--)
+ {
+ if (my_charlen(cs, (const char *) src, (const char *) se) > 1)
+ {
+ /*
+ Note, it is safe not to check (src < se)
+ in the code below, because my_charlen() would
+ not return 2 if src was too short
+ */
+ uint16 e= WEIGHT_MB2_FRM(src[0], src[1]);
+ *dst++= (uchar) (e >> 8);
+ if (dst < de)
+ *dst++= (uchar) (e & 0xFF);
+ src+= 2;
+ }
+ else
+ *dst++= sort_order ? sort_order[*src++] : *src++;
+ }
+ return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
+}
+#endif /* DEFINE_STRNXFRM */
+
+
/*
We usually include this file at least two times from the same source file,
for the _ci and the _bin collations. Prepare for the second inclusion.
@@ -273,3 +308,5 @@ MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)),
#undef WEIGHT_MB3
#undef WEIGHT_MB4
#undef WEIGHT_PAD_SPACE
+#undef WEIGHT_MB2_FRM
+#undef DEFINE_STRNXFRM