]> granicus.if.org Git - php/commitdiff
MFB: serialize() should use '.' as decimal point irrespectively to locale
authorAntony Dovgal <tony2001@php.net>
Tue, 19 Dec 2006 12:44:26 +0000 (12:44 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 19 Dec 2006 12:44:26 +0000 (12:44 +0000)
ext/standard/var.c

index 04fb08d448202e2393299d84ad72cff1e1e153ec..d9fd977820d10496f5123f97e9c8ede5543dc458 100644 (file)
@@ -942,10 +942,12 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var
 
                case IS_DOUBLE: {
                                char *s;
-                               ulong slen;
 
-                               slen = spprintf(&s, 0, "d:%.*G;", (int) PG(serialize_precision), Z_DVAL_P(struc));
-                               smart_str_appendl(buf, s, slen);
+                               smart_str_appendl(buf, "d:", 2);
+                               s = (char *) emalloc(MAX_LENGTH_OF_DOUBLE + PG(serialize_precision) + 1);
+                               php_gcvt(Z_DVAL_P(struc), PG(serialize_precision), '.', 'E', s);
+                               smart_str_appends(buf, s);
+                               smart_str_appendc(buf, ';');
                                efree(s);
                                return;
                        }