Author: leo
Date: Mon Oct 17 04:21:10 2005
New Revision: 9497
Modified:
trunk/classes/complex.pmc
trunk/classes/perlnum.pmc
trunk/src/spf_render.c
trunk/src/trace.c
Log:
[perl #37434][PATCH] number formatting
* fix ARM number formatting issue, spotted by Simon Vogl
* fix complex string parsing: "-i" became -0-i
All numeric tests are still passing.
Modified: trunk/classes/complex.pmc
==============================================================================
--- trunk/classes/complex.pmc (original)
+++ trunk/classes/complex.pmc Mon Oct 17 04:21:10 2005
@@ -366,12 +366,8 @@ Returns true if the complex number is no
STRING* get_string () {
STRING *s;
- if (IM(SELF) >= 0)
s = Parrot_sprintf_c(INTERP,
- "%vg+%vgi", RE(SELF), IM(SELF));
- else
- s = Parrot_sprintf_c(INTERP,
- "%vg-%vgi", RE(SELF), -IM(SELF));
+ "%vg%+vgi", RE(SELF), IM(SELF));
return s;
}
Modified: trunk/classes/perlnum.pmc
==============================================================================
--- trunk/classes/perlnum.pmc (original)
+++ trunk/classes/perlnum.pmc Mon Oct 17 04:21:10 2005
@@ -35,12 +35,20 @@ Returns the number as a Parrot string.
*/
STRING* get_string () {
+#if 0
double d = (double) PMC_num_val(SELF);
const char *sign = "-";
if (!signbit(PMC_num_val(SELF)))
sign = "";
d = fabs(d);
return Parrot_sprintf_c(INTERP, "%s" FLOATVAL_FMT, sign, d);
+#else
+ /* XXX signbit isn't portable and as we are calling Parrot_sprintf_c
+ * anyway, we can use the builtin number formatting too
+ * this might still be a problem with -0.0
+ */
+ return Parrot_sprintf_c(INTERP, "%Pf", SELF);
+#endif
}
Modified: trunk/src/spf_render.c
==============================================================================
--- trunk/src/spf_render.c (original)
+++ trunk/src/spf_render.c Mon Oct 17 04:21:10 2005
@@ -658,7 +658,7 @@ Parrot_sprintf_format(Interp *interprete
thefloat = obj->getfloat
(interpreter, info.type, obj);
/* turn -0.0 into 0.0 */
- if( thefloat == 0.0 ) { thefloat = 0.0; }
+ /* WTF if( thefloat == 0.0 ) { thefloat = 0.0; } */
gen_sprintf_call(interpreter, tc, &info, ch);
ts = cstr2pstr(tc);
/* XXX lost precision if %Hg or whatever
Modified: trunk/src/trace.c
==============================================================================
--- trunk/src/trace.c (original)
+++ trunk/src/trace.c Mon Oct 17 04:21:10 2005
@@ -107,7 +107,7 @@ trace_pmc_dump(Interp *interpreter, PMC*
else if (pmc->vtable->base_type == enum_class_PerlUndef
|| pmc->vtable->base_type == enum_class_PerlInt
|| pmc->vtable->base_type == enum_class_PerlNum) {
- PIO_eprintf(interpreter, "%S=PMC(%#p Num:%Pg Int:%Pd)",
+ PIO_eprintf(interpreter, "%S=PMC(%#p Num:%Pf Int:%Pd)",
VTABLE_name(interpreter, pmc), pmc, pmc, pmc);
}
else if (pmc->vtable->base_type == enum_class_RetContinuation