summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-12-06 11:38:56 +0200
committerunknown <monty@mysql.com>2004-12-06 11:38:56 +0200
commit796bd7de96a1d1ec422708b90df5328388201c10 (patch)
treea7bb331b7dac7ac2b3cda915e99bb8c1333f4fec /strings
parent289d3b2ee0f912dd4f128e1c61685d7bb170eb90 (diff)
parentf8cdf570979c550ef04c53f691118ed2b1296a7c (diff)
downloadmariadb-git-796bd7de96a1d1ec422708b90df5328388201c10.tar.gz
Merge with 4.1
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BUILD/SETUP.sh: Auto merged Build-tools/Do-compile: Auto merged client/mysqladmin.cc: Auto merged configure.in: Auto merged innobase/include/lock0lock.h: Auto merged innobase/os/os0file.c: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/ctype_ucs.result: Auto merged mysql-test/r/heap.result: Auto merged mysql-test/r/insert_select.result: Auto merged mysql-test/r/lowercase_table3.result: Auto merged mysql-test/r/rpl_start_stop_slave.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/t/ctype_ucs.test: Auto merged mysql-test/t/rpl_until.test: Auto merged mysql-test/t/subselect.test: Auto merged ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/ha_myisam.h: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/lock.cc: Auto merged sql/log_event.h: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/set_var.cc: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/log_event.cc: Merge with 4.1 Trivial cleanup
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-ucs2.c73
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;
}