[Kstars-devel] KDE/kdeedu/kstars/kstars/skycomponents
Akarsh Simha
akarshsimha at gmail.com
Mon Jun 8 11:50:34 CEST 2009
SVN commit 978818 by asimha:
Swapping bytes for cross-architecture compatibility.
Although we did have byte-swap calls in most places, they were not
present at some crucial places. [While reading the header of the data
files]
This should hopefully ease the situation, if not fix bug
195414. However, this is still untested and testing on big endian
machines is still required.
CCMAIL: kstars-devel at kde.org
CCBUG: 195414
M +10 -0 deepstarcomponent.cpp
M +7 -0 starcomponent.cpp
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/deepstarcomponent.cpp #978817:978818
@@ -74,10 +74,16 @@
qint16 faintmag;
quint8 htm_level;
quint16 t_MSpT;
+
fread( &faintmag, 2, 1, dataFile );
+ if( starReader.getByteSwap() )
+ bswap_16( faintmag );
fread( &htm_level, 1, 1, dataFile );
fread( &t_MSpT, 2, 1, dataFile ); // Unused
+ if( starReader.getByteSwap() )
+ bswap_16( faintmag );
+
// TODO: Read the multiplying factor from the dataFile
m_FaintMagnitude = faintmag / 100.0;
@@ -329,6 +335,8 @@
qint16 faintmag;
quint8 htm_level;
fread( &faintmag, 2, 1, starReader.getFileHandle() );
+ if( starReader.getByteSwap() )
+ bswap_16( faintmag );
if( starReader.guessRecordSize() == 16 )
m_FaintMagnitude = faintmag / 1000.0;
else
@@ -344,6 +352,8 @@
}
meshLevel = htm_level;
fread( &MSpT, 2, 1, starReader.getFileHandle() );
+ if( starReader.getByteSwap() )
+ bswap_16( MSpT );
fileOpened = true;
kDebug() << " Sky Mesh Size: " << m_skyMesh->size();
for (long int i = 0; i < m_skyMesh->size(); i++) {
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #978817:978818
@@ -457,9 +457,14 @@
quint16 t_MSpT;
fread( &faintmag, 2, 1, dataFile );
+ if( swapBytes )
+ bswap_16( faintmag );
fread( &htm_level, 1, 1, dataFile );
fread( &t_MSpT, 2, 1, dataFile ); // Unused
+ if( swapBytes )
+ bswap_16( faintmag );
+
if( faintmag / 100.0 > m_FaintMagnitude )
m_FaintMagnitude = faintmag / 100.0;
@@ -572,6 +577,8 @@
return 0;
FILE *dataFile;
KDE_fseek( hdidxFile, (HDnum - 1) * 4, SEEK_SET );
+ // TODO: Offsets need to be byteswapped if this is a big endian machine.
+ // This means that the Henry Draper Index needs a endianness indicator.
fread( &offset, 4, 1, hdidxFile );
if( offset <= 0 )
return 0;
More information about the Kstars-devel
mailing list