diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index d5bbce379d..e551a3f358 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -276,7 +276,6 @@ typedef USHORT ERRCODE; extern HB_SYMB hb_symEval; /* Extend API */ -extern char HB_EXPORT * hb_filecase ( char * ); /* Convert string to environment case */ extern char HB_EXPORT * hb_parc( int iParam, ... ); /* retrieve a string parameter */ extern ULONG HB_EXPORT hb_parclen( int iParam, ... ); /* retrieve a string parameter length */ extern ULONG HB_EXPORT hb_parcsiz( int iParam, ... ); /* retrieve a by-reference string parameter length, including terminator */ diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index 8767019799..3f4a4922c1 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -187,6 +187,7 @@ extern USHORT hb_fsAttrFromRaw( ULONG raw_attr ); extern ULONG hb_fsAttrToRaw( USHORT uiAttr ); extern USHORT hb_fsAttrEncode( const char * szAttr ); extern char * hb_fsAttrDecode( USHORT uiAttr, char * szAttr ); +extern BYTE * hb_filecase ( char * ); /* Convert string to environment case */ #if defined(HB_EXTERN_C) } diff --git a/harbour/include/hbset.h b/harbour/include/hbset.h index d04d6df380..0381a8e91c 100644 --- a/harbour/include/hbset.h +++ b/harbour/include/hbset.h @@ -185,13 +185,17 @@ typedef struct BOOL HB_SET_STRICTREAD; int HB_SET_TYPEAHEAD; BOOL HB_SET_UNIQUE; - char * HB_SET_FILECASE; - char * HB_SET_DIRCASE; - char * HB_SET_DIRSEPARATOR; + int HB_SET_FILECASE; + int HB_SET_DIRCASE; + char HB_SET_DIRSEPARATOR; int HB_SET_VIDEOMODE; BOOL HB_SET_WRAP; } HB_SET_STRUCT; +#define HB_SET_CASE_MIXED 0 +#define HB_SET_CASE_LOWER 1 +#define HB_SET_CASE_UPPER 2 + extern HB_SET_STRUCT hb_set; extern void hb_setInitialize( void ); diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 44f7cf45dc..f3edc7f30f 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -391,7 +391,7 @@ static void convert_create_flags_ex( USHORT uiAttr, USHORT uiFlags, int * result #endif -char *hb_filecase(char *str) { +BYTE * hb_filecase(char *str) { // Convert file and dir case. The allowed SET options are: // LOWER - Convert all caracters of file to lower // UPPER - Convert all caracters of file to upper @@ -408,20 +408,33 @@ char *hb_filecase(char *str) { size_t dirlen; // Look for filename (Last "\" or DIRSEPARATOR) - if( hb_set.HB_SET_DIRSEPARATOR[0]!='\\') { - for(a=0;a 1 ) hb_set.HB_SET_IDLEREPEAT = set_logical( pArg2 ); break; case HB_SET_FILECASE : - if( hb_set.HB_SET_FILECASE ) hb_retc( hb_set.HB_SET_FILECASE ); + hb_retni( hb_set.HB_SET_FILECASE ); + if( args > 1 ) + { + if( HB_IS_STRING( pArg2 ) ) + { + if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "LOWER" ) ) + hb_set.HB_SET_FILECASE = HB_SET_CASE_LOWER; + else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "UPPER" ) ) + hb_set.HB_SET_FILECASE = HB_SET_CASE_UPPER; + else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) ) + hb_set.HB_SET_FILECASE = HB_SET_CASE_MIXED; + else + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + } + else if( HB_IS_NUMERIC( pArg2 ) ) + { + if( set_number( pArg2, hb_set.HB_SET_FILECASE ) < 0 ) + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + else + hb_set.HB_SET_FILECASE = set_number( pArg2, hb_set.HB_SET_FILECASE ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + } + /* + if( hb_set.HB_SET_FILECASE ) + hb_retc( hb_set.HB_SET_FILECASE ); else hb_retc( NULL ); - if( args > 1 ) hb_set.HB_SET_FILECASE = set_string( pArg2, hb_set.HB_SET_FILECASE ); + if( hb_stricmp( hb_set.HB_SET_FILECASE, "LOWER" ) == 0 ) + if( args > 1 ) + hb_set.HB_SET_FILECASE = set_string( pArg2, hb_set.HB_SET_FILECASE ); + */ break; case HB_SET_DIRCASE : + hb_retni( hb_set.HB_SET_DIRCASE ); + if( args > 1 ) + { + if( HB_IS_STRING( pArg2 ) ) + { + if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "LOWER" ) ) + hb_set.HB_SET_DIRCASE = HB_SET_CASE_LOWER; + else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "UPPER" ) ) + hb_set.HB_SET_DIRCASE = HB_SET_CASE_UPPER; + else if( ! hb_stricmp( hb_itemGetCPtr( pArg2 ), "MIXED" ) ) + hb_set.HB_SET_DIRCASE = HB_SET_CASE_MIXED; + else + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + } + else if( HB_IS_NUMERIC( pArg2 ) ) + { + if( set_number( pArg2, hb_set.HB_SET_DIRCASE ) < 0 ) + hb_errRT_BASE( EG_ARG, 2020, NULL, "SET", 2, hb_paramError( 1 ), hb_paramError( 2 ) ); + else + hb_set.HB_SET_DIRCASE = set_number( pArg2, hb_set.HB_SET_DIRCASE ); + } + 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 ); break; default : + */ /* Return NIL if called with invalid SET specifier */ break; } @@ -858,12 +915,18 @@ 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; @@ -901,9 +964,9 @@ 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 ); + // 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 */