diff --git a/harbour/ChangeLog b/harbour/ChangeLog index de29d65c2f..1c1463080e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-07 14:19 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/set.c + + finished hb_setSetFile() used internally for HB_SET_ALTFILE, + HB_SET_EXTRAFILE, HB_SET_PRINTFILE + 2008-11-07 13:01 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbset.h * harbour/source/vm/set.c diff --git a/harbour/source/vm/set.c b/harbour/source/vm/set.c index d99dbe1621..55c195a116 100644 --- a/harbour/source/vm/set.c +++ b/harbour/source/vm/set.c @@ -1208,12 +1208,62 @@ int hb_setListenerRemove( int listener ) static BOOL hb_setSetFile( HB_set_enum set_specifier, const char * szFile, BOOL fAdditive ) { - /* TODO: */ - HB_SYMBOL_UNUSED( set_specifier ); - HB_SYMBOL_UNUSED( szFile ); - HB_SYMBOL_UNUSED( fAdditive ); + PHB_SET_STRUCT pSet = hb_stackSetStruct(); + BOOL fResult = TRUE; - return FALSE; + switch( set_specifier ) + { + case HB_SET_ALTFILE: + if( pSet->HB_SET_ALTFILE ) + hb_xfree( pSet->HB_SET_ALTFILE ); + /* Limit size of SET strings to 64K, truncating if source is longer */ + pSet->HB_SET_ALTFILE = szFile ? hb_strndup( szFile, USHRT_MAX ) : NULL; + close_text( pSet, pSet->hb_set_althan ); + if( pSet->HB_SET_ALTFILE && pSet->HB_SET_ALTFILE[0] != '\0' ) + pSet->hb_set_althan = open_handle( pSet, pSet->HB_SET_ALTFILE, + fAdditive, ".txt", HB_SET_ALTFILE ); + else + pSet->hb_set_althan = FS_ERROR; + break; + + case HB_SET_EXTRAFILE: + if( pSet->HB_SET_EXTRAFILE ) + hb_xfree( pSet->HB_SET_EXTRAFILE ); + /* Limit size of SET strings to 64K, truncating if source is longer */ + pSet->HB_SET_EXTRAFILE = szFile ? hb_strndup( szFile, USHRT_MAX ) : NULL; + if( szFile ) + { + close_text( pSet, pSet->hb_set_extrahan ); + if( pSet->HB_SET_EXTRAFILE && pSet->HB_SET_EXTRAFILE[0] != '\0' ) + pSet->hb_set_extrahan = open_handle( pSet, pSet->HB_SET_EXTRAFILE, + fAdditive, ".prn", HB_SET_EXTRAFILE ); + else + pSet->hb_set_extrahan = FS_ERROR; + } + break; + + case HB_SET_PRINTFILE: + if( pSet->HB_SET_PRINTFILE ) + hb_xfree( pSet->HB_SET_PRINTFILE ); + /* Limit size of SET strings to 64K, truncating if source is longer */ + pSet->HB_SET_PRINTFILE = szFile ? hb_strndup( szFile, USHRT_MAX ) : NULL; + if( szFile ) + { + close_binary( pSet->hb_set_printhan ); + if( pSet->HB_SET_PRINTFILE && pSet->HB_SET_PRINTFILE[0] != '\0' ) + pSet->hb_set_printhan = open_handle( pSet, pSet->HB_SET_PRINTFILE, + fAdditive, ".prn", HB_SET_PRINTFILE ); + else + pSet->hb_set_printhan = FS_ERROR; + } + break; + + default: + fResult = FALSE; + break; + } + + return fResult; } HB_EXPORT BOOL hb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem )