cvs: Zend / zend.c zend_operators.c zend_operators.h

From: Date: Sat, 12 Oct 2002 20:35:35 +0000
Subject: cvs: Zend / zend.c zend_operators.c zend_operators.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-505@lists.php.net to get a copy of this message
iliaa Sat Oct 12 16:35:35 2002 EDT Modified files: /Zend zend.c zend_operators.c zend_operators.h Log: Cleanup the float/locale implementation as suggested by Andi. Index: Zend/zend.c diff -u Zend/zend.c:1.160 Zend/zend.c:1.161 --- Zend/zend.c:1.160 Thu Oct 10 18:36:01 2002 +++ Zend/zend.c Sat Oct 12 16:35:34 2002 @@ -124,8 +124,6 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy) { - TSRMLS_FETCH(); - if (expr->type==IS_STRING) { *use_copy = 0; return; @@ -159,15 +157,7 @@ case IS_DOUBLE: *expr_copy = *expr; zval_copy_ctor(expr_copy); - convert_to_string(expr_copy); - - /* locale handling */ - if (EG(float_separator)[0] != '.') { - char *p = expr_copy->value.str.val; - if ((p = strchr(p, '.'))) { - *p = EG(float_separator)[0]; - } - } + zend_locale_sprintf_double(expr_copy ZEND_FILE_LINE_CC); break; default: *expr_copy = *expr; Index: Zend/zend_operators.c diff -u Zend/zend_operators.c:1.127 Zend/zend_operators.c:1.128 --- Zend/zend_operators.c:1.127 Wed Oct 9 10:17:53 2002 +++ Zend/zend_operators.c Sat Oct 12 16:35:34 2002 @@ -1734,3 +1734,21 @@ } zend_compare_symbol_tables(result, Z_OBJPROP_P(o1), Z_OBJPROP_P(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]; + } + } +} \ No newline at end of file Index: Zend/zend_operators.h diff -u Zend/zend_operators.h:1.54 Zend/zend_operators.h:1.55 --- Zend/zend_operators.h:1.54 Wed Oct 9 10:17:53 2002 +++ Zend/zend_operators.h Sat Oct 12 16:35:34 2002 @@ -185,6 +185,8 @@ 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) { \

« previous php.zend-engine.cvs (#505) next »