Thanks Julien!

I looked for this one for a while!

Fabien

Julien BLACHE a écrit :
tags 369500 + patch
thanks

Hi Cédric,

The attached patch fixes two endianness issues in stellarium:
 - translator.cpp: the resulting UCS4 string was needlessly
   byteswapped
 - hip_star.cpp: the floats read from the data file were not
   byteswapped due to gcc optimizing the macro away (that, or aliasing
   rules kicking in). The patch does the byteswapping the proper way,
   using a union (warning: anonymous unions are not be portable to
   some non-gcc compilers).

With these fixes, stellarium works perfectly fine on PPC.

(btw, please add the locale files to the stellarium-data package ;)

JB.



------------------------------------------------------------------------

--- stellarium-0.8.0.orig/src/translator.cpp
+++ stellarium-0.8.0/src/translator.cpp
@@ -114,7 +114,7 @@
                                        ch |=  (unsigned short)(utf8[++i]&0x3F);
                                }
-#ifdef WORDS_BIGENDIAN
+#if 0 //def WORDS_BIGENDIAN
                unicode[j] = bswap_16(ch);
 #else
                unicode[j] = ch;
--- stellarium-0.8.0.orig/src/hip_star.cpp
+++ stellarium-0.8.0/src/hip_star.cpp
@@ -145,21 +145,23 @@
// Read datas in binary catalog and compute x,y,z;
 // The aliasing bug on some architecture has been fixed by Rainer Canavan on 
26/11/2003
+// Really ? -- JB, 20060607
 int HipStar::read(FILE * catalog)
 {
-       float RA=0, DE=0, xDE, xRA;
-       fread(&xRA,4,1,catalog);
-       LE_TO_CPU_FLOAT(RA, xRA);
+       union { float fl; unsigned int ui; } RA, DE, LY, xRA, xDE, xLY;
- fread(&xDE,4,1,catalog);
-       LE_TO_CPU_FLOAT(DE, xDE);
+       fread(&xRA.ui,4,1,catalog);
+       LE_TO_CPU_INT32(RA.ui, xRA.ui);
+
+       fread(&xDE.ui,4,1,catalog);
+       LE_TO_CPU_INT32(DE.ui, xDE.ui);
// for debug printing
-       //      float rao = RA;
-       //  float deo = DE;
+       //      float rao = RA.fl;
+       //  float deo = DE.fl;
- RA*=M_PI/12.; // Convert from hours to rad
-    DE*=M_PI/180.;    // Convert from deg to rad
+    RA.fl*=M_PI/12.;     // Convert from hours to rad
+    DE.fl*=M_PI/180.;    // Convert from deg to rad
unsigned short int mag, xmag;
        fread(&xmag,2,1,catalog);
@@ -173,7 +175,7 @@
        //      LE_TO_CPU_INT16(type, xtype);
// Calc the Cartesian coord with RA and DE
-    sphe_to_rect(RA,DE,XYZ);
+    sphe_to_rect(RA.fl,DE.fl,XYZ);
XYZ*=RADIUS_STAR; @@ -198,9 +200,9 @@
        setColor(SpType); // Color depending on the spectral type
// distance
-       float LY;
-       fread(&LY,4,1,catalog);
-       LE_TO_CPU_FLOAT(Distance, LY);
+       fread(&xLY.ui,4,1,catalog);
+       LE_TO_CPU_INT32(LY.ui, xLY.ui);
+       Distance = LY.fl;
if (mag==0 && type==0) return 0;

Reply via email to