mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
New functions
This commit is contained in:
@ -536,9 +536,9 @@ public:
|
||||
enum Type type() const { return COPY_STR_ITEM; }
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
double val()
|
||||
{ return null_value ? 0.0 : atof(str_value.c_ptr()); }
|
||||
{ return null_value ? 0.0 : my_strntod(str_value.charset(),str_value.ptr(),str_value.length(),NULL); }
|
||||
longlong val_int()
|
||||
{ return null_value ? LL(0) : strtoll(str_value.c_ptr(),(char**) 0,10); }
|
||||
{ return null_value ? LL(0) : my_strntoll(str_value.charset(),str_value.ptr(),str_value.length(),(char**) 0,10); }
|
||||
String *val_str(String*);
|
||||
void make_field(Send_field *field) { item->make_field(field); }
|
||||
void copy();
|
||||
|
@ -801,12 +801,12 @@ public:
|
||||
double val()
|
||||
{
|
||||
String *res; res=val_str(&str_value);
|
||||
return res ? atof(res->c_ptr()) : 0.0;
|
||||
return res ? my_strntod(res->charset(),res->ptr(),res->length(),0) : 0.0;
|
||||
}
|
||||
longlong val_int()
|
||||
{
|
||||
String *res; res=val_str(&str_value);
|
||||
return res ? strtoll(res->c_ptr(),(char**) 0,10) : (longlong) 0;
|
||||
return res ? my_strntoll(res->charset(),res->ptr(),res->length(),(char**) 0,10) : (longlong) 0;
|
||||
}
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
void fix_length_and_dec();
|
||||
|
@ -442,12 +442,12 @@ public:
|
||||
double val()
|
||||
{
|
||||
String *res; res=val_str(&str_value);
|
||||
return res ? atof(res->c_ptr()) : 0.0;
|
||||
return res ? my_strntod(res->charset(),res->ptr(),res->length(),(char**) 0) : 0.0;
|
||||
}
|
||||
longlong val_int()
|
||||
{
|
||||
String *res; res=val_str(&str_value);
|
||||
return res ? strtoll(res->c_ptr(),(char**) 0,10) : (longlong) 0;
|
||||
return res ? my_strntoll(res->charset(),res->ptr(),res->length(),(char**) 0,10) : (longlong) 0;
|
||||
}
|
||||
enum Item_result result_type () const { return STRING_RESULT; }
|
||||
void fix_length_and_dec();
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "m_string.h"
|
||||
#include "m_ctype.h"
|
||||
#include "my_sys.h" /* defines errno */
|
||||
#include <errno.h>
|
||||
|
||||
#include "stdarg.h"
|
||||
#include "assert.h"
|
||||
|
||||
@ -246,8 +248,6 @@ void my_hash_sort_simple(CHARSET_INFO *cs,
|
||||
}
|
||||
|
||||
|
||||
#define MY_ERRNO(y)
|
||||
|
||||
long my_strntol_8bit(CHARSET_INFO *cs,
|
||||
const char *nptr, uint l, char **endptr, int base)
|
||||
{
|
||||
@ -349,14 +349,14 @@ long my_strntol_8bit(CHARSET_INFO *cs,
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
MY_ERRNO(ERANGE);
|
||||
my_errno=(ERANGE);
|
||||
return negative ? LONG_MIN : LONG_MAX;
|
||||
}
|
||||
|
||||
return (negative ? -((long) i) : (long) i);
|
||||
|
||||
noconv:
|
||||
MY_ERRNO(EDOM);
|
||||
my_errno=(EDOM);
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *) nptr;
|
||||
return 0L;
|
||||
@ -455,14 +455,14 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
MY_ERRNO(ERANGE);
|
||||
my_errno=(ERANGE);
|
||||
return ((ulong)~0L);
|
||||
}
|
||||
|
||||
return (negative ? -((long) i) : (long) i);
|
||||
|
||||
noconv:
|
||||
MY_ERRNO(EDOM);
|
||||
my_errno=(EDOM);
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *) nptr;
|
||||
return 0L;
|
||||
@ -570,14 +570,14 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
MY_ERRNO(ERANGE);
|
||||
my_errno=(ERANGE);
|
||||
return negative ? LONGLONG_MIN : LONGLONG_MAX;
|
||||
}
|
||||
|
||||
return (negative ? -((longlong) i) : (longlong) i);
|
||||
|
||||
noconv:
|
||||
MY_ERRNO(EDOM);
|
||||
my_errno=(EDOM);
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *) nptr;
|
||||
return 0L;
|
||||
@ -677,14 +677,14 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs,
|
||||
|
||||
if (overflow)
|
||||
{
|
||||
MY_ERRNO(ERANGE);
|
||||
my_errno=(ERANGE);
|
||||
return (~(ulonglong) 0);
|
||||
}
|
||||
|
||||
return (negative ? -((longlong) i) : (longlong) i);
|
||||
|
||||
noconv:
|
||||
MY_ERRNO(EDOM);
|
||||
my_errno=(EDOM);
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *) nptr;
|
||||
return 0L;
|
||||
|
Reference in New Issue
Block a user