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
This commit is contained in:
Viktor Szakats
2012-10-17 12:42:37 +00:00
parent 2224e491b1
commit 955f5d676c
5 changed files with 37 additions and 31 deletions

View File

@@ -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

View File

@@ -36,8 +36,8 @@
HB_FUNC( FT_CAPLOCK )
{
int iState = 0, iNewState;
HB_GT_INFO gtInfo;
int iState = 0;
HB_GT_INFO gtInfo;
memset( &gtInfo, 0, sizeof( gtInfo ) );
hb_gtInfo( HB_GTI_KBDSHIFTS, &gtInfo );
@@ -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, &gtInfo );
}

View File

@@ -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, &registers, &registers );
}
#endif

View File

@@ -33,8 +33,8 @@
HB_FUNC( FT_NUMLOCK )
{
int iState = 0, iNewState;
HB_GT_INFO gtInfo;
int iState = 0;
HB_GT_INFO gtInfo;
memset( &gtInfo, 0, sizeof( gtInfo ) );
hb_gtInfo( HB_GTI_KBDSHIFTS, &gtInfo );
@@ -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, &gtInfo );
}

View File

@@ -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