Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: php/php-src
base: master
...
head fork: Topface/php-src
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 15 additions and 4 deletions.
  1. +15 −4 ext/standard/math.c
View
19 ext/standard/math.c
@@ -1094,7 +1094,18 @@ PHP_FUNCTION(base_convert)
*/
PHPAPI char *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep)
{
- return _php_math_number_format_ex(d, dec, &dec_point, 1, &thousand_sep, 1);
+ size_t size_dec_point = 0, size_thousand_sep = 0;
+
+ if(dec_point) {
+ size_dec_point = 1;
+ }
+
+ if(thousand_sep) {
+ size_thousand_sep = 1;
+ }
+
+ return _php_math_number_format_ex(d, dec, &dec_point, size_dec_point, &thousand_sep, size_thousand_sep);
+
}
static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
@@ -1143,7 +1154,7 @@ static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
}
/* allow for thousand separators */
- if (thousand_sep) {
+ if (thousand_sep_len) {
integral += thousand_sep_len * ((integral-1) / 3);
}
@@ -1152,7 +1163,7 @@ static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
if (dec) {
reslen += dec;
- if (dec_point) {
+ if (dec_point_len) {
reslen += dec_point_len;
}
}
@@ -1188,7 +1199,7 @@ static char *_php_math_number_format_ex_len(double d, int dec, char *dec_point,
}
/* add decimal point */
- if (dec_point) {
+ if (dec_point_len) {
t -= dec_point_len;
memcpy(t + 1, dec_point, dec_point_len);
}

No commit comments for this range

Something went wrong with that request. Please try again.