From 01162d920037a6d1b4597ed653205b624d4300a0 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 16 Jun 2009 11:27:55 +0000 Subject: [PATCH] 2009-06-16 13:37 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbct/token1.c % use explicit constant value instead of HB_MKULONG() macro * harbour/source/compiler/cmdcheck.c ! fixed few typos in bit manipulation used to calculate result in PackDateTime() function by rewriting it to use bitfield union. --- harbour/ChangeLog | 8 ++++++ harbour/contrib/hbct/token1.c | 8 +++--- harbour/source/compiler/cmdcheck.c | 43 +++++++++++++++--------------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9004eb7b4f..8fdb2087c6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-16 13:37 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbct/token1.c + % use explicit constant value instead of HB_MKULONG() macro + + * harbour/source/compiler/cmdcheck.c + ! fixed few typos in bit manipulation used to calculate result in + PackDateTime() function by rewriting it to use bitfield union. + 2009-06-16 09:13 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * INSTALL + Two optional envvars got some super extra clarification. diff --git a/harbour/contrib/hbct/token1.c b/harbour/contrib/hbct/token1.c index e767e1041e..63a0c58650 100644 --- a/harbour/contrib/hbct/token1.c +++ b/harbour/contrib/hbct/token1.c @@ -278,9 +278,9 @@ static void do_token1( int iSwitch ) /* should we find the last token, but string ends with tokenizer, i.e. pc points to the last character at the moment ? -> break here ! */ - if( ulTokenCounter == HB_MKULONG( 255, 255, 255, 255 ) ) + if( ulTokenCounter == 0xFFFFFFFFUL ) { - if( ulSkip == HB_MKULONG( 255, 255, 255, 255 ) ) + if( ulSkip == 0xFFFFFFFFUL ) { char *t; BOOL bLast = TRUE; @@ -307,7 +307,7 @@ static void do_token1( int iSwitch ) { char cRet; - if( ( ulTokenCounter == HB_MKULONG( 255, 255, 255, 255 ) ) || + if( ( ulTokenCounter == 0xFFFFFFFFUL ) || ( ulToken == ulTokenCounter ) ) hb_retclen( pcSubStr, pc - pcSubStr ); else @@ -330,7 +330,7 @@ static void do_token1( int iSwitch ) break; case DO_TOKEN1_ATTOKEN: - if( ( ulTokenCounter == HB_MKULONG( 255, 255, 255, 255 ) ) || + if( ( ulTokenCounter == 0xFFFFFFFFUL ) || ( ulToken == ulTokenCounter ) ) hb_retnl( pcSubStr - pcString + 1 ); else diff --git a/harbour/source/compiler/cmdcheck.c b/harbour/source/compiler/cmdcheck.c index e408eb6fea..3cf6910af5 100644 --- a/harbour/source/compiler/cmdcheck.c +++ b/harbour/source/compiler/cmdcheck.c @@ -72,31 +72,32 @@ static ULONG PackDateTime( void ) { - int iYear, iMonth, iDay, iHour, iMinute, iSeconds, iMillisec; - BYTE szString[4]; - BYTE nValue; + union + { + struct + { + UINT32 second : 6; /* bits: 0 - 5 */ + UINT32 minute : 6; /* bits: 6 - 11 */ + UINT32 hour : 5; /* bits: 12 - 16 */ + UINT32 day : 5; /* bits: 16 - 21 */ + UINT32 month : 4; /* bits: 22 - 25 */ + UINT32 year : 6; /* bits: 26 - 31 */ + } ts; + UINT32 val; + } u; + int iYear, iMonth, iDay, iHour, iMinute, iSecond, iMillisec; hb_timeStampGetLocal( &iYear, &iMonth, &iDay, - &iHour, &iMinute, &iSeconds, &iMillisec ); + &iHour, &iMinute, &iSecond, &iMillisec ); - nValue = ( BYTE ) ( ( iYear - 1980 ) & ( 2 ^ 6 ) ); /* 6 bits */ - szString[0] = nValue << 2; - nValue = ( BYTE ) ( iMonth ); /* 4 bits */ - szString[0] |= nValue >> 2; - szString[1] = nValue << 6; - nValue = ( BYTE ) ( iDay ); /* 5 bits */ - szString[1] |= nValue << 1; + u.ts.year = iYear - 1980; + u.ts.month = iMonth; + u.ts.day = iDay; + u.ts.hour = iHour; + u.ts.minute = iMinute; + u.ts.second = iSecond; - nValue = ( BYTE ) iHour; /* 5 bits */ - szString[1] = nValue >> 4; - szString[2] = nValue << 4; - nValue = ( BYTE ) iMinute; /* 6 bits */ - szString[2] |= nValue >> 2; - szString[3] = nValue << 6; - nValue = ( BYTE ) iSeconds; /* 6 bits */ - szString[3] |= nValue; - - return HB_MKLONG( szString[3], szString[2], szString[1], szString[0] ); + return u.val; } static void hb_notSupportedInfo( HB_COMP_DECL, const char *szSwitch )