summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <bar@bar.mysql.r18.ru>2003-01-16 17:17:07 +0400
committerunknown <bar@bar.mysql.r18.ru>2003-01-16 17:17:07 +0400
commitbefc314c104c5e3d41139fa2d17bbeb23afad90a (patch)
tree63655aa98b051bb33cac94c520aec58962c9252b /strings
parentc23209c71c330fd9e4889056fafc023a7ef68385 (diff)
downloadmariadb-git-befc314c104c5e3d41139fa2d17bbeb23afad90a.tar.gz
strnto family functions now return error in a new argument
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-simple.c32
-rw-r--r--strings/ctype-utf8.c48
-rw-r--r--strings/ctype.c10
3 files changed, 51 insertions, 39 deletions
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 07e7a382f8a..df1609c983d 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -17,7 +17,6 @@
#include <my_global.h>
#include "m_string.h"
#include "m_ctype.h"
-#include "my_sys.h" /* defines errno */
#include <errno.h>
#include "stdarg.h"
@@ -203,7 +202,8 @@ void my_hash_sort_simple(CHARSET_INFO *cs,
long my_strntol_8bit(CHARSET_INFO *cs,
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr, int *err)
{
int negative;
register ulong cutoff;
@@ -303,14 +303,14 @@ long my_strntol_8bit(CHARSET_INFO *cs,
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]= ERANGE;
return negative ? LONG_MIN : LONG_MAX;
}
return (negative ? -((long) i) : (long) i);
noconv:
- my_errno=(EDOM);
+ err[0]= EDOM;
if (endptr != NULL)
*endptr = (char *) nptr;
return 0L;
@@ -318,7 +318,8 @@ noconv:
ulong my_strntoul_8bit(CHARSET_INFO *cs,
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr, int *err)
{
int negative;
register ulong cutoff;
@@ -409,14 +410,14 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs,
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]= ERANGE;
return ((ulong)~0L);
}
return (negative ? -((long) i) : (long) i);
noconv:
- my_errno=(EDOM);
+ err[0]= EDOM;
if (endptr != NULL)
*endptr = (char *) nptr;
return 0L;
@@ -424,7 +425,8 @@ noconv:
longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr,int *err)
{
int negative;
register ulonglong cutoff;
@@ -524,14 +526,14 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)),
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]= ERANGE;
return negative ? LONGLONG_MIN : LONGLONG_MAX;
}
return (negative ? -((longlong) i) : (longlong) i);
noconv:
- my_errno=(EDOM);
+ err[0]= EDOM;
if (endptr != NULL)
*endptr = (char *) nptr;
return 0L;
@@ -539,7 +541,8 @@ noconv:
ulonglong my_strntoull_8bit(CHARSET_INFO *cs,
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr, int *err)
{
int negative;
register ulonglong cutoff;
@@ -631,14 +634,14 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs,
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]= ERANGE;
return (~(ulonglong) 0);
}
return (negative ? -((longlong) i) : (longlong) i);
noconv:
- my_errno=(EDOM);
+ err[0]= EDOM;
if (endptr != NULL)
*endptr = (char *) nptr;
return 0L;
@@ -667,7 +670,8 @@ noconv:
double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)),
- char *str, uint length, char **end)
+ char *str, uint length,
+ char **end, int *err __attribute__ ((unused)))
{
char end_char;
double result;
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 7ca3395c2cc..e57f35bab19 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -21,7 +21,6 @@
#include <my_global.h>
#include "m_string.h"
#include "m_ctype.h"
-#include "my_sys.h" /* defines errno */
#include <errno.h>
#ifdef HAVE_CHARSET_utf8
@@ -2446,7 +2445,8 @@ static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused))
long my_strntol_ucs2(CHARSET_INFO *cs,
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr, int *err)
{
int negative=0;
int overflow;
@@ -2475,7 +2475,7 @@ long my_strntol_ucs2(CHARSET_INFO *cs,
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
+ err[0] = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
return 0;
}
s+=cnv;
@@ -2518,7 +2518,7 @@ bs:
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno=EILSEQ;
+ err[0]=EILSEQ;
return 0;
}
else
@@ -2533,7 +2533,7 @@ bs:
if (s == save)
{
- my_errno=EDOM;
+ err[0]=EDOM;
return 0L;
}
@@ -2547,7 +2547,7 @@ bs:
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]=ERANGE;
return negative ? LONG_MIN : LONG_MAX;
}
@@ -2556,7 +2556,8 @@ bs:
ulong my_strntoul_ucs2(CHARSET_INFO *cs,
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr, int *err)
{
int negative=0;
int overflow;
@@ -2585,7 +2586,7 @@ ulong my_strntoul_ucs2(CHARSET_INFO *cs,
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
+ err[0] = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
return 0;
}
s+=cnv;
@@ -2628,7 +2629,7 @@ bs:
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno=EILSEQ;
+ err[0]=EILSEQ;
return 0;
}
else
@@ -2643,13 +2644,13 @@ bs:
if (s == save)
{
- my_errno=EDOM;
+ err[0]=EDOM;
return 0L;
}
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]=(ERANGE);
return ((ulong)~0L);
}
@@ -2660,7 +2661,8 @@ bs:
longlong my_strntoll_ucs2(CHARSET_INFO *cs,
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr, int *err)
{
int negative=0;
int overflow;
@@ -2689,7 +2691,7 @@ longlong my_strntoll_ucs2(CHARSET_INFO *cs,
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
+ err[0] = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
return 0;
}
s+=cnv;
@@ -2732,7 +2734,7 @@ bs:
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno=EILSEQ;
+ err[0]=EILSEQ;
return 0;
}
else
@@ -2747,7 +2749,7 @@ bs:
if (s == save)
{
- my_errno=EDOM;
+ err[0]=EDOM;
return 0L;
}
@@ -2761,7 +2763,7 @@ bs:
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]=ERANGE;
return negative ? LONGLONG_MIN : LONGLONG_MAX;
}
@@ -2772,7 +2774,8 @@ bs:
ulonglong my_strntoull_ucs2(CHARSET_INFO *cs,
- const char *nptr, uint l, char **endptr, int base)
+ const char *nptr, uint l, int base,
+ char **endptr, int *err)
{
int negative=0;
int overflow;
@@ -2801,7 +2804,7 @@ ulonglong my_strntoull_ucs2(CHARSET_INFO *cs,
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno = (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
+ err[0]= (cnv==MY_CS_ILSEQ) ? EILSEQ : EDOM;
return 0;
}
s+=cnv;
@@ -2844,7 +2847,7 @@ bs:
{
if (endptr !=NULL )
*endptr = (char*)s;
- my_errno=EILSEQ;
+ err[0]= EILSEQ;
return 0;
}
else
@@ -2859,13 +2862,13 @@ bs:
if (s == save)
{
- my_errno=EDOM;
+ err[0]= EDOM;
return 0L;
}
if (overflow)
{
- my_errno=(ERANGE);
+ err[0]= ERANGE;
return (~(ulonglong) 0);
}
@@ -2874,7 +2877,8 @@ bs:
double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)),
- char *nptr, uint length, char **endptr)
+ char *nptr, uint length,
+ char **endptr, int *err __attribute__ ((unused)))
{
char buf[256];
double res;
diff --git a/strings/ctype.c b/strings/ctype.c
index 76636d17ace..615f0b7ef49 100644
--- a/strings/ctype.c
+++ b/strings/ctype.c
@@ -3983,6 +3983,7 @@ typedef struct my_cs_file_info
static int fill_uchar(uchar *a,uint size,const char *str, uint len)
{
+ int err=0;
uint i= 0;
const char *s, *b, *e=str+len;
@@ -3993,7 +3994,7 @@ static int fill_uchar(uchar *a,uint size,const char *str, uint len)
for ( ; (s < e) && !strchr(" \t\r\n",s[0]); s++) ;
if (s == b || i > size)
break;
- a[i]= my_strntoul(my_charset_latin1,b,s-b,NULL,16);
+ a[i]= my_strntoul(my_charset_latin1,b,s-b,16,NULL,&err);
}
return 0;
}
@@ -4001,6 +4002,8 @@ static int fill_uchar(uchar *a,uint size,const char *str, uint len)
static int fill_uint16(uint16 *a,uint size,const char *str, uint len)
{
uint i= 0;
+ int err;
+
const char *s, *b, *e=str+len;
for (s=str ; s < e ; i++)
{
@@ -4009,7 +4012,7 @@ static int fill_uint16(uint16 *a,uint size,const char *str, uint len)
for ( ; (s < e) && !strchr(" \t\r\n",s[0]); s++) ;
if (s == b || i > size)
break;
- a[i]= my_strntol(my_charset_latin1,b,s-b,NULL,16);
+ a[i]= my_strntol(my_charset_latin1,b,s-b,16,NULL,&err);
}
return 0;
}
@@ -4051,6 +4054,7 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len)
struct my_cs_file_info *i= (struct my_cs_file_info *)st->user_data;
struct my_cs_file_section_st *s;
int state= (s=cs_file_sec(st->attr,strlen(st->attr))) ? s->state : 0;
+ int err;
#ifndef DBUG_OFF
if(0){
@@ -4062,7 +4066,7 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len)
switch (state) {
case _CS_ID:
- i->cs.number= my_strntoul(my_charset_latin1,attr,len,(char**)NULL,0);
+ i->cs.number= my_strntoul(my_charset_latin1,attr,len,0,(char**)NULL,&err);
break;
case _CS_COLNAME:
i->cs.name=mstr(i->name,attr,len,MY_CS_NAME_SIZE-1);