Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
01fce5ad
Commit
01fce5ad
authored
May 03, 2009
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use PyOS_strnicmp for NaN and Inf detection: it's locale-aware.
parent
777e4ff5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
Python/pystrtod.c
Python/pystrtod.c
+16
-3
No files found.
Python/pystrtod.c
View file @
01fce5ad
...
@@ -40,6 +40,19 @@
...
@@ -40,6 +40,19 @@
correctly rounded results.
correctly rounded results.
*/
*/
/* Case-insensitive string match used for nan and inf detection; t should be
lower-case. Returns 1 for a successful match, 0 otherwise. */
static
int
case_insensitive_match
(
const
char
*
s
,
const
char
*
t
)
{
while
(
*
t
&&
Py_TOLOWER
(
*
s
)
==
*
t
)
{
s
++
;
t
++
;
}
return
*
t
?
0
:
1
;
}
double
double
PyOS_ascii_strtod
(
const
char
*
nptr
,
char
**
endptr
)
PyOS_ascii_strtod
(
const
char
*
nptr
,
char
**
endptr
)
{
{
...
@@ -89,9 +102,9 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
...
@@ -89,9 +102,9 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
/* Parse infinities and nans */
/* Parse infinities and nans */
if
(
*
p
==
'i'
||
*
p
==
'I'
)
{
if
(
*
p
==
'i'
||
*
p
==
'I'
)
{
if
(
PyOS_strnicmp
(
p
,
"inf"
,
3
)
==
0
)
{
if
(
case_insensitive_match
(
p
+
1
,
"nf"
)
)
{
val
=
Py_HUGE_VAL
;
val
=
Py_HUGE_VAL
;
if
(
PyOS_strnicmp
(
p
+
3
,
"inity"
,
5
)
==
0
)
if
(
case_insensitive_match
(
p
+
3
,
"inity"
)
)
fail_pos
=
(
char
*
)
p
+
8
;
fail_pos
=
(
char
*
)
p
+
8
;
else
else
fail_pos
=
(
char
*
)
p
+
3
;
fail_pos
=
(
char
*
)
p
+
3
;
...
@@ -102,7 +115,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
...
@@ -102,7 +115,7 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
}
}
#ifdef Py_NAN
#ifdef Py_NAN
if
(
*
p
==
'n'
||
*
p
==
'N'
)
{
if
(
*
p
==
'n'
||
*
p
==
'N'
)
{
if
(
PyOS_strnicmp
(
p
,
"nan"
,
3
)
==
0
)
{
if
(
case_insensitive_match
(
p
+
1
,
"an"
)
)
{
val
=
Py_NAN
;
val
=
Py_NAN
;
fail_pos
=
(
char
*
)
p
+
3
;
fail_pos
=
(
char
*
)
p
+
3
;
goto
got_val
;
goto
got_val
;
...
...
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