[PATCH] fix KJS crash on some more strict platforms

Friedrich W. H. Kossebau Friedrich.W.H at Kossebau.de
Thu Dec 18 20:43:50 GMT 2003


Am Mittwoch, 17. Dezember 2003 22:37 schrieb Helge Deller:
> On Wednesday 17 December 2003 11:32, Harri Porten wrote:
> > I'm fine with any of the proposed (and proven to work;) solutions. Apart
> > from the STL functions.
>
> First of all thanks for all the feedback I got regarding my last patch here
> on the list ! I tried to find the cleanest solution and attached is now a
> shiny new patch proposal.
> It's clean, compiler- and platform independent (it uses an union) and
> was tested by me on i686/SuSE9 & HP-PARISC/Debian.
>
> It would be nice if someone gives his ok on this one.
>
> Helge

So something like this (in khexedit) is to be doomed, too?

    QString buf;
    void *P8Bit, *P16Bit, *P32Bit, *P64Bit;
    unsigned char Data[8];
    if(
#ifdef WORDS_BIGENDIAN
        !
#endif
         mCheckIntelFormat->isChecked() )
    {
      // take it as it is
      memcpy( Data, state.data, 8 );
      P8Bit = P16Bit = P32Bit = P64Bit = Data;
    }
    else
    {
      // reverse order
      for( int i=0,j=7; i<8; ++i,--j )
        Data[i] = state.data[j];

      P8Bit =  &Data[7];
      P16Bit = &Data[6];
      P32Bit = &Data[4];
      P64Bit = Data;
    }
  ...
    // float 32 bit
    buf.sprintf( "%E", *(float*)P32Bit );
    mText2[2]->setText( buf );
    // float 64 bit
    buf.sprintf( "%E", *(double*)P64Bit );
    mText2[3]->setText( buf );

So should I use a kjs_double_t typedef there, too?

Friedrich




More information about the kde-core-devel mailing list