tony2001 Wed Dec 27 19:07:28 2006 UTC Modified files: /php-src/ext/standard math.c Log: NULL is a special value for number_format() meaning "use default separator" http://cvs.php.net/viewvc.cgi/php-src/ext/standard/math.c?r1=1.140&r2=1.141&diff_format=u Index: php-src/ext/standard/math.c diff -u php-src/ext/standard/math.c:1.140 php-src/ext/standard/math.c:1.141 --- php-src/ext/standard/math.c:1.140 Fri Dec 22 21:18:30 2006 +++ php-src/ext/standard/math.c Wed Dec 27 19:07:28 2006 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: math.c,v 1.140 2006/12/22 21:18:30 andrei Exp $ */ +/* $Id: math.c,v 1.141 2006/12/27 19:07:28 tony2001 Exp $ */ #include "php.h" #include "php_math.h" @@ -1018,30 +1018,30 @@ Formats a number with grouped thousands */ PHP_FUNCTION(number_format) { - char *sep1 = NULL, *sep2 = NULL; - int sep1_len, sep2_len; + zval *sep1 = NULL, *sep2 = NULL; double num; int dec = 0; char thousand_sep=',', dec_point='.'; char *tmp; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|ls&s&", &num, &dec, - &sep1, &sep1_len, UG(ascii_conv), - &sep2, &sep2_len, UG(ascii_conv)) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d|lzz", &num, &dec, &sep1, &sep2) == FAILURE) { return; } - if (sep1) { - if (sep1_len >= 1) { - dec_point = sep1[0]; - } else if (sep1_len == 0) { + if (sep1 && Z_TYPE_P(sep1) != IS_NULL) { + convert_to_string_with_converter(sep1, UG(ascii_conv)); + if (Z_STRLEN_P(sep1)) { + dec_point = Z_STRVAL_P(sep1)[0]; + } else { dec_point = 0; } } - if (sep2) { - if (sep2_len >= 1) { - thousand_sep = sep2[0]; - } else if (sep2_len == 0) { + + if (sep2 && Z_TYPE_P(sep2) != IS_NULL) { + convert_to_string_with_converter(sep2, UG(ascii_conv)); + if (Z_STRLEN_P(sep2)) { + thousand_sep = Z_STRVAL_P(sep2)[0]; + } else { thousand_sep = 0; } }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php