Commit 847ea719 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

New functions

parent a3ae370d
...@@ -536,9 +536,9 @@ public: ...@@ -536,9 +536,9 @@ public:
enum Type type() const { return COPY_STR_ITEM; } enum Type type() const { return COPY_STR_ITEM; }
enum Item_result result_type () const { return STRING_RESULT; } enum Item_result result_type () const { return STRING_RESULT; }
double val() 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() 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*); String *val_str(String*);
void make_field(Send_field *field) { item->make_field(field); } void make_field(Send_field *field) { item->make_field(field); }
void copy(); void copy();
......
...@@ -801,12 +801,12 @@ public: ...@@ -801,12 +801,12 @@ public:
double val() double val()
{ {
String *res; res=val_str(&str_value); 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() longlong val_int()
{ {
String *res; res=val_str(&str_value); 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; } enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec(); void fix_length_and_dec();
......
...@@ -442,12 +442,12 @@ public: ...@@ -442,12 +442,12 @@ public:
double val() double val()
{ {
String *res; res=val_str(&str_value); 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() longlong val_int()
{ {
String *res; res=val_str(&str_value); 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; } enum Item_result result_type () const { return STRING_RESULT; }
void fix_length_and_dec(); void fix_length_and_dec();
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "m_string.h" #include "m_string.h"
#include "m_ctype.h" #include "m_ctype.h"
#include "my_sys.h" /* defines errno */ #include "my_sys.h" /* defines errno */
#include <errno.h>
#include "stdarg.h" #include "stdarg.h"
#include "assert.h" #include "assert.h"
...@@ -246,8 +248,6 @@ void my_hash_sort_simple(CHARSET_INFO *cs, ...@@ -246,8 +248,6 @@ void my_hash_sort_simple(CHARSET_INFO *cs,
} }
#define MY_ERRNO(y)
long my_strntol_8bit(CHARSET_INFO *cs, long my_strntol_8bit(CHARSET_INFO *cs,
const char *nptr, uint l, char **endptr, int base) const char *nptr, uint l, char **endptr, int base)
{ {
...@@ -349,14 +349,14 @@ long my_strntol_8bit(CHARSET_INFO *cs, ...@@ -349,14 +349,14 @@ long my_strntol_8bit(CHARSET_INFO *cs,
if (overflow) if (overflow)
{ {
MY_ERRNO(ERANGE); my_errno=(ERANGE);
return negative ? LONG_MIN : LONG_MAX; return negative ? LONG_MIN : LONG_MAX;
} }
return (negative ? -((long) i) : (long) i); return (negative ? -((long) i) : (long) i);
noconv: noconv:
MY_ERRNO(EDOM); my_errno=(EDOM);
if (endptr != NULL) if (endptr != NULL)
*endptr = (char *) nptr; *endptr = (char *) nptr;
return 0L; return 0L;
...@@ -455,14 +455,14 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, ...@@ -455,14 +455,14 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
if (overflow) if (overflow)
{ {
MY_ERRNO(ERANGE); my_errno=(ERANGE);
return ((ulong)~0L); return ((ulong)~0L);
} }
return (negative ? -((long) i) : (long) i); return (negative ? -((long) i) : (long) i);
noconv: noconv:
MY_ERRNO(EDOM); my_errno=(EDOM);
if (endptr != NULL) if (endptr != NULL)
*endptr = (char *) nptr; *endptr = (char *) nptr;
return 0L; return 0L;
...@@ -570,14 +570,14 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), ...@@ -570,14 +570,14 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
if (overflow) if (overflow)
{ {
MY_ERRNO(ERANGE); my_errno=(ERANGE);
return negative ? LONGLONG_MIN : LONGLONG_MAX; return negative ? LONGLONG_MIN : LONGLONG_MAX;
} }
return (negative ? -((longlong) i) : (longlong) i); return (negative ? -((longlong) i) : (longlong) i);
noconv: noconv:
MY_ERRNO(EDOM); my_errno=(EDOM);
if (endptr != NULL) if (endptr != NULL)
*endptr = (char *) nptr; *endptr = (char *) nptr;
return 0L; return 0L;
...@@ -677,14 +677,14 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs, ...@@ -677,14 +677,14 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs,
if (overflow) if (overflow)
{ {
MY_ERRNO(ERANGE); my_errno=(ERANGE);
return (~(ulonglong) 0); return (~(ulonglong) 0);
} }
return (negative ? -((longlong) i) : (longlong) i); return (negative ? -((longlong) i) : (longlong) i);
noconv: noconv:
MY_ERRNO(EDOM); my_errno=(EDOM);
if (endptr != NULL) if (endptr != NULL)
*endptr = (char *) nptr; *endptr = (char *) nptr;
return 0L; return 0L;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment