diff options
author | unknown <evgen@moonbone.local> | 2005-12-28 19:47:56 +0300 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2005-12-28 19:47:56 +0300 |
commit | 613253c49dde9bf3a27f8dc5d393fa441df73a9d (patch) | |
tree | 943fc4f32d66cc7e9822cdb825d9a8118a4a8487 /strings | |
parent | 38005eae6ac73bb2a58287b6eb9da14816e8424b (diff) | |
parent | 8f29cc3e84a0bfff0562e7d3a25dc497704a6ff5 (diff) | |
download | mariadb-git-613253c49dde9bf3a27f8dc5d393fa441df73a9d.tar.gz |
Merge moonbone.local:/work/14583-bug-5.0-mysql
into moonbone.local:/work/14583-bug-5.1-new-mysql
BitKeeper/deleted/.del-ha_blackhole.cc~727c69ef7846623a:
Auto merged
mysql-test/r/ctype_ucs.result:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_update.cc:
Auto merged
strings/ctype-ucs2.c:
Auto merged
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-ucs2.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 80a7bd84601..e2629f445cb 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1373,14 +1373,50 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, return (int) (t_is_prefix ? t-te : ((se-s) - (te-t))); } -static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs, +static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *s, uint slen, const uchar *t, uint tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { - /* TODO: Needs to be fixed to handle end space! */ - return my_strnncoll_ucs2_bin(cs,s,slen,t,tlen,0); + const uchar *se, *te; + uint minlen; + + /* extra safety to make sure the lengths are even numbers */ + slen= (slen >> 1) << 1; + tlen= (tlen >> 1) << 1; + + se= s + slen; + te= t + tlen; + + for (minlen= min(slen, tlen); minlen; minlen-= 2) + { + int s_wc= s[0] * 256 + s[1]; + int t_wc= t[0] * 256 + t[1]; + if ( s_wc != t_wc ) + return s_wc > t_wc ? 1 : -1; + + s+= 2; + t+= 2; + } + + if (slen != tlen) + { + int swap= 1; + if (slen < tlen) + { + s= t; + se= te; + swap= -1; + } + + for ( ; s < se ; s+= 2) + { + if (s[0] || s[1] != ' ') + return (s[0] == 0 && s[1] < ' ') ? -swap : swap; + } + } + return 0; } |