diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-11-24 22:47:42 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-11-24 22:47:42 +0400 |
commit | 310c718cff0fbc5182eab7e77ed26fe567166fca (patch) | |
tree | 64f2bde619fd4c95dcb1fc184cccc1022b8113c5 /strings | |
parent | 2f8c84fd16ced8f0615b43e83890e60dd2b53479 (diff) | |
download | mariadb-git-310c718cff0fbc5182eab7e77ed26fe567166fca.tar.gz |
MDEV-9178 Wrong result for CAST(CONVERT('1IJ3' USING ucs2) AS SIGNED)
Also, fixing compilation warnings in ctype-mb.ic (Windows).
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-mb.ic | 4 | ||||
-rw-r--r-- | strings/ctype-ucs2.c | 21 |
2 files changed, 20 insertions, 5 deletions
diff --git a/strings/ctype-mb.ic b/strings/ctype-mb.ic index 0ad945b685d..6fc4d6e3db4 100644 --- a/strings/ctype-mb.ic +++ b/strings/ctype-mb.ic @@ -269,7 +269,7 @@ my_native_to_mb_fixed2(my_wc_t wc, uchar *s, uchar *e) { /* The caller must insure there is a space for at least one byte */ DBUG_ASSERT(s < e); - s[0]= wc >> 8; + s[0]= (uchar) (wc >> 8); if (s + 2 > e) return MY_CS_TOOSMALL2; s[1]= wc & 0xFF; @@ -286,7 +286,7 @@ my_native_to_mb_fixed3(my_wc_t wc, uchar *s, uchar *e) { /* The caller must insure there is a space for at least one byte */ DBUG_ASSERT(s < e); - s[0]= wc >> 16; + s[0]= (uchar) (wc >> 16); if (s + 2 > e) return MY_CS_TOOSMALL2; s[1]= (wc >> 8) & 0xFF; diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index e7ba5cbc3c3..5780fff003a 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -818,6 +818,21 @@ cnv: #ifdef HAVE_CHARSET_mb2 +/** + Convert a Unicode code point to a digit. + @param wc - the input Unicode code point + @param[OUT] c - the output character representing the digit value 0..9 + + @return 0 - if wc is a good digit + @return 1 - if wc is not a digit +*/ +static inline my_bool +wc2digit_uchar(uchar *c, my_wc_t wc) +{ + return wc > '9' || (c[0]= (uchar) (wc - '0')) > 9; +} + + static longlong my_strtoll10_mb2(CHARSET_INFO *cs __attribute__((unused)), const char *nptr, char **endptr, int *error) @@ -921,7 +936,7 @@ my_strtoll10_mb2(CHARSET_INFO *cs __attribute__((unused)), { if ((res= mb_wc(cs, &wc, s, n_end)) <= 0) break; - if ((c= (wc - '0')) > 9) + if (wc2digit_uchar(&c, wc)) goto end_i; i= i*10+c; } @@ -938,7 +953,7 @@ my_strtoll10_mb2(CHARSET_INFO *cs __attribute__((unused)), { if ((res= mb_wc(cs, &wc, s, end)) <= 0) goto no_conv; - if ((c= (wc - '0')) > 9) + if (wc2digit_uchar(&c, wc)) goto end_i_and_j; s+= res; j= j * 10 + c; @@ -961,7 +976,7 @@ my_strtoll10_mb2(CHARSET_INFO *cs __attribute__((unused)), goto end4; if ((res= mb_wc(cs, &wc, s, end)) <= 0) goto no_conv; - if ((c= (wc - '0')) > 9) + if (wc2digit_uchar(&c, wc)) goto end4; s+= res; k= k*10+c; |