diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2261909a90..48d32753ae 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2002-12-01 23:12 UTC+0100 Foo Bar */ +2002-10-22 18:30 UTC-0400 David G. Holm + * source/rtl/set.c + ! Removed comment block that incorrectly commented out + the default case in the HB_SET switch block. + ! Fixed the previously commented out code that prevented + changing the new HB_SET_DIRSEPARATOR value. + * tests/set_test.prg + + Added tests to display the Harbour-specific SET values + and a test for changing the _SET_DIRSEPARATOR value. + 2002-10-22 17:30 UTC-0400 David G. Holm * source/rdd/dbfcmd.c * Made FIELDNAME Clipper compatible for the case where there is diff --git a/harbour/source/rtl/set.c b/harbour/source/rtl/set.c index 180c6f663b..14a0864d75 100644 --- a/harbour/source/rtl/set.c +++ b/harbour/source/rtl/set.c @@ -73,6 +73,8 @@ static PHB_SET_LISTENER sp_sl_first; static PHB_SET_LISTENER sp_sl_last; static int s_next_listener; +static char hb_dirsep_string[2]; + static HB_PATHNAMES * sp_set_path; static void hb_setFreeSetPath( void ) @@ -99,6 +101,24 @@ static void hb_setFreeSetPath( void ) sp_set_path = NULL; } +static char set_char( PHB_ITEM pItem, char oldChar ) +{ + char newChar = oldChar; + + HB_TRACE(HB_TR_DEBUG, ("set_char(%p, %c)", pItem, oldChar)); + + if( HB_IS_STRING( pItem ) ) + { + /* Only replace if string has at least one character. */ + ULONG ulLen = hb_itemGetCLen( pItem ); + if( ulLen > 0 ) + { + newChar = *hb_itemGetCPtr( pItem ); + } + } + return newChar; +} + static BOOL set_logical( PHB_ITEM pItem ) { BOOL bLogical = FALSE; @@ -822,20 +842,14 @@ HB_FUNC( SET ) else hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); } - /* - if( hb_set.HB_SET_DIRCASE ) hb_retc( hb_set.HB_SET_DIRCASE ); - else hb_retc( NULL ); - if( args > 1 ) hb_set.HB_SET_DIRCASE = set_string( pArg2, hb_set.HB_SET_DIRCASE ); - */ break; case HB_SET_DIRSEPARATOR : - /* - if( hb_set.HB_SET_DIRSEPARATOR ) hb_retc( hb_set.HB_SET_DIRSEPARATOR ); - else hb_retc( NULL ); - if( args > 1 ) hb_set.HB_SET_DIRSEPARATOR = set_string( pArg2, hb_set.HB_SET_DIRSEPARATOR ); + hb_dirsep_string[0] = hb_set.HB_SET_DIRSEPARATOR; + hb_dirsep_string[1] = '\0'; + hb_retc( hb_dirsep_string ); + if( args > 1 ) hb_set.HB_SET_DIRSEPARATOR = set_char( pArg2, hb_set.HB_SET_DIRSEPARATOR ); break; default : - */ /* Return NIL if called with invalid SET specifier */ break; } @@ -915,18 +929,9 @@ void hb_setInitialize( void ) hb_set.HB_SET_STRICTREAD = FALSE; hb_set.HB_SET_TYPEAHEAD = 50; hb_inkeyReset( TRUE ); /* Allocate keyboard typeahead buffer */ hb_set.HB_SET_UNIQUE = FALSE; - /* - hb_set.HB_SET_FILECASE = ( char * ) hb_xgrab( 6 ); - memcpy( hb_set.HB_SET_FILECASE, "MIXED", 6 ); - hb_set.HB_SET_DIRCASE = ( char * ) hb_xgrab( 6 ); - memcpy( hb_set.HB_SET_DIRCASE, "MIXED", 6 ); - hb_set.HB_SET_DIRSEPARATOR = ( char * ) hb_xgrab( 2 ); - memcpy( hb_set.HB_SET_DIRSEPARATOR, "\\", 2 ); - */ hb_set.HB_SET_FILECASE = HB_SET_CASE_MIXED; hb_set.HB_SET_DIRCASE = HB_SET_CASE_MIXED; hb_set.HB_SET_DIRSEPARATOR = '\\'; - hb_set.HB_SET_VIDEOMODE = 0; hb_set.HB_SET_WRAP = FALSE; @@ -964,9 +969,6 @@ void hb_setRelease( void ) if( hb_set.HB_SET_MFILEEXT ) hb_xfree( hb_set.HB_SET_MFILEEXT ); if( hb_set.HB_SET_PATH ) hb_xfree( hb_set.HB_SET_PATH ); if( hb_set.HB_SET_PRINTFILE ) hb_xfree( hb_set.HB_SET_PRINTFILE ); - // if( hb_set.HB_SET_FILECASE ) hb_xfree( hb_set.HB_SET_FILECASE ); - // if( hb_set.HB_SET_DIRCASE ) hb_xfree( hb_set.HB_SET_FILECASE ); - // if( hb_set.HB_SET_DIRSEPARATOR ) hb_xfree( hb_set.HB_SET_FILECASE ); hb_set.HB_SET_TYPEAHEAD = -1; hb_inkeyReset( TRUE ); /* Free keyboard typeahead buffer */ diff --git a/harbour/tests/set_test.prg b/harbour/tests/set_test.prg index dea278125a..37530907fe 100644 --- a/harbour/tests/set_test.prg +++ b/harbour/tests/set_test.prg @@ -73,11 +73,22 @@ function Main() TestLine( "_SET_AUTOSHARE", 47) #endif +#ifdef _SET_LANGUAGE + TestLine( "_SET_LANGUAGE", 100) + TestLine( "_SET_IDLEREPEAT", 101) + TestLine( "_SET_FILECASE", 102) + TestLine( "_SET_DIRCASE", 103) + TestLine( "_SET_DIRSEPARATOR",104) + Set(_SET_DIRSEPARATOR, "/") + TestLine( "_SET_DIRSEPARATOR",104) +#endif return nil proc testline( c, n ) -outstd( s_cNewLine ) -outstd( str( n, 3 ) ) -outstd( " "+Padr( c, 17 ) ) -outstd( Set( n ) ) + outstd( s_cNewLine ) + outstd( str( n, 3 ) ) + outstd( " " ) + outstd( Padr( c, 20 ) ) + outstd( Set( n ) ) +return