From 6a49a722cdf2313abcb48e636fea9c1d829a948a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 11 May 2007 08:35:52 +0000 Subject: [PATCH] 2007-05-11 10:17 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * harbour/source/rtl/filehb.c * Changed one old TOFIX to a NOTE regarding a minor incompatibility in FILE() where the filename is RTrim()-ed in Clipper but not in Harbour. It became a NOTE because making it compatible would mean losing some portability. * harbour/source/rtl/hbffind.c ! Removed code in UNIX branch which would change an empty file mask to "*" (thus causing FILE("") to return .T. and DIRECTORY("") to return the whole dir content.) ! Made sure in UNIX branch that an empty file mask won't return any files regardless of the filename matching method used. * harbour/source/rtl/strmatch.c + Added NOTE about hb_WildMatch() / sx_WildMatch() incompatibility. ! Guarded WILDMATCH() with HB_COMPAT_XHB. * WILDMATCH() now calls HB_WILDMATCH() internally. --- harbour/ChangeLog | 21 +++++++++++++++++++++ harbour/source/rtl/filehb.c | 5 +++-- harbour/source/rtl/hbffind.c | 8 +++----- harbour/source/rtl/strmatch.c | 22 ++++++++++++++-------- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7475072927..d5c449720f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,27 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-05-11 10:17 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * harbour/source/rtl/filehb.c + * Changed one old TOFIX to a NOTE regarding a minor + incompatibility in FILE() where the filename is RTrim()-ed + in Clipper but not in Harbour. It became a NOTE because + making it compatible would mean losing some portability. + + * harbour/source/rtl/hbffind.c + ! Removed code in UNIX branch which would change an empty + file mask to "*" (thus causing FILE("") to return .T. + and DIRECTORY("") to return the whole dir content.) + ! Made sure in UNIX branch that an empty file mask won't + return any files regardless of the filename matching + method used. + + * harbour/source/rtl/strmatch.c + + Added NOTE about hb_WildMatch() / sx_WildMatch() + incompatibility. + ! Guarded WILDMATCH() with HB_COMPAT_XHB. + * WILDMATCH() now calls HB_WILDMATCH() internally. + 2007-05-11 01:04 UTC+0100 Antonio Linares (alinares@fivetechsoft.com) * contrib/adordd/adordd.prg * Reduced used variables and memory diff --git a/harbour/source/rtl/filehb.c b/harbour/source/rtl/filehb.c index 607994b4f0..be14ed8c22 100644 --- a/harbour/source/rtl/filehb.c +++ b/harbour/source/rtl/filehb.c @@ -56,8 +56,9 @@ /* TODO: Xbase++ has an extension where the second parameter can specify the required attribute. */ -/* TOFIX: CA-Cl*pper RTrim()s the filename before doing the existance check. - [vszakats] */ +/* NOTE: CA-Cl*pper RTrim()s the filename before doing the existence check. + This is not multiplatform friendly, so Harbour doesn't do any + modification on the filename. [vszakats] */ HB_FUNC( FILE ) { diff --git a/harbour/source/rtl/hbffind.c b/harbour/source/rtl/hbffind.c index ea82029f5c..8acdb46b7b 100644 --- a/harbour/source/rtl/hbffind.c +++ b/harbour/source/rtl/hbffind.c @@ -655,9 +655,6 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind ) hb_strncpy( dirname, ".X", sizeof( dirname ) - 1 ); dirname[ 1 ] = OS_PATH_DELIMITER; } - - if( info->pattern[ 0 ] == '\0' ) - hb_strncpy( info->pattern, "*", sizeof( info->pattern ) - 1 ); tzset(); @@ -665,7 +662,7 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind ) hb_strncpy( info->path, dirname, sizeof( info->path ) - 1 ); } - if( info->dir != NULL) + if( info->dir != NULL && info->pattern[ 0 ] != '\0' ) { while( ( info->entry = readdir( info->dir ) ) != NULL ) { @@ -724,7 +721,8 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind ) } } - if( !bFound ) hb_fsSetIOError( bFound, 0 ); + if( ! bFound ) + hb_fsSetIOError( bFound, 0 ); } #else diff --git a/harbour/source/rtl/strmatch.c b/harbour/source/rtl/strmatch.c index eef1b4707e..c47b4218ce 100644 --- a/harbour/source/rtl/strmatch.c +++ b/harbour/source/rtl/strmatch.c @@ -240,14 +240,6 @@ HB_EXPORT BOOL hb_strMatchWildExact( const char *szString, const char *szPattern return fMatch; } -HB_FUNC( WILDMATCH ) -{ - hb_retl( ( ! ISCHAR( 1 ) || ! ISCHAR( 2 ) ) ? FALSE : - hb_parl( 3 ) ? hb_strMatchWildExact( hb_parc( 2 ), hb_parc( 1 ) ) : - hb_strMatchWild( hb_parc( 2 ), hb_parc( 1 ) ) ); -} - - /* TODO: Replace it with a code that supports real regular expressions * */ @@ -264,9 +256,23 @@ BOOL hb_strMatchRegExp( const char * szString, const char * szMask ) * When lExact is TRUE then it will check if whole cValue is covered by * cPattern else if will check if cPatern is a prefix of cValue */ + +/* NOTE: This function is compatible with sx_WildMatch(), except when + the pattern is an empty string where hb_WildMatch() returns + .T., while sx_WildMatch() returns .F. [vszakats] */ + HB_FUNC( HB_WILDMATCH ) { hb_retl( ( ! ISCHAR( 1 ) || ! ISCHAR( 2 ) ) ? FALSE : hb_parl( 3 ) ? hb_strMatchWildExact( hb_parc( 2 ), hb_parc( 1 ) ) : hb_strMatchWild( hb_parc( 2 ), hb_parc( 1 ) ) ); } + +#ifdef HB_COMPAT_XHB + +HB_FUNC( WILDMATCH ) +{ + HB_FUNC_EXEC( HB_WILDMATCH ); +} + +#endif