From 847ea719b6e9f41cfd0f4730a163c13f91c41fda Mon Sep 17 00:00:00 2001 From: "bar@bar.mysql.r18.ru" <> Date: Thu, 28 Nov 2002 11:04:26 +0400 Subject: [PATCH] New functions --- sql/item.h | 4 ++-- sql/item_func.h | 4 ++-- sql/item_sum.h | 4 ++-- strings/ctype-simple.c | 20 ++++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sql/item.h b/sql/item.h index 414dcfbc328..9e36e36adfb 100644 --- a/sql/item.h +++ b/sql/item.h @@ -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(); diff --git a/sql/item_func.h b/sql/item_func.h index 38f461acc13..352a9e0e272 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -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(); diff --git a/sql/item_sum.h b/sql/item_sum.h index 70bb3a7c0a1..00803abf25d 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -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(); diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index be4fdc9cb8d..b487159a733 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -18,6 +18,8 @@ #include "m_string.h" #include "m_ctype.h" #include "my_sys.h" /* defines errno */ +#include + #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;