summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-05-13 14:04:32 +0300
committermonty@mysql.com <>2005-05-13 14:04:32 +0300
commitb54d7d04bd13498b5bc5e8e109f5690aeb10ec5d (patch)
treee79a2291f34c9b4f5b7aa00b0d318368038008da /strings
parent1494f0ab6815075840728839dad528a37082def6 (diff)
downloadmariadb-git-b54d7d04bd13498b5bc5e8e109f5690aeb10ec5d.tar.gz
Fixes during review
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-ucs2.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index f12cfe3256e..12c1ae905cf 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1251,7 +1251,7 @@ static
uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e)
{
- return (e-b)/2;
+ return (uint) (e-b)/2;
}
@@ -1261,7 +1261,8 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *e __attribute__((unused)),
uint pos)
{
- return pos > e - b ? e - b + 2 : pos * 2;
+ uint string_length= (uint) (e - b);
+ return pos > string_length ? string_length + 2 : pos * 2;
}
@@ -1270,7 +1271,8 @@ uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)),
const char *b, const char *e,
uint nchars, int *error)
{
- uint nbytes= (e-b) & ~ (uint)1;
+ /* Ensure string length is dividable with 2 */
+ uint nbytes= ((uint) (e-b)) & ~(uint) 1;
*error= 0;
nchars*= 2;
return min(nbytes, nchars);