diff options
author | unknown <monty@mysql.com> | 2004-12-06 17:16:35 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-12-06 17:16:35 +0200 |
commit | 19a95482195a158425c66ac629d07da53e4fc1b6 (patch) | |
tree | 5cfc0009e76810724a4db2904e75e2db2506bd46 /strings | |
parent | a4a69f73126d247a519a50f5ba21357ce13839fe (diff) | |
parent | a1fba2daccee3c7c5d46cded39fda7ee7f0d6eae (diff) | |
download | mariadb-git-19a95482195a158425c66ac629d07da53e4fc1b6.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0
ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
Auto merged
sql/sql_show.cc:
Auto merged
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-ucs2.c | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 851c2044f47..403d31aa15b 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -218,11 +218,78 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs, return t_is_prefix ? t-te : ((se-s) - (te-t)); } -static int my_strnncollsp_ucs2(CHARSET_INFO *cs, - const uchar *s, uint slen, +/* + Compare strings, discarding end space + + SYNOPSIS + my_strnncollsp_ucs2() + cs character set handler + a First string to compare + a_length Length of 'a' + b Second string to compare + b_length Length of 'b' + + IMPLEMENTATION + If one string is shorter as the other, then we space extend the other + so that the strings have equal length. + + This will ensure that the following things hold: + + "a" == "a " + "a\0" < "a" + "a\0" < "a " + + RETURN + < 0 a < b + = 0 a == b + > 0 a > b +*/ + +static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const uchar *s, uint slen, const uchar *t, uint tlen) { - return my_strnncoll_ucs2(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 = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort : + (((int) s[0]) << 8) + (int) s[1]; + + int t_wc = uni_plane[t[0]] ? (int) uni_plane[t[0]][t[1]].sort : + (((int) t[0]) << 8) + (int) t[1]; + if ( s_wc != t_wc ) + return s_wc - t_wc; + + s+= 2; + t+= 2; + } + + if (slen != tlen) + { + int swap= 0; + if (slen < tlen) + { + s= t; + se= te; + swap= -1; + } + + for ( ; s < se ; s+= 2) + { + if (s[0] || s[1] != ' ') + return (((int)s[0] << 8) + (int) s[1] - (int) ' ') ^ swap; + } + } + return 0; } |