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
0b64be23
Commit
0b64be23
authored
May 05, 2010
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly add stdio.h and string.h to make strtod.c work standalone.
Found using Clang's static analyzer.
parent
c33e82d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
Python/strtod.c
Python/strtod.c
+9
-6
No files found.
Python/strtod.c
View file @
0b64be23
#include <stdio.h>
#include <string.h>
#include "pyconfig.h"
#include "pyconfig.h"
/* comp.sources.misc strtod(), as posted in comp.lang.tcl,
/* comp.sources.misc strtod(), as posted in comp.lang.tcl,
...
@@ -14,7 +17,7 @@
...
@@ -14,7 +17,7 @@
Defines: double strtod (char *str, char**ptr)
Defines: double strtod (char *str, char**ptr)
*/
*/
/* This is an implementation of the strtod() function described in the
/* This is an implementation of the strtod() function described in the
System V manuals, with a different name to avoid linker problems.
System V manuals, with a different name to avoid linker problems.
All that str2dbl() does itself is check that the argument is well-formed
All that str2dbl() does itself is check that the argument is well-formed
and is in range. It leaves the work of conversion to atof(), which is
and is in range. It leaves the work of conversion to atof(), which is
...
@@ -29,7 +32,7 @@
...
@@ -29,7 +32,7 @@
of strtod(), and if we give this one away maybe someone will look for
of strtod(), and if we give this one away maybe someone will look for
mistakes in it and fix them for us (:-).
mistakes in it and fix them for us (:-).
*/
*/
/* The following constants are machine-specific. MD{MIN,MAX}EXPT are
/* The following constants are machine-specific. MD{MIN,MAX}EXPT are
integers and MD{MIN,MAX}FRAC are strings such that
integers and MD{MIN,MAX}FRAC are strings such that
0.${MDMAXFRAC}e${MDMAXEXPT} is the largest representable double,
0.${MDMAXFRAC}e${MDMAXEXPT} is the largest representable double,
...
@@ -74,10 +77,10 @@ double strtod(char *str, char **ptr)
...
@@ -74,10 +77,10 @@ double strtod(char *str, char **ptr)
sign
=
1
;
sign
=
1
;
if
(
*
sp
==
'-'
)
sign
-=
2
,
sp
++
;
if
(
*
sp
==
'-'
)
sign
-=
2
,
sp
++
;
dotseen
=
0
,
scale
=
0
;
dotseen
=
0
,
scale
=
0
;
dp
=
buffer
;
dp
=
buffer
;
*
dp
++
=
'0'
;
*
dp
++
=
'.'
;
*
dp
++
=
'0'
;
*
dp
++
=
'.'
;
buforg
=
dp
,
buflim
=
buffer
+
48
;
buforg
=
dp
,
buflim
=
buffer
+
48
;
for
(
save
=
sp
;
c
=
*
sp
;
sp
++
)
for
(
save
=
sp
;
(
c
=
*
sp
)
;
sp
++
)
if
(
c
==
'.'
)
{
if
(
c
==
'.'
)
{
if
(
dotseen
)
break
;
if
(
dotseen
)
break
;
dotseen
++
;
dotseen
++
;
...
@@ -106,7 +109,7 @@ double strtod(char *str, char **ptr)
...
@@ -106,7 +109,7 @@ double strtod(char *str, char **ptr)
errno
=
EDOM
;
/* what should this be? */
errno
=
EDOM
;
/* what should this be? */
return
ZERO
;
return
ZERO
;
}
}
while
(
dp
>
buforg
&&
dp
[
-
1
]
==
'0'
)
--
dp
;
while
(
dp
>
buforg
&&
dp
[
-
1
]
==
'0'
)
--
dp
;
if
(
dp
==
buforg
)
*
dp
++
=
'0'
;
if
(
dp
==
buforg
)
*
dp
++
=
'0'
;
*
dp
=
'\0'
;
*
dp
=
'\0'
;
...
@@ -128,7 +131,7 @@ double strtod(char *str, char **ptr)
...
@@ -128,7 +131,7 @@ double strtod(char *str, char **ptr)
if
((
unsigned
)(
c
-
'0'
)
>
(
unsigned
)(
'9'
-
'0'
))
break
;
if
((
unsigned
)(
c
-
'0'
)
>
(
unsigned
)(
'9'
-
'0'
))
break
;
while
(
c
==
'0'
)
c
=
*
sp
++
;
while
(
c
==
'0'
)
c
=
*
sp
++
;
for
(;
(
unsigned
)(
c
-
'0'
)
<=
(
unsigned
)(
'9'
-
'0'
);
c
=
*
sp
++
)
for
(;
(
unsigned
)(
c
-
'0'
)
<=
(
unsigned
)(
'9'
-
'0'
);
c
=
*
sp
++
)
expt
=
expt
*
10
+
c
-
'0'
;
expt
=
expt
*
10
+
c
-
'0'
;
if
(
esign
<
0
)
expt
=
-
expt
;
if
(
esign
<
0
)
expt
=
-
expt
;
save
=
sp
-
1
;
save
=
sp
-
1
;
}
while
(
0
);
}
while
(
0
);
...
...
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