From 9053ff561c516ac2a85422d0db5742279bb774a5 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 16 Oct 2012 10:32:57 +0000 Subject: [PATCH] 2012-10-16 12:29 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnf/bitclr.prg * contrib/hbnf/bitset.prg * contrib/hbnf/byt2bit.prg * contrib/hbnf/byt2hex.prg * contrib/hbnf/byteand.prg * contrib/hbnf/bytenot.prg * contrib/hbnf/byteor.prg * contrib/hbnf/bytexor.prg * contrib/hbnf/ftint86.ch * contrib/hbnf/isbit.prg * contrib/hbnf/isbiton.prg * contrib/hbnf/tempfile.prg % reworked bit functions to use HB_BIT*() * contrib/hbnf/workdays.prg * deleted unnecessary parantheses --- harbour/ChangeLog | 18 ++++++++++++++++++ harbour/contrib/hbnf/bitclr.prg | 13 ++----------- harbour/contrib/hbnf/bitset.prg | 15 +++------------ harbour/contrib/hbnf/byt2bit.prg | 12 ++++++------ harbour/contrib/hbnf/byt2hex.prg | 11 ++--------- harbour/contrib/hbnf/byteand.prg | 13 ++----------- harbour/contrib/hbnf/bytenot.prg | 13 ++----------- harbour/contrib/hbnf/byteor.prg | 13 ++----------- harbour/contrib/hbnf/bytexor.prg | 15 ++------------- harbour/contrib/hbnf/ftint86.ch | 2 +- harbour/contrib/hbnf/isbit.prg | 12 ++---------- harbour/contrib/hbnf/isbiton.prg | 8 +------- harbour/contrib/hbnf/tempfile.prg | 2 +- harbour/contrib/hbnf/workdays.prg | 2 +- 14 files changed, 45 insertions(+), 104 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 45dce055f6..1d7a097919 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,24 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-16 12:29 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbnf/bitclr.prg + * contrib/hbnf/bitset.prg + * contrib/hbnf/byt2bit.prg + * contrib/hbnf/byt2hex.prg + * contrib/hbnf/byteand.prg + * contrib/hbnf/bytenot.prg + * contrib/hbnf/byteor.prg + * contrib/hbnf/bytexor.prg + * contrib/hbnf/ftint86.ch + * contrib/hbnf/isbit.prg + * contrib/hbnf/isbiton.prg + * contrib/hbnf/tempfile.prg + % reworked bit functions to use HB_BIT*() + + * contrib/hbnf/workdays.prg + * deleted unnecessary parantheses + 2012-10-16 11:12 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnf/acctmnth.prg * contrib/hbnf/acctqtr.prg diff --git a/harbour/contrib/hbnf/bitclr.prg b/harbour/contrib/hbnf/bitclr.prg index 10ab5bd0d2..789a623d12 100644 --- a/harbour/contrib/hbnf/bitclr.prg +++ b/harbour/contrib/hbnf/bitclr.prg @@ -25,17 +25,8 @@ FUNCTION FT_BITCLR( cInbyte, nBitpos ) - LOCAL cByte - IF HB_ISSTRING( cInbyte ) .AND. HB_ISNUMERIC( nBitpos ) - IF nBitPos > 7 .OR. nBitPos < 0 .OR. nBitPos != Int( nBitPos ) - cByte := NIL - ELSE - cByte := iif( ! FT_ISBIT( cInByte, nBitpos ), cInByte, ; - hb_BChar( hb_BCode( cInByte ) - ( 2 ^ nBitpos ) ) ) - ENDIF - ELSE - cByte := NIL + RETURN hb_BChar( hb_bitReset( hb_BCode( cInbyte ), nBitpos ) ) ENDIF - RETURN cByte + RETURN NIL diff --git a/harbour/contrib/hbnf/bitset.prg b/harbour/contrib/hbnf/bitset.prg index bf61d18674..b1405f0482 100644 --- a/harbour/contrib/hbnf/bitset.prg +++ b/harbour/contrib/hbnf/bitset.prg @@ -23,19 +23,10 @@ * */ -FUNCTION FT_BITSET( cInByte, nBitpos ) - - LOCAL cByte +FUNCTION FT_BITSET( cInbyte, nBitpos ) IF HB_ISSTRING( cInbyte ) .AND. HB_ISNUMERIC( nBitpos ) - IF nBitPos > 7 .OR. nBitPos < 0 .OR. nBitPos != Int( nBitPos ) - cByte := NIL - ELSE - cByte := iif( FT_ISBIT( cInByte, nBitpos ), cInByte, ; - hb_BChar( hb_BCode( cInByte ) + ( 2 ^ nBitpos ) ) ) - ENDIF - ELSE - cByte := NIL + RETURN hb_BChar( hb_bitSet( hb_BCode( cInbyte ), nBitpos ) ) ENDIF - RETURN cByte + RETURN NIL diff --git a/harbour/contrib/hbnf/byt2bit.prg b/harbour/contrib/hbnf/byt2bit.prg index 904e1882d8..f4f0248d0f 100644 --- a/harbour/contrib/hbnf/byt2bit.prg +++ b/harbour/contrib/hbnf/byt2bit.prg @@ -25,15 +25,15 @@ FUNCTION FT_BYT2BIT( cByte ) - LOCAL nCounter, xBitstring + LOCAL nCounter, cBitstring IF HB_ISSTRING( cByte ) - xBitString := "" + cByte := hb_BCode( cByte ) + cBitString := "" FOR nCounter := 7 TO 0 STEP -1 - xBitString += iif( FT_ISBIT( cByte, nCounter ), "1", "0" ) + cBitString += iif( hb_bitTest( cByte, nCounter ), "1", "0" ) NEXT - ELSE - xBitString := NIL + RETURN cBitString ENDIF - RETURN xBitString + RETURN NIL diff --git a/harbour/contrib/hbnf/byt2hex.prg b/harbour/contrib/hbnf/byt2hex.prg index 78a7cc8e4b..4e74f3c760 100644 --- a/harbour/contrib/hbnf/byt2hex.prg +++ b/harbour/contrib/hbnf/byt2hex.prg @@ -25,15 +25,8 @@ FUNCTION FT_BYT2HEX( cByte ) - LOCAL cHexTable := "0123456789ABCDEF" - LOCAL xHexString - IF HB_ISSTRING( cByte ) - xHexString := SubStr( cHexTable, Int( hb_BCode( cByte ) / 16 ) + 1, 1 ) + ; - SubStr( cHexTable, Int( hb_BCode( cByte ) % 16 ) + 1, 1 ) + ; - "h" - ELSE - xHexString := NIL + RETURN hb_StrToHex( Left( cByte, 1 ) ) + "h" ENDIF - RETURN xHexString + RETURN NIL diff --git a/harbour/contrib/hbnf/byteand.prg b/harbour/contrib/hbnf/byteand.prg index 86592be1ad..fd7062ca1c 100644 --- a/harbour/contrib/hbnf/byteand.prg +++ b/harbour/contrib/hbnf/byteand.prg @@ -25,17 +25,8 @@ FUNCTION FT_BYTEAND( cByte1, cByte2 ) - LOCAL nCounter, cNewByte - IF HB_ISSTRING( cByte1 ) .AND. HB_ISSTRING( cByte2 ) - cNewByte := hb_BChar( 0 ) - FOR nCounter := 0 TO 7 // test each bit position - IF FT_ISBIT( cByte1, nCounter ) .AND. FT_ISBIT( cByte2, nCounter ) - cNewByte := FT_BITSET( cNewByte, nCounter ) - ENDIF - NEXT - ELSE - cNewByte := NIL + RETURN hb_BChar( hb_bitAnd( hb_BCode( cByte1 ), hb_BCode( cByte2 ) ) ) ENDIF - RETURN cNewByte + RETURN NIL diff --git a/harbour/contrib/hbnf/bytenot.prg b/harbour/contrib/hbnf/bytenot.prg index 69a21c02ce..0a29831f2e 100644 --- a/harbour/contrib/hbnf/bytenot.prg +++ b/harbour/contrib/hbnf/bytenot.prg @@ -26,17 +26,8 @@ FUNCTION FT_BYTENOT( cByte ) - LOCAL nCounter, cNewByte - IF HB_ISSTRING( cByte ) - cNewByte := hb_BChar( 0 ) - FOR nCounter := 0 TO 7 // test each bit position - IF ! FT_ISBIT( cByte, nCounter ) - cNewByte := FT_BITSET( cNewByte, nCounter ) - ENDIF - NEXT - ELSE - cNewByte := NIL + RETURN hb_BChar( hb_bitNot( hb_BCode( cByte ) ) ) ENDIF - RETURN cNewByte + RETURN NIL diff --git a/harbour/contrib/hbnf/byteor.prg b/harbour/contrib/hbnf/byteor.prg index 6eae6f26e3..119e1da16b 100644 --- a/harbour/contrib/hbnf/byteor.prg +++ b/harbour/contrib/hbnf/byteor.prg @@ -25,17 +25,8 @@ FUNCTION FT_BYTEOR( cByte1, cByte2 ) - LOCAL nCounter, cNewByte - IF HB_ISSTRING( cByte1 ) .AND. HB_ISSTRING( cByte2 ) - cNewByte := hb_BChar( 0 ) - FOR nCounter := 0 TO 7 // test each bit position - IF FT_ISBIT( cByte1, nCounter ) .OR. FT_ISBIT( cByte2, nCounter ) - cNewByte := FT_BITSET( cNewByte, nCounter ) - ENDIF - NEXT - ELSE - cNewByte := NIL + RETURN hb_BChar( hb_bitOr( hb_BCode( cByte1 ), hb_BCode( cByte2 ) ) ) ENDIF - RETURN cNewByte + RETURN NIL diff --git a/harbour/contrib/hbnf/bytexor.prg b/harbour/contrib/hbnf/bytexor.prg index 7fbb83d9d5..c38c6e51ae 100644 --- a/harbour/contrib/hbnf/bytexor.prg +++ b/harbour/contrib/hbnf/bytexor.prg @@ -28,19 +28,8 @@ FUNCTION FT_BYTEXOR( cByte1, cByte2 ) - LOCAL nCounter, cNewByte - IF HB_ISSTRING( cByte1 ) .AND. HB_ISSTRING( cByte2 ) - cNewByte := hb_BChar( 0 ) - FOR nCounter := 0 TO 7 // test each bit position - IF FT_ISBIT( cByte1, nCounter ) .OR. FT_ISBIT( cByte2, nCounter ) - IF ! ( FT_ISBIT( cByte1, nCounter ) .AND. FT_ISBIT( cByte2, nCounter ) ) - cNewByte := FT_BITSET( cNewByte, nCounter ) - ENDIF - ENDIF - NEXT - ELSE - cNewByte := NIL + RETURN hb_BChar( hb_bitXor( hb_BCode( cByte1 ), hb_BCode( cByte2 ) ) ) ENDIF - RETURN cNewByte + RETURN NIL diff --git a/harbour/contrib/hbnf/ftint86.ch b/harbour/contrib/hbnf/ftint86.ch index 2840c44846..bffbbb6e6b 100644 --- a/harbour/contrib/hbnf/ftint86.ch +++ b/harbour/contrib/hbnf/ftint86.ch @@ -71,6 +71,6 @@ #translate REG_ES => .F. #translate highbyte( ) => ( int( iif( () \< 0, 65536 + (), () ) / 256 ) ) #translate lowbyte( ) => ( iif( () \< 0, 65536 + (), () ) % 256 ) -#translate carrySet( ) => ( ft_isbiton( ( ), FLAG_CARRY ) ) +#translate carrySet( ) => ( hb_bitTest( , FLAG_CARRY ) ) #endif // __FTINT86_CH__ diff --git a/harbour/contrib/hbnf/isbit.prg b/harbour/contrib/hbnf/isbit.prg index 87d65da81c..0b0bf388de 100644 --- a/harbour/contrib/hbnf/isbit.prg +++ b/harbour/contrib/hbnf/isbit.prg @@ -25,16 +25,8 @@ FUNCTION FT_ISBIT( cInbyte, nBitPos ) - LOCAL lBitStat - IF HB_ISSTRING( cInbyte ) .AND. HB_ISNUMERIC( nBitPos ) - IF nBitPos > 7 .OR. nBitPos < 0 .OR. nBitPos != Int( nBitPos ) - lBitStat := NIL - ELSE - lBitStat := Int( ( ( hb_BCode( cInByte ) * ( 2 ^ ( 7 - nBitPos ) ) ) % 256 ) / 128 ) == 1 - ENDIF - ELSE - lBitStat := NIL + RETURN hb_bitTest( hb_BCode( cInbyte ), nBitpos ) ENDIF - RETURN lBitStat + RETURN NIL diff --git a/harbour/contrib/hbnf/isbiton.prg b/harbour/contrib/hbnf/isbiton.prg index 69bcad7648..9412844b30 100644 --- a/harbour/contrib/hbnf/isbiton.prg +++ b/harbour/contrib/hbnf/isbiton.prg @@ -27,10 +27,4 @@ */ FUNCTION FT_ISBITON( nWord, nBit ) - - nWord := iif( nWord < 0, nWord + 65536, nWord ) - nWord := Int( nWord * ( 2 ^ ( 15 - nBit ) ) ) - nWord := Int( nWord % 65536 ) - nWord := Int( nWord / 32768 ) - - RETURN ( nWord == 1 ) + RETURN hb_bitTest( nWord, nBit ) diff --git a/harbour/contrib/hbnf/tempfile.prg b/harbour/contrib/hbnf/tempfile.prg index c2e5416769..482cce0fe7 100644 --- a/harbour/contrib/hbnf/tempfile.prg +++ b/harbour/contrib/hbnf/tempfile.prg @@ -79,7 +79,7 @@ FUNCTION FT_TEMPFIL( cPath, lHide, nHandle ) * sitting in AX that needs to be closed. */ - IF ! ft_isBitOn( aRegs[ 3 ], FLAG_CARRY ) + IF ! hb_bitTest( aRegs[ 3 ], FLAG_CARRY ) IF PCount() >= 3 nHandle := aRegs[ 1 ] ELSE diff --git a/harbour/contrib/hbnf/workdays.prg b/harbour/contrib/hbnf/workdays.prg index 97ecc3f503..c8c8739600 100644 --- a/harbour/contrib/hbnf/workdays.prg +++ b/harbour/contrib/hbnf/workdays.prg @@ -58,7 +58,7 @@ FUNCTION FT_WorkDays( dStart, dStop ) nWorkDays := Int( nDays / 7 ) * 5 + nAdjust - ELSEIF ( DOW( dStart ) != 1 .AND. DOW( dStart ) != 7 ) + ELSEIF DOW( dStart ) != 1 .AND. DOW( dStart ) != 7 nWorkDays := 1