19991030-03:24 GMT+1 Victor Szel <info@szelvesz.hu>

This commit is contained in:
Viktor Szakats
1999-10-30 01:43:23 +00:00
parent e893a0b6f6
commit db8899fffa
6 changed files with 47 additions and 56 deletions

View File

@@ -1,3 +1,17 @@
19991030-03:24 GMT+1 Victor Szel <info@szelvesz.hu>
* tests/rtl_test.prg
+ Four new Pad*() tests added.
* source/rtl/samples.c
* Small optimalizations, formatting corrections.
* source/rtl/dynsym.c
% hb_strgreater() replaced with standard ANSI C function strcmp(), it's
now a bit faster.
* source/rtl/strings.c
include/extend.h
! SUBSTR() bug fix in handling the error when the third parameter was not
a string. (reported by Andi Jahja)
- hb_strgreater() removed since it was same as strcmp()
19991028-22:30 EDT David G. Holm <dholm@jsd-llc.com>
* source/rtl/inkey.c

View File

@@ -328,13 +328,8 @@ extern PHB_ITEM hb_arrayClone( PHB_ITEM pArray );
/* string management */
#define HB_STRGREATER_EQUAL 0
#define HB_STRGREATER_LEFT 1
#define HB_STRGREATER_RIGHT 2
extern int hb_stricmp( const char * s1, const char * s2 );
extern int hb_strnicmp( const char * s1, const char * s2, ULONG ulLen );
extern int hb_strgreater( const char * szText1, const char * szText2 );
extern void hb_strupr( char * szText );
extern BOOL hb_strMatchRegExp( const char * szString, const char * szMask );
extern BOOL hb_strEmpty( const char * szText, ULONG ulLen );

View File

@@ -68,6 +68,7 @@ static ULONG hb_TimeStrToSec( char * pszTime )
HB_TRACE(("hb_TimeStrToSec(%s)", pszTime));
ulLen = strlen( pszTime );
if( ulLen >= 1 )
ulTime += ( ULONG ) hb_strVal( pszTime ) * 3600;
@@ -88,7 +89,7 @@ HARBOUR HB_AMPM( void )
USHORT uiHour = ( USHORT ) hb_strVal( pszTime );
BOOL bAM;
memset( pszResult, 0, 3 );
memset( pszResult, '\0', 3 );
memcpy( pszResult, pszTime, ulTimeLen );
if( uiHour == 0 || uiHour == 24 )
@@ -110,14 +111,12 @@ HARBOUR HB_AMPM( void )
pszResult[ 1 ] = ( char ) ( uiHour % 10 ) + '0';
if( pszResult[ 0 ] == '0' )
pszResult[ 0 ] = ' ';
pszResult[ 0 ] = ' ';
bAM = FALSE;
}
else if( uiHour == 12 )
bAM = FALSE;
else
bAM = TRUE;
bAM = ( uiHour != 12 );
strcpy( pszResult + ulTimeLen, bAM ? " am" : " pm" );

View File

@@ -814,9 +814,10 @@ HARBOUR HB_SUBSTR( void )
{
hb_itemReturn( pResult );
hb_itemRelease( pResult );
/* NOTE: Exit from inside */
return;
}
/* NOTE: Exit from inside */
return;
}
}
else
@@ -1583,29 +1584,6 @@ HARBOUR HB_STRZERO( void )
}
}
/* Values returned : HB_STRGREATER_EQUAL, HB_STRGREATER_LEFT, HB_STRGREATER_RIGHT */
int hb_strgreater( const char * szText1, const char * szText2 )
{
HB_TRACE(("hb_strgreater(%s, %s)", szText1, szText2));
while( *szText1 && *szText2 && *szText1 == *szText2 )
{
szText1++;
szText2++;
}
if( ( *szText1 == '\0' && *szText2 != '\0' ) ||
( *szText1 < *szText2 ) )
return HB_STRGREATER_RIGHT;
if( ( *szText1 != '\0' && *szText2 == '\0' ) ||
( *szText1 > *szText2 ) )
return HB_STRGREATER_LEFT;
return HB_STRGREATER_EQUAL;
}
/* $DOC$
* $FUNCNAME$
* HB_VALTOSTR

View File

@@ -215,21 +215,22 @@ PHB_DYNS hb_dynsymFind( char * szName )
while( uiFirst < uiLast )
{
switch( hb_strgreater( s_pDynItems[ uiMiddle ].pDynSym->pSymbol->szName, szName ) )
int iCmp = strcmp( s_pDynItems[ uiMiddle ].pDynSym->pSymbol->szName, szName );
if( iCmp == 0 )
{
case HB_STRGREATER_EQUAL: /* they are equals */
s_uiClosestDynSym = uiMiddle;
return s_pDynItems[ uiMiddle ].pDynSym;
case HB_STRGREATER_LEFT: /* pMiddle is greater */
uiLast = uiMiddle;
s_uiClosestDynSym = uiMiddle;
break;
case HB_STRGREATER_RIGHT: /* szName is greater */
uiFirst = uiMiddle + 1;
s_uiClosestDynSym = uiFirst;
break;
s_uiClosestDynSym = uiMiddle;
return s_pDynItems[ uiMiddle ].pDynSym;
}
else if( iCmp < 0 )
{
uiLast = uiMiddle;
s_uiClosestDynSym = uiMiddle;
}
else /* if( iCmp > 0 ) */
{
uiFirst = uiMiddle + 1;
s_uiClosestDynSym = uiFirst;
}
uiMiddle = uiFirst + ( ( uiLast - uiFirst ) / 2 );

View File

@@ -1665,6 +1665,7 @@ STATIC FUNCTION Main_STRINGS()
TEST_LINE( Pad("abcdef", 0) , "" )
TEST_LINE( Pad("abcdef", 5) , "abcde" )
TEST_LINE( Pad("abcdef", 10) , "abcdef " )
TEST_LINE( Pad("abcdef", 10, "") , "abcdef"+Chr(0)+""+Chr(0)+""+Chr(0)+""+Chr(0)+"" )
TEST_LINE( Pad("abcdef", 10, "1") , "abcdef1111" )
TEST_LINE( Pad("abcdef", 10, "12") , "abcdef1111" )
@@ -1689,6 +1690,7 @@ STATIC FUNCTION Main_STRINGS()
TEST_LINE( PadR("abcdef", 0) , "" )
TEST_LINE( PadR("abcdef", 5) , "abcde" )
TEST_LINE( PadR("abcdef", 10) , "abcdef " )
TEST_LINE( PadR("abcdef", 10, "") , "abcdef"+Chr(0)+""+Chr(0)+""+Chr(0)+""+Chr(0)+"" )
TEST_LINE( PadR("abcdef", 10, "1") , "abcdef1111" )
TEST_LINE( PadR("abcdef", 10, "12") , "abcdef1111" )
@@ -1713,6 +1715,7 @@ STATIC FUNCTION Main_STRINGS()
TEST_LINE( PadL("abcdef", 0) , "" )
TEST_LINE( PadL("abcdef", 5) , "abcde" ) /* QUESTION: CA-Cl*pper "bug", should return: "bcdef" ? */
TEST_LINE( PadL("abcdef", 10) , " abcdef" )
TEST_LINE( PadL("abcdef", 10, "") , ""+Chr(0)+""+Chr(0)+""+Chr(0)+""+Chr(0)+"abcdef" )
TEST_LINE( PadL("abcdef", 10, "1") , "1111abcdef" )
TEST_LINE( PadL("abcdef", 10, "12") , "1111abcdef" )
@@ -1738,6 +1741,7 @@ STATIC FUNCTION Main_STRINGS()
TEST_LINE( PadC("abcdef", 2) , "ab" ) /* QUESTION: CA-Cl*pper "bug", should return: "cd" ? */
TEST_LINE( PadC("abcdef", 5) , "abcde" )
TEST_LINE( PadC("abcdef", 10) , " abcdef " )
TEST_LINE( PadC("abcdef", 10, "") , ""+Chr(0)+""+Chr(0)+"abcdef"+Chr(0)+""+Chr(0)+"" )
TEST_LINE( PadC("abcdef", 10, "1") , "11abcdef11" )
TEST_LINE( PadC("abcdef", 10, "12") , "11abcdef11" )
@@ -3232,7 +3236,7 @@ STATIC FUNCTION TEST_BEGIN( cParam )
/* NOTE: The 0 parameter of Version() will force Harbour to include the
compiler version in the version string. */
fWrite( s_nFhnd, " Version: " + Version( 0 ) + s_cNewLine +;
FWrite( s_nFhnd, " Version: " + Version( 0 ) + s_cNewLine +;
" OS: " + OS() + s_cNewLine +;
" Date, Time: " + DToS( Date() ) + " " + Time() + s_cNewLine +;
" Output: " + s_cFileName + s_cNewLine +;
@@ -3240,7 +3244,7 @@ STATIC FUNCTION TEST_BEGIN( cParam )
" Switches: " + cParam + s_cNewLine +;
"===========================================================================" + s_cNewLine )
fWrite( s_nFhnd, PadR( "R", TEST_RESULT_COL1_WIDTH ) + " " +;
FWrite( s_nFhnd, PadR( "R", TEST_RESULT_COL1_WIDTH ) + " " +;
PadR( "Line", TEST_RESULT_COL2_WIDTH ) + " " +;
PadR( "TestCall()", TEST_RESULT_COL3_WIDTH ) + " -> " +;
PadR( "Result", TEST_RESULT_COL4_WIDTH ) + " | " +;
@@ -3371,13 +3375,13 @@ STATIC FUNCTION TEST_CALL( cBlock, bBlock, xResultExpected )
ENDIF
IF s_lShowAll .OR. lFailed .OR. lSkipped .OR. lPPError
fWrite( s_nFhnd, PadR( iif( lFailed, "!", iif( lSkipped, "S", " " ) ), TEST_RESULT_COL1_WIDTH ) + " " +;
FWrite( s_nFhnd, PadR( iif( lFailed, "!", iif( lSkipped, "S", " " ) ), TEST_RESULT_COL1_WIDTH ) + " " +;
PadR( ProcName( 1 ) + "(" + LTrim( Str( ProcLine( 1 ), 5 ) ) + ")", TEST_RESULT_COL2_WIDTH ) + " " +;
PadR( cBlock, TEST_RESULT_COL3_WIDTH ) + " -> " +;
PadR( XToStr( xResult ), TEST_RESULT_COL4_WIDTH ) + " | " +;
PadR( XToStr( xResultExpected ), TEST_RESULT_COL5_WIDTH ) )
fWrite( s_nFhnd, s_cNewLine )
FWrite( s_nFhnd, s_cNewLine )
ENDIF
@@ -3396,7 +3400,7 @@ STATIC FUNCTION TEST_END()
s_nEndTime := Seconds()
fWrite( s_nFhnd, "===========================================================================" + s_cNewLine +;
FWrite( s_nFhnd, "===========================================================================" + s_cNewLine +;
"Test calls passed: " + Str( s_nPass ) + s_cNewLine +;
"Test calls failed: " + Str( s_nFail ) + s_cNewLine +;
" ----------" + s_cNewLine +;
@@ -3406,10 +3410,10 @@ STATIC FUNCTION TEST_END()
IF s_nFail != 0
IF "CLIPPER (R)" $ Upper( Version() )
fWrite( s_nFhnd, "WARNING ! Failures detected using CA-Clipper." + s_cNewLine +;
FWrite( s_nFhnd, "WARNING ! Failures detected using CA-Clipper." + s_cNewLine +;
"Please fix those expected results which are not bugs in CA-Clipper itself." + s_cNewLine )
ELSE
fWrite( s_nFhnd, "WARNING ! Failures detected" + s_cNewLine )
FWrite( s_nFhnd, "WARNING ! Failures detected" + s_cNewLine )
ENDIF
ENDIF