mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-30879 Add support for up to BASE 62 to CONV()
BASE 62 uses 0-9, A-Z and then a-z to give the numbers 0-61. This patch increases the range of the string functions to cover this. Based on ideas and tests in PR #2589, but re-written into the charset functions. Includes fix by Sergei, UBSAN complained: ctype-simple.c:683:38: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself Co-authored-by: Weijun Huang <huangweijun1001@gmail.com> Co-authored-by: Sergei Golubchik <serg@mariadb.org>
This commit is contained in:
committed by
Andrew Hutchings
parent
be6d48fd53
commit
f552febe43
@@ -451,7 +451,11 @@ long my_strntol_8bit(CHARSET_INFO *cs,
|
||||
else if (c>='A' && c<='Z')
|
||||
c = c - 'A' + 10;
|
||||
else if (c>='a' && c<='z')
|
||||
{
|
||||
c = c - 'a' + 10;
|
||||
if (base > 36)
|
||||
c += 26;
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
@@ -546,7 +550,11 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
|
||||
else if (c>='A' && c<='Z')
|
||||
c = c - 'A' + 10;
|
||||
else if (c>='a' && c<='z')
|
||||
{
|
||||
c = c - 'a' + 10;
|
||||
if (base > 36)
|
||||
c += 26;
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
@@ -634,7 +642,11 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
|
||||
else if (c>='A' && c<='Z')
|
||||
c = c - 'A' + 10;
|
||||
else if (c>='a' && c<='z')
|
||||
{
|
||||
c = c - 'a' + 10;
|
||||
if (base > 36)
|
||||
c += 26;
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
@@ -656,8 +668,12 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
if (negative)
|
||||
{
|
||||
if (i > (ulonglong) LONGLONG_MIN)
|
||||
if (i >= (ulonglong) LONGLONG_MIN)
|
||||
{
|
||||
if (i == (ulonglong) LONGLONG_MIN)
|
||||
return LONGLONG_MIN;
|
||||
overflow = 1;
|
||||
}
|
||||
}
|
||||
else if (i > (ulonglong) LONGLONG_MAX)
|
||||
overflow = 1;
|
||||
@@ -731,7 +747,11 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs,
|
||||
else if (c>='A' && c<='Z')
|
||||
c = c - 'A' + 10;
|
||||
else if (c>='a' && c<='z')
|
||||
{
|
||||
c = c - 'a' + 10;
|
||||
if (base > 36)
|
||||
c += 26;
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
|
Reference in New Issue
Block a user