MFZE1 (floats & locale issue)

This commit is contained in:
Ilia Alshanetsky 2002-10-12 21:15:35 +00:00
parent 06455b10bf
commit e842ef9f4b
5 changed files with 30 additions and 0 deletions

View File

@ -156,6 +156,11 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
expr_copy->value.str.val = estrndup("Object", expr_copy->value.str.len);
#endif
break;
case IS_DOUBLE:
*expr_copy = *expr;
zval_copy_ctor(expr_copy);
zend_locale_sprintf_double(expr_copy ZEND_FILE_LINE_CC);
break;
default:
*expr_copy = *expr;
zval_copy_ctor(expr_copy);

View File

@ -180,6 +180,8 @@ void init_executor(TSRMLS_D)
EG(current_execute_data) = NULL;
EG(This) = NULL;
EG(float_separator)[0] = '.';
}

View File

@ -209,6 +209,9 @@ struct _zend_executor_globals {
struct _zend_execute_data *current_execute_data;
/* locale stuff */
char float_separator[1];
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};

View File

@ -1764,3 +1764,21 @@ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC)
result->value.lval = Z_OBJ_HT_P(o1)->compare_objects(o1, o2 TSRMLS_CC);
}
}
ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC)
{
double dval = op->value.dval;
TSRMLS_FETCH();
op->value.str.val = (char *) emalloc_rel(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
sprintf(op->value.str.val, "%.*G", (int) EG(precision), dval);
op->value.str.len = strlen(op->value.str.val);
if (EG(float_separator)[0] != '.') {
char *p = op->value.str.val;
if ((p = strchr(p, '.'))) {
*p = EG(float_separator)[0];
}
}
}

View File

@ -187,6 +187,8 @@ ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC);
ZEND_API int zend_atoi(const char *str, int str_len);
ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC);
#define convert_to_ex_master(ppzv, lower_type, upper_type) \
if ((*ppzv)->type!=IS_##upper_type) { \
if (!(*ppzv)->is_ref) { \