@@ -114,7 +114,7 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
114
114
char * strval ;
115
115
116
116
strval = op -> value .str .val ;
117
- switch ((op -> type = is_numeric_string (strval , op -> value .str .len , & op -> value .lval , & op -> value .dval ))) {
117
+ switch ((op -> type = is_numeric_string (strval , op -> value .str .len , & op -> value .lval , & op -> value .dval , 1 ))) {
118
118
case IS_DOUBLE :
119
119
case IS_LONG :
120
120
break ;
@@ -152,7 +152,7 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC)
152
152
switch ((op)->type) { \
153
153
case IS_STRING: \
154
154
{ \
155
- switch (((holder).type=is_numeric_string((op)->value.str.val, (op)->value.str.len, &(holder).value.lval, &(holder).value.dval))) { \
155
+ switch (((holder).type=is_numeric_string((op)->value.str.val, (op)->value.str.len, &(holder).value.lval, &(holder).value.dval, 1 ))) { \
156
156
case IS_DOUBLE: \
157
157
case IS_LONG: \
158
158
break; \
@@ -1456,7 +1456,7 @@ ZEND_API int increment_function(zval *op1)
1456
1456
double dval ;
1457
1457
char * strval = op1 -> value .str .val ;
1458
1458
1459
- switch (is_numeric_string (strval , op1 -> value .str .len , & lval , & dval )) {
1459
+ switch (is_numeric_string (strval , op1 -> value .str .len , & lval , & dval , 0 )) {
1460
1460
case IS_LONG :
1461
1461
op1 -> value .lval = lval + 1 ;
1462
1462
op1 -> type = IS_LONG ;
@@ -1502,7 +1502,7 @@ ZEND_API int decrement_function(zval *op1)
1502
1502
op1 -> value .lval = -1 ;
1503
1503
op1 -> type = IS_LONG ;
1504
1504
break ;
1505
- } else if (is_numeric_string (op1 -> value .str .val , op1 -> value .str .len , & lval , NULL )== IS_LONG ) { /* long */
1505
+ } else if (is_numeric_string (op1 -> value .str .val , op1 -> value .str .len , & lval , NULL , 0 )== IS_LONG ) { /* long */
1506
1506
STR_FREE (op1 -> value .str .val );
1507
1507
op1 -> value .lval = lval - 1 ;
1508
1508
op1 -> type = IS_LONG ;
@@ -1627,8 +1627,8 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2)
1627
1627
long lval1 , lval2 ;
1628
1628
double dval1 , dval2 ;
1629
1629
1630
- if ((ret1 = is_numeric_string (s1 -> value .str .val , s1 -> value .str .len , & lval1 , & dval1 )) &&
1631
- (ret2 = is_numeric_string (s2 -> value .str .val , s2 -> value .str .len , & lval2 , & dval2 ))) {
1630
+ if ((ret1 = is_numeric_string (s1 -> value .str .val , s1 -> value .str .len , & lval1 , & dval1 , 0 )) &&
1631
+ (ret2 = is_numeric_string (s2 -> value .str .val , s2 -> value .str .len , & lval2 , & dval2 , 0 ))) {
1632
1632
#if 0 && WITH_BCMATH
1633
1633
if ((ret1 == FLAG_IS_BC ) || (ret2 == FLAG_IS_BC )) {
1634
1634
bc_num first , second ;
@@ -1703,83 +1703,3 @@ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC)
1703
1703
}
1704
1704
zend_compare_symbol_tables (result , Z_OBJPROP_P (o1 ), Z_OBJPROP_P (o2 ) TSRMLS_CC );
1705
1705
}
1706
-
1707
-
1708
- /* returns 0 for non-numeric string
1709
- * returns IS_DOUBLE for floating point string, and assigns the value to *dval (if it's not NULL)
1710
- * returns IS_LONG for integer strings, and assigns the value to *lval (if it's not NULL)
1711
- * returns FLAG_IS_BC if the number might lose accuracy when converted to a double
1712
- */
1713
-
1714
- #if 0
1715
-
1716
- static inline int is_numeric_string (char * str , int length , long * lval , double * dval )
1717
- {
1718
- register char * p = str , * end = str + length ;
1719
- unsigned char had_period = 0 , had_exponent = 0 ;
1720
- char * end_ptr ;
1721
-
1722
- if (!length ) {
1723
- return 0 ;
1724
- }
1725
- switch (* p ) {
1726
- case '-' :
1727
- case '+' :
1728
- while (* ++ p == ' ' ); /* ignore spaces after the sign */
1729
- break ;
1730
- default :
1731
- break ;
1732
- }
1733
- while (p < end ) {
1734
- if (isdigit ((int )(unsigned char )* p )) {
1735
- p ++ ;
1736
- } else if (* p == '.' ) {
1737
- if (had_period ) {
1738
- return 0 ;
1739
- } else {
1740
- had_period = 1 ;
1741
- p ++ ;
1742
- }
1743
- } else if (* p == 'e' || * p == 'E' ) {
1744
- p ++ ;
1745
- if (is_numeric_string (p , length - (int ) (p - str ), NULL , NULL )== IS_LONG ) { /* valid exponent */
1746
- had_exponent = 1 ;
1747
- break ;
1748
- } else {
1749
- return 0 ;
1750
- }
1751
- } else {
1752
- return 0 ;
1753
- }
1754
- }
1755
- errno = 0 ;
1756
- if (had_period || had_exponent ) { /* floating point number */
1757
- double local_dval ;
1758
-
1759
- local_dval = strtod (str , & end_ptr );
1760
- if (errno == ERANGE || end_ptr != str + length ) { /* overflow or bad string */
1761
- return 0 ;
1762
- } else {
1763
- if (dval ) {
1764
- * dval = local_dval ;
1765
- }
1766
- return IS_DOUBLE ;
1767
- }
1768
- } else {
1769
- long local_lval ;
1770
-
1771
- local_lval = strtol (str , & end_ptr , 10 );
1772
- if (errno == ERANGE || end_ptr != str + length ) { /* overflow or bad string */
1773
- return 0 ;
1774
- } else {
1775
- if (lval ) {
1776
- * lval = local_lval ;
1777
- }
1778
- return IS_LONG ;
1779
- }
1780
- }
1781
- }
1782
-
1783
-
1784
-
1785
- #endif
0 commit comments