MFH? --Jani On Fri, 10 Jan 2003, Wez Furlong wrote:
>wez Fri Jan 10 08:32:25 2003 EDT > > Modified files: > /php4/ext/standard math.c > Log: > Fix the number format fix when the number of decimal places is 0. > # Thanks to Edin for his telepathy! > > >Index: php4/ext/standard/math.c >diff -u php4/ext/standard/math.c:1.100 php4/ext/standard/math.c:1.101 >--- php4/ext/standard/math.c:1.100 Thu Jan 9 10:44:49 2003 >+++ php4/ext/standard/math.c Fri Jan 10 08:32:24 2003 >@@ -19,7 +19,7 @@ > +----------------------------------------------------------------------+ > */ > >-/* $Id: math.c,v 1.100 2003/01/09 15:44:49 wez Exp $ */ >+/* $Id: math.c,v 1.101 2003/01/10 13:32:24 wez Exp $ */ > > #include "php.h" > #include "php_math.h" >@@ -1014,7 +1014,11 @@ > integral += integral / 3; > } > >- reslen = integral + 1 + dec; >+ reslen = integral; >+ >+ if (dec) { >+ reslen += 1 + dec; >+ } > > /* add a byte for minus sign */ > if (is_negative) { >@@ -1034,21 +1038,24 @@ > int topad = declen > 0 ? dec - declen : 0; > > /* pad with '0's */ >+ > while (topad--) { > *t-- = '0'; > } >- >- /* now copy the chars after the point */ >- memcpy(t - declen + 1, dp + 1, declen); > >- t -= declen; >- s -= declen; >+ if (dp) { >+ /* now copy the chars after the point */ >+ memcpy(t - declen + 1, dp + 1, declen); >+ >+ t -= declen; >+ s -= declen; >+ } > > /* add decimal point */ > *t-- = dec_point; > s--; > } >- >+ > /* copy the numbers before the decimal place, adding thousand > * separator every three digits */ > while(s >= tmpbuf) { >@@ -1064,7 +1071,7 @@ > } > > efree(tmpbuf); >- >+ > return resbuf; > } > > > > > -- <- For Sale! -> -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php