diff options
author | bar@bar.myoffice.izhnet.ru <> | 2007-07-05 14:55:02 +0500 |
---|---|---|
committer | bar@bar.myoffice.izhnet.ru <> | 2007-07-05 14:55:02 +0500 |
commit | 84eb79856eee2430594d691ec2ac10c7e9c4c119 (patch) | |
tree | dc73de2776d7878fbe04c30bffc7bf30f3fb4481 /strings | |
parent | b351b0f1eb6462af40598019431bb330996f40e6 (diff) | |
parent | fd3cdea376dc8cb81dfdb194117d8e75a1f4e725 (diff) | |
download | mariadb-git-84eb79856eee2430594d691ec2ac10c7e9c4c119.tar.gz |
Merge mysql.com:/home/bar/mysql-work/mysql-5.0.b29333
into mysql.com:/home/bar/mysql-work/mysql-5.0-rpl
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-cp932.c | 14 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 29 |
2 files changed, 29 insertions, 14 deletions
diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index 0ece0ef1270..42325648037 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -250,9 +250,16 @@ static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)), const uchar *a_end= a + a_length; const uchar *b_end= b + b_length; int res= my_strnncoll_cp932_internal(cs, &a, a_length, &b, b_length); + +#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE + diff_if_only_endspace_difference= 0; +#endif + if (!res && (a != a_end || b != b_end)) { - int swap= 0; + int swap= 1; + if (diff_if_only_endspace_difference) + res= 1; /* Assume 'a' is bigger */ /* Check the next not space character of the longer key. If it's < ' ', then it's smaller than the other key. @@ -263,11 +270,12 @@ static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)), a_end= b_end; a= b; swap= -1; /* swap sign of result */ + res= -res; } for (; a < a_end ; a++) { - if (*a != ' ') - return ((int) *a - (int) ' ') ^ swap; + if (*a != (uchar) ' ') + return (*a < (uchar) ' ') ? -swap : swap; } } return res; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 387ce16a43d..4682868562f 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2802,16 +2802,19 @@ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs, const uchar *s, uint slen, const uchar *t, uint tlen, - my_bool diff_if_only_endspace_difference - __attribute__((unused))) + my_bool diff_if_only_endspace_difference) { - int s_res,t_res; - my_wc_t s_wc,t_wc; - const uchar *se= s+slen; - const uchar *te= t+tlen; - int save_diff = 0; + int s_res, t_res, res; + my_wc_t s_wc, t_wc; + const uchar *se= s + slen; + const uchar *te= t + tlen; + int save_diff= 0; MY_UNICASE_INFO **uni_plane= cs->caseinfo; - + +#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE + diff_if_only_endspace_difference= 0; +#endif + while ( s < se && t < te ) { int plane; @@ -2843,16 +2846,20 @@ static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs, slen= se-s; tlen= te-t; + res= 0; if (slen != tlen) { - int swap= 0; + int swap= 1; + if (diff_if_only_endspace_difference) + res= 1; /* Assume 'a' is bigger */ if (slen < tlen) { slen= tlen; s= t; se= te; swap= -1; + res= -res; } /* This following loop uses the fact that in UTF-8 @@ -2866,8 +2873,8 @@ static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs, */ for ( ; s < se; s++) { - if (*s != ' ') - return ((int)*s - (int) ' ') ^ swap; + if (*s != (uchar) ' ') + return (*s < (uchar) ' ') ? -swap : swap; } } return save_diff; |