1
0
mirror of https://github.com/MariaDB/server.git synced 2025-11-30 05:23:50 +03:00

Moving implementation of INET_ATON() INET_NTOA() into

separate files item_inetfunc.h and item_inetfunc.cc.
This commit is contained in:
Alexander Barkov
2014-05-30 15:24:25 +04:00
parent 69742e4ee3
commit 1449d1d54f
9 changed files with 186 additions and 123 deletions

View File

@@ -3861,48 +3861,6 @@ void Item_func_export_set::fix_length_and_dec()
fix_char_length(length * 64 + sep_length * 63);
}
String* Item_func_inet_ntoa::val_str(String* str)
{
DBUG_ASSERT(fixed == 1);
uchar buf[8], *p;
ulonglong n = (ulonglong) args[0]->val_int();
char num[4];
/*
We do not know if args[0] is NULL until we have called
some val function on it if args[0] is not a constant!
Also return null if n > 255.255.255.255
*/
if ((null_value= (args[0]->null_value || n > 0xffffffff)))
return 0; // Null value
str->set_charset(collation.collation);
str->length(0);
int4store(buf,n);
/* Now we can assume little endian. */
num[3]='.';
for (p=buf+4 ; p-- > buf ; )
{
uint c = *p;
uint n1,n2; // Try to avoid divisions
n1= c / 100; // 100 digits
c-= n1*100;
n2= c / 10; // 10 digits
c-=n2*10; // last digit
num[0]=(char) n1+'0';
num[1]=(char) n2+'0';
num[2]=(char) c+'0';
uint length= (n1 ? 4 : n2 ? 3 : 2); // Remove pre-zero
uint dot_length= (p <= buf) ? 1 : 0;
(void) str->append(num + 4 - length, length - dot_length,
&my_charset_latin1);
}
return str;
}
#define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7))