2007-06-28 16:15 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/rtl/cdpapi.c
! fixed possible GPF and some other problems in HB_TRANSLATE()
* harbour/source/rtl/dateshb.c
* harbour/source/rtl/datesx.c
* harbour/source/common/hbdate.c
* make STOD() exact Clipper compatible
This commit is contained in:
@@ -8,6 +8,15 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2007-06-28 16:15 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/rtl/cdpapi.c
|
||||
! fixed possible GPF and some other problems in HB_TRANSLATE()
|
||||
|
||||
* harbour/source/rtl/dateshb.c
|
||||
* harbour/source/rtl/datesx.c
|
||||
* harbour/source/common/hbdate.c
|
||||
* make STOD() exact Clipper compatible
|
||||
|
||||
2007-06-27 21:02 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/rtl/gttrm/gttrm.c
|
||||
* restore default color on exit
|
||||
|
||||
@@ -166,8 +166,11 @@ HB_EXPORT void hb_dateStrGet( const char * szDate, int * piYear, int * piMonth,
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_dateStrGet(%s, %p, %p, %p)", szDate, piYear, piMonth, piDay));
|
||||
|
||||
#if !defined( HB_C52_STRICT )
|
||||
if( szDate[ 0 ] >= '0' && szDate[ 0 ] <= '9' &&
|
||||
#if defined( HB_C52_STRICT ) || 1
|
||||
if( szDate )
|
||||
#else
|
||||
if( szDate &&
|
||||
szDate[ 0 ] >= '0' && szDate[ 0 ] <= '9' &&
|
||||
szDate[ 1 ] >= '0' && szDate[ 1 ] <= '9' &&
|
||||
szDate[ 2 ] >= '0' && szDate[ 2 ] <= '9' &&
|
||||
szDate[ 3 ] >= '0' && szDate[ 3 ] <= '9' &&
|
||||
@@ -178,14 +181,13 @@ HB_EXPORT void hb_dateStrGet( const char * szDate, int * piYear, int * piMonth,
|
||||
#endif
|
||||
{
|
||||
/* Date string has correct length, so attempt to convert */
|
||||
*piYear = ( ( int ) ( szDate[ 0 ] - '0' ) * 1000 ) +
|
||||
( ( int ) ( szDate[ 1 ] - '0' ) * 100 ) +
|
||||
( ( int ) ( szDate[ 2 ] - '0' ) * 10 ) +
|
||||
( int ) ( szDate[ 3 ] - '0' );
|
||||
*piMonth = ( ( szDate[ 4 ] - '0' ) * 10 ) + ( szDate[ 5 ] - '0' );
|
||||
*piDay = ( ( szDate[ 6 ] - '0' ) * 10 ) + ( szDate[ 7 ] - '0' );
|
||||
*piYear = ( ( ( int ) ( szDate[ 0 ] - '0' ) * 10 +
|
||||
( int ) ( szDate[ 1 ] - '0' ) ) * 10 +
|
||||
( int ) ( szDate[ 2 ] - '0' ) ) * 10 +
|
||||
( int ) ( szDate[ 3 ] - '0' );
|
||||
*piMonth = ( szDate[ 4 ] - '0' ) * 10 + ( szDate[ 5 ] - '0' );
|
||||
*piDay = ( szDate[ 6 ] - '0' ) * 10 + ( szDate[ 7 ] - '0' );
|
||||
}
|
||||
#if !defined( HB_C52_STRICT )
|
||||
else
|
||||
{
|
||||
/* Date string missing or bad length, so force an empty date */
|
||||
@@ -193,7 +195,6 @@ HB_EXPORT void hb_dateStrGet( const char * szDate, int * piYear, int * piMonth,
|
||||
*piMonth =
|
||||
*piDay = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function always closes the date with a zero byte, so it needs a
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapicdp.h"
|
||||
|
||||
#define NUMBER_OF_CHARS 256
|
||||
@@ -993,34 +994,33 @@ HB_FUNC( HB_SETCODEPAGE )
|
||||
{
|
||||
hb_retc( hb_cdp_page->id );
|
||||
|
||||
if( ISCHAR(1) )
|
||||
if( ISCHAR( 1 ) )
|
||||
hb_cdpSelectID( hb_parc( 1 ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_TRANSLATE )
|
||||
{
|
||||
char *szResult;
|
||||
char *szIn = hb_parc(1);
|
||||
char *szIdIn = hb_parc(2);
|
||||
char *szIdOut = hb_parc(3);
|
||||
int ilen;
|
||||
PHB_CODEPAGE cdpIn;
|
||||
PHB_CODEPAGE cdpOut;
|
||||
ULONG ulLen = hb_parclen( 1 );
|
||||
|
||||
if( szIn )
|
||||
if( ulLen )
|
||||
{
|
||||
ilen = hb_parclen(1);
|
||||
cdpIn = ( szIdIn )? hb_cdpFind( szIdIn ):hb_cdp_page;
|
||||
cdpOut = ( szIdOut )? hb_cdpFind( szIdOut ):hb_cdp_page;
|
||||
szResult = (char*) hb_xgrab( ilen + 1 );
|
||||
memcpy( szResult, szIn, ilen );
|
||||
szResult[ ilen ] = '\0';
|
||||
hb_cdpTranslate( szResult, cdpIn, cdpOut );
|
||||
char * szIdIn = hb_parc( 2 );
|
||||
char * szIdOut = hb_parc( 3 );
|
||||
PHB_CODEPAGE cdpIn = szIdIn ? hb_cdpFind( szIdIn ) : hb_cdp_page;
|
||||
PHB_CODEPAGE cdpOut = szIdOut ? hb_cdpFind( szIdOut ) : hb_cdp_page;
|
||||
|
||||
hb_retc_buffer( szResult );
|
||||
if( cdpIn && cdpOut && cdpIn != cdpOut )
|
||||
{
|
||||
char * szResult = ( char * ) hb_xgrab( ulLen + 1 );
|
||||
memcpy( szResult, hb_parc( 1 ), ulLen + 1 );
|
||||
hb_cdpnTranslate( szResult, cdpIn, cdpOut, ulLen );
|
||||
hb_retclen_buffer( szResult, ulLen );
|
||||
}
|
||||
else
|
||||
hb_itemReturn( hb_param( 1, HB_IT_STRING ) );
|
||||
}
|
||||
else
|
||||
hb_retc( "" );
|
||||
hb_retc( NULL );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_CDPLIST )
|
||||
|
||||
@@ -207,7 +207,7 @@ HB_FUNC( HB_STOD )
|
||||
#ifdef HB_FAST_STOD
|
||||
hb_retds( hb_parc( 1 ) );
|
||||
#else
|
||||
hb_retds( hb_parclen( 1 ) == 8 ? hb_parc( 1 ) : " " );
|
||||
hb_retds( hb_parclen( 1 ) >= 7 ? hb_parc( 1 ) : NULL );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ HB_FUNC( STOD )
|
||||
#ifdef HB_FAST_STOD
|
||||
hb_retds( hb_parc( 1 ) );
|
||||
#else
|
||||
hb_retds( hb_parclen( 1 ) >= 8 ? hb_parc( 1 ) : " " );
|
||||
hb_retds( hb_parclen( 1 ) >= 7 ? hb_parc( 1 ) : NULL );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user