[svn:parrot] r36205 - trunk/src/packfile

rurban at svn.parrot.org rurban at svn.parrot.org
Sat Jan 31 17:40:22 UTC 2009


Author: rurban
Date: Sat Jan 31 17:40:21 2009
New Revision: 36205
URL: https://trac.parrot.org/parrot/changeset/36205

Log:
Fix the failing t/native_pbc/number.t tests in TT #254.
The pf->header>floatval logic was wrong. only floattype 1 = 12 byte

Fixes the pf_item floatval reader if a conversion is requested, 
and floatval is a normal IEEE-754 8 byte double.

The bug was a wrong advance of 12 byte on 
  (NUMVAL_SIZE == 8 && ! pf->header->floattype)

Modified:
   trunk/src/packfile/pf_items.c

Modified: trunk/src/packfile/pf_items.c
==============================================================================
--- trunk/src/packfile/pf_items.c	Sat Jan 31 16:40:53 2009	(r36204)
+++ trunk/src/packfile/pf_items.c	Sat Jan 31 17:40:21 2009	(r36205)
@@ -123,6 +123,8 @@
 /*
  * low level FLOATVAL fetch and convert functions
  *
+ * Floattype 0 = IEEE-754 8 byte double
+ * Floattype 1 = x86 little endian 12 byte long double
  *
  */
 
@@ -130,7 +132,7 @@
 
 =item C<static void cvt_num12_num8>
 
-Converts i386 LE 12-byte long double to IEEE 754 8 byte double
+Converts i386 LE 12-byte long double to IEEE 754 8 byte double.
 
 =cut
 
@@ -618,15 +620,22 @@
 #if TRACE_PACKFILE
     Parrot_io_eprintf(NULL, "PF_fetch_number: Byteordering..\n");
 #endif
-    /* Here is where the size transforms get messy */
-    if (NUMVAL_SIZE == 8 && ! pf->header->floattype) {
+    /* Here is where the size transforms get messy.
+       Floattype 0 = IEEE-754 8 byte double
+       Floattype 1 = x86 little endian 12 byte long double
+    */
+    if (NUMVAL_SIZE == 8 && pf->header->floattype) {
+        (pf->fetch_nv)((unsigned char *)&d, (const unsigned char *) *stream);
+        f = d;
+    }
+    else {
         (pf->fetch_nv)((unsigned char *)&f, (const unsigned char *) *stream);
+    }
+    if (pf->header->floattype) {
         *((const unsigned char **) (stream)) += 12;
     }
     else {
-        (pf->fetch_nv)((unsigned char *)&d, (const unsigned char *) *stream);
         *((const unsigned char **) (stream)) += 8;
-        f = d;
     }
     return f;
 }


More information about the parrot-commits mailing list