version 1.1, 2012/02/21 23:47:52
|
version 1.1.1.3, 2014/06/15 20:04:04
|
Line 267 BEGIN_EXTERN_C()
|
Line 267 BEGIN_EXTERN_C()
|
|
|
#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + \ |
#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + \ |
defined(IBM) != 1 |
defined(IBM) != 1 |
Exactly one of IEEE_LITTLE_ENDIAN IEEE_BIG_ENDIAN, VAX, or | #error "Exactly one of IEEE_LITTLE_ENDIAN IEEE_BIG_ENDIAN, VAX, or IBM should be defined." |
IBM should be defined. | |
#endif |
#endif |
|
|
typedef union { |
typedef union { |
Line 2037 ret1:
|
Line 2036 ret1:
|
return s0; |
return s0; |
} |
} |
|
|
/* F* VC6 */ | ZEND_API double zend_strtod (CONST char *s00, CONST char **se) |
#if _MSC_VER <= 1300 | |
# pragma optimize( "", off ) | |
#endif | |
ZEND_API double zend_strtod (CONST char *s00, char **se) | |
{ |
{ |
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, |
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, |
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; |
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; |
Line 2574 retfree:
|
Line 2569 retfree:
|
Bfree(delta); |
Bfree(delta); |
ret: |
ret: |
if (se) |
if (se) |
*se = (char *)s; | *se = s; |
result = sign ? -value(rv) : value(rv); |
result = sign ? -value(rv) : value(rv); |
|
|
_THREAD_PRIVATE_MUTEX_LOCK(pow5mult_mutex); |
_THREAD_PRIVATE_MUTEX_LOCK(pow5mult_mutex); |
Line 2588 ret:
|
Line 2583 ret:
|
return result; |
return result; |
} |
} |
|
|
ZEND_API double zend_hex_strtod(const char *str, char **endptr) | ZEND_API double zend_hex_strtod(const char *str, const char **endptr) |
{ |
{ |
const char *s = str; |
const char *s = str; |
char c; |
char c; |
int any = 0; |
int any = 0; |
double value = 0; |
double value = 0; |
|
|
|
if (strlen(str) < 2) { |
|
*endptr = str; |
|
return 0.0; |
|
} |
|
|
if (*s == '0' && (s[1] == 'x' || s[1] == 'X')) { |
if (*s == '0' && (s[1] == 'x' || s[1] == 'X')) { |
s += 2; |
s += 2; |
} |
} |
Line 2615 ZEND_API double zend_hex_strtod(const char *str, char
|
Line 2615 ZEND_API double zend_hex_strtod(const char *str, char
|
} |
} |
|
|
if (endptr != NULL) { |
if (endptr != NULL) { |
*endptr = (char *)(any ? s - 1 : str); | *endptr = any ? s - 1 : str; |
} |
} |
|
|
return value; |
return value; |
} |
} |
|
|
ZEND_API double zend_oct_strtod(const char *str, char **endptr) | ZEND_API double zend_oct_strtod(const char *str, const char **endptr) |
{ |
{ |
const char *s = str; |
const char *s = str; |
char c; |
char c; |
double value = 0; |
double value = 0; |
int any = 0; |
int any = 0; |
|
|
|
if (strlen(str) < 1) { |
|
*endptr = str; |
|
return 0.0; |
|
} |
|
|
/* skip leading zero */ |
/* skip leading zero */ |
s++; |
s++; |
|
|
Line 2643 ZEND_API double zend_oct_strtod(const char *str, char
|
Line 2648 ZEND_API double zend_oct_strtod(const char *str, char
|
} |
} |
|
|
if (endptr != NULL) { |
if (endptr != NULL) { |
|
*endptr = any ? s - 1 : str; |
|
} |
|
|
|
return value; |
|
} |
|
|
|
ZEND_API double zend_bin_strtod(const char *str, const char **endptr) |
|
{ |
|
const char *s = str; |
|
char c; |
|
double value = 0; |
|
int any = 0; |
|
|
|
if (strlen(str) < 2) { |
|
*endptr = str; |
|
return 0.0; |
|
} |
|
|
|
if ('0' == *s && ('b' == s[1] || 'B' == s[1])) { |
|
s += 2; |
|
} |
|
|
|
while ((c = *s++)) { |
|
/* |
|
* Verify the validity of the current character as a base-2 digit. In |
|
* the event that an invalid digit is found, halt the conversion and |
|
* return the portion which has been converted thus far. |
|
*/ |
|
if ('0' == c || '1' == c) |
|
value = value * 2 + c - '0'; |
|
else |
|
break; |
|
|
|
any = 1; |
|
} |
|
|
|
/* |
|
* As with many strtoX implementations, should the subject sequence be |
|
* empty or not well-formed, no conversion is performed and the original |
|
* value of str is stored in *endptr, provided that endptr is not a null |
|
* pointer. |
|
*/ |
|
if (NULL != endptr) { |
*endptr = (char *)(any ? s - 1 : str); |
*endptr = (char *)(any ? s - 1 : str); |
} |
} |
|
|