forked from KolibriOS/kolibrios
newlib: update
git-svn-id: svn://kolibrios.org@3065 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
21
programs/develop/libraries/newlib/stdlib/atol.c
Normal file
21
programs/develop/libraries/newlib/stdlib/atol.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Andy Wilson, 2-Oct-89.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <_ansi.h>
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
long
|
||||
_DEFUN (atol, (s), _CONST char *s)
|
||||
{
|
||||
return strtol (s, NULL, 10);
|
||||
}
|
||||
#endif /* !_REENT_ONLY */
|
||||
|
||||
long
|
||||
_DEFUN (_atol_r, (ptr, s), struct _reent *ptr _AND _CONST char *s)
|
||||
{
|
||||
return _strtol_r (ptr, s, NULL, 10);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ Supporting OS subroutines required: <<_exit>>.
|
||||
* Exit, flushing stdio buffers if necessary.
|
||||
*/
|
||||
|
||||
void
|
||||
void
|
||||
_DEFUN (exit, (code),
|
||||
int code)
|
||||
{
|
||||
|
||||
@@ -299,15 +299,17 @@ _DEFUN (_strtod_r, (ptr, s00, se),
|
||||
}
|
||||
s0 = s;
|
||||
y = z = 0;
|
||||
for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
|
||||
for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) {
|
||||
if (nd < DBL_DIG + 1) {
|
||||
if (nd < 9)
|
||||
y = 10*y + c - '0';
|
||||
else if (nd < 16)
|
||||
else
|
||||
z = 10*z + c - '0';
|
||||
}
|
||||
}
|
||||
nd0 = nd;
|
||||
if (strncmp (s, _localeconv_r (ptr)->decimal_point,
|
||||
strlen (_localeconv_r (ptr)->decimal_point)) == 0)
|
||||
{
|
||||
strlen (_localeconv_r (ptr)->decimal_point)) == 0) {
|
||||
decpt = 1;
|
||||
c = *(s += strlen (_localeconv_r (ptr)->decimal_point));
|
||||
if (!nd) {
|
||||
@@ -325,16 +327,24 @@ _DEFUN (_strtod_r, (ptr, s00, se),
|
||||
have_dig:
|
||||
nz++;
|
||||
if (c -= '0') {
|
||||
nf += nz;
|
||||
for(i = 1; i < nz; i++)
|
||||
if (nd++ < 9)
|
||||
for(i = 1; i < nz; i++) {
|
||||
if (nd <= DBL_DIG + 1) {
|
||||
if (nd + i < 10)
|
||||
y *= 10;
|
||||
else if (nd <= DBL_DIG + 1)
|
||||
else
|
||||
z *= 10;
|
||||
if (nd++ < 9)
|
||||
}
|
||||
}
|
||||
if (nd <= DBL_DIG + 1) {
|
||||
if (nd + i < 10)
|
||||
y = 10*y + c;
|
||||
else if (nd <= DBL_DIG + 1)
|
||||
else
|
||||
z = 10*z + c;
|
||||
}
|
||||
if (nd <= DBL_DIG + 1) {
|
||||
nf += nz;
|
||||
nd += nz;
|
||||
}
|
||||
nz = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user