From 955f5d676cd78285f0752f3c3312e7cfd565e899 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 17 Oct 2012 12:42:37 +0000 Subject: [PATCH] 2012-10-17 14:41 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnf/caplock.c * contrib/hbnf/kspeed.c * contrib/hbnf/numlock.c * contrib/hbnf/proper.c * code cleanups --- harbour/ChangeLog | 7 +++++++ harbour/contrib/hbnf/caplock.c | 9 +++++---- harbour/contrib/hbnf/kspeed.c | 21 +++++++++++---------- harbour/contrib/hbnf/numlock.c | 9 +++++---- harbour/contrib/hbnf/proper.c | 22 +++++++++------------- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a7d9416105..99edb27de9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,13 @@ The license applies to all entries newer than 2009-04-28. */ +2012-10-17 14:41 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbnf/caplock.c + * contrib/hbnf/kspeed.c + * contrib/hbnf/numlock.c + * contrib/hbnf/proper.c + * code cleanups + 2012-10-17 12:45 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbnf/acctmnth.prg * contrib/hbnf/acctyear.prg diff --git a/harbour/contrib/hbnf/caplock.c b/harbour/contrib/hbnf/caplock.c index 2c11e04db8..6c71f626c0 100644 --- a/harbour/contrib/hbnf/caplock.c +++ b/harbour/contrib/hbnf/caplock.c @@ -36,8 +36,8 @@ HB_FUNC( FT_CAPLOCK ) { - int iState = 0, iNewState; - HB_GT_INFO gtInfo; + int iState = 0; + HB_GT_INFO gtInfo; memset( >Info, 0, sizeof( gtInfo ) ); hb_gtInfo( HB_GTI_KBDSHIFTS, >Info ); @@ -50,8 +50,9 @@ HB_FUNC( FT_CAPLOCK ) if( HB_ISLOG( 1 ) ) { - iNewState = hb_parl( 1 ) ? ( iState | HB_GTI_KBD_CAPSLOCK ) : - ( iState & ~HB_GTI_KBD_CAPSLOCK ); + int iNewState = hb_parl( 1 ) ? + ( iState | HB_GTI_KBD_CAPSLOCK ) : + ( iState & ~HB_GTI_KBD_CAPSLOCK ); gtInfo.pNewVal = hb_itemPutNI( gtInfo.pNewVal, iNewState ); hb_gtInfo( HB_GTI_KBDSHIFTS, >Info ); } diff --git a/harbour/contrib/hbnf/kspeed.c b/harbour/contrib/hbnf/kspeed.c index f832592867..e4048f76a0 100644 --- a/harbour/contrib/hbnf/kspeed.c +++ b/harbour/contrib/hbnf/kspeed.c @@ -33,29 +33,30 @@ HB_FUNC( FT_SETRATE ) { #if defined( HB_OS_DOS ) { - union REGS registers; - int tempo = 0, nrepete = 0; + union REGS registers; + int iSpeed = 0; + int iRepeat = 0; switch( hb_pcount() ) { case 0: - tempo = 0; - nrepete = 0; + iSpeed = 0; + iRepeat = 0; break; case 1: - tempo = hb_parni( 1 ); - nrepete = 0; + iSpeed = hb_parni( 1 ); + iRepeat = 0; break; case 2: - tempo = hb_parni( 1 ); - nrepete = hb_parni( 2 ); + iSpeed = hb_parni( 1 ); + iRepeat = hb_parni( 2 ); break; } registers.h.ah = 0x03; registers.h.al = 0x05; - registers.h.bh = tempo; - registers.h.bl = nrepete; + registers.h.bh = iSpeed; + registers.h.bl = iRepeat; HB_DOS_INT86( 0x16, ®isters, ®isters ); } #endif diff --git a/harbour/contrib/hbnf/numlock.c b/harbour/contrib/hbnf/numlock.c index d6bb7207d5..451e9b2699 100644 --- a/harbour/contrib/hbnf/numlock.c +++ b/harbour/contrib/hbnf/numlock.c @@ -33,8 +33,8 @@ HB_FUNC( FT_NUMLOCK ) { - int iState = 0, iNewState; - HB_GT_INFO gtInfo; + int iState = 0; + HB_GT_INFO gtInfo; memset( >Info, 0, sizeof( gtInfo ) ); hb_gtInfo( HB_GTI_KBDSHIFTS, >Info ); @@ -47,8 +47,9 @@ HB_FUNC( FT_NUMLOCK ) if( HB_ISLOG( 1 ) ) { - iNewState = hb_parl( 1 ) ? ( iState | HB_GTI_KBD_NUMLOCK ) : - ( iState & ~HB_GTI_KBD_NUMLOCK ); + int iNewState = hb_parl( 1 ) ? + ( iState | HB_GTI_KBD_NUMLOCK ) : + ( iState & ~HB_GTI_KBD_NUMLOCK ); gtInfo.pNewVal = hb_itemPutNI( gtInfo.pNewVal, iNewState ); hb_gtInfo( HB_GTI_KBDSHIFTS, >Info ); } diff --git a/harbour/contrib/hbnf/proper.c b/harbour/contrib/hbnf/proper.c index bc8bca0f14..f52597ecc0 100644 --- a/harbour/contrib/hbnf/proper.c +++ b/harbour/contrib/hbnf/proper.c @@ -60,14 +60,13 @@ static HB_BOOL _ftIsAlpha( char c ) HB_FUNC( FT_PROPER ) { - HB_ISIZ iLen = hb_parclen( 1 ); - const char * cStr; - char * cDst = NULL; - HB_ISIZ i; /*, iPos = 0; */ - HB_BOOL fCap = HB_TRUE; + HB_ISIZ iLen = hb_parclen( 1 ); + const char * cStr = hb_parc( 1 ); + char * cDst = NULL; + HB_ISIZ i; + HB_BOOL fCap = HB_TRUE; hb_storc( NULL, 1 ); - cStr = hb_parc( 1 ); for( i = 0; i < iLen; i++ ) { @@ -83,24 +82,21 @@ HB_FUNC( FT_PROPER ) else cDst[ i ] = _ftToLower( cDst[ i ] ); } - fCap = ( cStr[ i ] == ' ' || cStr[ i ] == '-' || cStr[ i ] == 0x27 ); + fCap = ( cStr[ i ] == ' ' || cStr[ i ] == '-' || cStr[ i ] == '\'' ); } /* Find "Mc" */ if( cDst ) { for( i = 0; i < iLen - 2; i++ ) + { if( cStr[ i ] == 'M' && cStr[ i + 1 ] == 'c' ) { cDst[ i + 2 ] = _ftToUpper( cDst[ i + 2 ] ); } + } } - /* // If "Mc" was found, Cap next letter if Alpha - if( iPos > 1 ) - if( iPos < iLen ) - if( ! _ftIsUpper( cStr[ iPos ] ) ) - cStr[ iPos ] = _ftToUpper( cStr[ iPos ] ); - */ + if( cDst ) hb_retclen_buffer( cDst, iLen ); else