Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
ec7c4ea7
Commit
ec7c4ea7
authored
Nov 29, 2002
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
my_strntod_ucs2 and my_strntol_ucs2 fixes
parent
e1cb8679
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
98 deletions
+112
-98
strings/ctype-utf8.c
strings/ctype-utf8.c
+112
-98
No files found.
strings/ctype-utf8.c
View file @
ec7c4ea7
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#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>
#ifdef HAVE_CHARSET_utf8
#ifdef HAVE_CHARSET_utf8
#define HAVE_UNIDATA
#define HAVE_UNIDATA
...
@@ -2118,7 +2118,7 @@ static int my_ucs2_uni (CHARSET_INFO *cs __attribute__((unused)) ,
...
@@ -2118,7 +2118,7 @@ static int my_ucs2_uni (CHARSET_INFO *cs __attribute__((unused)) ,
my_wc_t
*
pwc
,
const
uchar
*
s
,
const
uchar
*
e
)
my_wc_t
*
pwc
,
const
uchar
*
s
,
const
uchar
*
e
)
{
{
if
(
s
+
2
>
e
)
/* Need 2 characters */
if
(
s
+
2
>
e
)
/* Need 2 characters */
return
MY_CS_
ILSEQ
;
return
MY_CS_
TOOFEW
(
0
)
;
*
pwc
=
((
unsigned
char
)
s
[
0
])
*
256
+
((
unsigned
char
)
s
[
1
]);
*
pwc
=
((
unsigned
char
)
s
[
0
])
*
256
+
((
unsigned
char
)
s
[
1
]);
return
2
;
return
2
;
...
@@ -2441,118 +2441,114 @@ static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused))
...
@@ -2441,118 +2441,114 @@ static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused))
return
my_vsnprintf_ucs2
(
to
,
n
,
fmt
,
args
);
return
my_vsnprintf_ucs2
(
to
,
n
,
fmt
,
args
);
}
}
#define MY_ERRNO(x)
long
my_strntol_ucs2
(
CHARSET_INFO
*
cs
,
long
my_strntol_ucs2
(
CHARSET_INFO
*
cs
,
const
char
*
nptr
,
uint
l
,
char
**
endptr
,
int
base
)
const
char
*
nptr
,
uint
l
,
char
**
endptr
,
int
base
)
{
{
int
negative
;
int
negative
=
0
;
register
ulong
cutoff
;
int
overflow
;
int
cnv
;
my_wc_t
wc
;
register
unsigned
int
cutlim
;
register
unsigned
int
cutlim
;
register
ulong
i
;
register
ulong
cutoff
;
register
const
char
*
s
;
register
ulong
re
s
;
register
unsigned
char
c
;
register
const
char
*
s
=
nptr
;
const
char
*
save
,
*
e
;
register
const
char
*
e
=
nptr
+
l
;
int
overflow
;
const
char
*
save
;
if
(
base
<
0
||
base
==
1
||
base
>
36
)
do
{
base
=
10
;
if
((
cnv
=
cs
->
mb_wc
(
cs
,
&
wc
,
s
,
e
))
>
0
)
{
switch
(
wc
)
{
case
' '
:
break
;
case
'\t'
:
break
;
case
'-'
:
negative
=
!
negative
;
break
;
case
'+'
:
break
;
default
:
goto
bs
;
}
}
else
/* No more characters or bad multibyte sequence */
{
if
(
endptr
!=
NULL
)
*
endptr
=
(
char
*
)
s
;
my_errno
=
(
cnv
==
MY_CS_ILSEQ
)
?
EILSEQ
:
EDOM
;
return
0
;
}
s
+=
cnv
;
}
while
(
1
);
s
=
nptr
;
bs:
e
=
nptr
+
l
;
for
(
;
s
<
e
&&
my_isspace
(
cs
,
*
s
)
;
s
++
);
if
(
base
<=
0
||
base
==
1
||
base
>
36
)
base
=
10
;
if
(
s
==
e
)
overflow
=
0
;
{
res
=
0
;
goto
noconv
;
save
=
s
;
}
cutoff
=
((
ulong
)
~
0L
)
/
(
unsigned
long
int
)
base
;
cutlim
=
(
uint
)
(((
ulong
)
~
0L
)
%
(
unsigned
long
int
)
base
);
/* Check for a sign. */
do
{
if
(
*
s
==
'-'
)
if
((
cnv
=
cs
->
mb_wc
(
cs
,
&
wc
,
s
,
e
))
>
0
)
{
negative
=
1
;
++
s
;
}
else
if
(
*
s
==
'+'
)
{
negative
=
0
;
++
s
;
}
else
negative
=
0
;
if
(
base
==
16
&&
s
[
0
]
==
'0'
&&
my_toupper
(
cs
,
s
[
1
])
==
'X'
)
s
+=
2
;
if
(
base
==
0
)
{
if
(
*
s
==
'0'
)
{
{
if
(
my_toupper
(
cs
,
s
[
1
])
==
'X'
)
s
+=
cnv
;
if
(
wc
>=
'0'
&&
wc
<=
'9'
)
wc
-=
'0'
;
else
if
(
wc
>=
'A'
&&
wc
<=
'Z'
)
wc
=
wc
-
'A'
+
10
;
else
if
(
wc
>=
'a'
&&
wc
<=
'z'
)
wc
=
wc
-
'a'
+
10
;
else
break
;
if
((
int
)
wc
>=
base
)
break
;
if
(
res
>
cutoff
||
(
res
==
cutoff
&&
wc
>
cutlim
))
overflow
=
1
;
else
{
{
s
+=
2
;
res
*=
(
ulong
)
base
;
base
=
16
;
res
+=
wc
;
}
}
else
base
=
8
;
}
}
else
else
if
(
cnv
==
MY_CS_ILSEQ
)
base
=
10
;
{
}
if
(
endptr
!=
NULL
)
*
endptr
=
(
char
*
)
s
;
save
=
s
;
my_errno
=
EILSEQ
;
cutoff
=
((
ulong
)
~
0L
)
/
(
unsigned
long
int
)
base
;
return
0
;
cutlim
=
(
uint
)
(((
ulong
)
~
0L
)
%
(
unsigned
long
int
)
base
);
}
overflow
=
0
;
i
=
0
;
for
(
c
=
*
s
;
s
!=
e
;
c
=
*++
s
)
{
if
(
my_isdigit
(
cs
,
c
))
c
-=
'0'
;
else
if
(
my_isalpha
(
cs
,
c
))
c
=
my_toupper
(
cs
,
c
)
-
'A'
+
10
;
else
break
;
if
(
c
>=
base
)
break
;
if
(
i
>
cutoff
||
(
i
==
cutoff
&&
c
>
cutlim
))
overflow
=
1
;
else
else
{
{
i
*=
(
ulong
)
base
;
/* No more characters */
i
+=
c
;
break
;
}
}
}
}
while
(
1
);
if
(
s
==
save
)
goto
noconv
;
if
(
endptr
!=
NULL
)
if
(
endptr
!=
NULL
)
*
endptr
=
(
char
*
)
s
;
*
endptr
=
(
char
*
)
s
;
if
(
s
==
save
)
{
my_errno
=
EDOM
;
return
0L
;
}
if
(
negative
)
if
(
negative
)
{
{
if
(
i
>
(
ulong
)
LONG_MIN
)
if
(
res
>
(
ulong
)
LONG_MIN
)
overflow
=
1
;
overflow
=
1
;
}
}
else
if
(
i
>
(
ulong
)
LONG_MAX
)
else
if
(
res
>
(
ulong
)
LONG_MAX
)
overflow
=
1
;
overflow
=
1
;
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
)
res
)
:
(
long
)
res
);
noconv:
MY_ERRNO
(
EDOM
);
if
(
endptr
!=
NULL
)
*
endptr
=
(
char
*
)
nptr
;
return
0L
;
}
}
...
@@ -2646,14 +2642,14 @@ ulong my_strntoul_ucs2(CHARSET_INFO *cs,
...
@@ -2646,14 +2642,14 @@ ulong my_strntoul_ucs2(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
;
...
@@ -2759,14 +2755,14 @@ longlong my_strntoll_ucs2(CHARSET_INFO *cs __attribute__((unused)),
...
@@ -2759,14 +2755,14 @@ longlong my_strntoll_ucs2(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
;
...
@@ -2864,35 +2860,53 @@ ulonglong my_strntoull_ucs2(CHARSET_INFO *cs,
...
@@ -2864,35 +2860,53 @@ ulonglong my_strntoull_ucs2(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
;
}
}
double
my_strntod_ucs2
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
double
my_strntod_ucs2
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
const
char
*
s
,
uint
l
,
char
**
e
)
const
char
*
nptr
,
uint
l
,
char
**
endptr
)
{
{
char
buf
[
256
];
char
buf
[
256
];
double
res
;
double
res
;
register
char
*
b
=
buf
;
register
const
char
*
s
=
nptr
;
register
const
char
*
e
=
nptr
+
l
;
my_wc_t
wc
;
int
cnv
;
if
((
l
+
1
)
>
sizeof
(
buf
))
if
((
l
+
1
)
>
sizeof
(
buf
))
{
{
if
(
e
)
if
(
endptr
)
memcpy
(
*
e
,
s
,
sizeof
(
s
));
*
endptr
=
(
char
*
)
nptr
;
my_errno
=
ERANGE
;
return
0
;
return
0
;
}
}
strncpy
(
buf
,
s
,
l
);
buf
[
l
]
=
'\0'
;
while
((
cnv
=
cs
->
mb_wc
(
cs
,
&
wc
,
s
,
e
))
>
0
)
res
=
strtod
(
buf
,
e
);
{
if
(
e
)
s
+=
cnv
;
memcpy
(
*
e
,
*
e
-
buf
+
s
,
sizeof
(
s
));
if
(
wc
<
128
)
{
*
b
++=
wc
;
}
else
break
;
}
*
b
=
'\0'
;
res
=
strtod
(
buf
,
endptr
);
if
(
endptr
)
*
endptr
=
(
char
*
)
(
*
endptr
-
buf
+
nptr
);
return
res
;
return
res
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment