From c61ec1315557f73a1a01d171ee0722fe918f233e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 20 May 2009 19:27:06 +0000 Subject: [PATCH] 2009-05-20 21:25 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/vm/set.c ! Applied fix sent by Xavi. Thanks. I did a few minor formattings and rename, and did a light review, please review further and test. I seem to remember some deeper problems with this feature, reported a while ago on the list. --- harbour/ChangeLog | 8 ++++++++ harbour/source/vm/set.c | 35 +++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3ba6d3dbeb..49199d6cd1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-20 21:25 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * source/vm/set.c + ! Applied fix sent by Xavi. Thanks. + I did a few minor formattings and rename, and did a + light review, please review further and test. I seem to + remember some deeper problems with this feature, + reported a while ago on the list. + 2009-05-20 20:02 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg ! Added workaround for DIRECTORY() problem under Windows. diff --git a/harbour/source/vm/set.c b/harbour/source/vm/set.c index 4429742b15..c914da838d 100644 --- a/harbour/source/vm/set.c +++ b/harbour/source/vm/set.c @@ -467,6 +467,22 @@ HB_FUNC( SETCANCEL ) hb_setSetItem( HB_SET_CANCEL, hb_param( 1, HB_IT_LOGICAL ) ); } +static void hb_set_PRINTFILE_default( PHB_SET_STRUCT pSet ) +{ + if( pSet->HB_SET_PRINTFILE ) + hb_xfree( pSet->HB_SET_PRINTFILE ); + +#if defined(HB_OS_UNIX) + pSet->HB_SET_PRINTFILE = hb_strdup( "|lpr" ); +#elif defined(HB_OS_DOS) + pSet->HB_SET_PRINTFILE = hb_strdup( "PRN" ); +#elif defined(HB_OS_WIN) || defined(HB_OS_OS2) + pSet->HB_SET_PRINTFILE = hb_strdup( "LPT1" ); +#else + pSet->HB_SET_PRINTFILE = hb_strdup( "PRN" ); /* TOFIX */ +#endif +} + HB_FUNC( SET ) { HB_STACK_TLS_PRELOAD @@ -816,7 +832,13 @@ HB_FUNC( SET ) case HB_SET_PRINTFILE: hb_retc( pSet->HB_SET_PRINTFILE ); if( args > 1 && ! HB_IS_NIL( pArg2 ) ) - pSet->HB_SET_PRINTFILE = set_string( pArg2, pSet->HB_SET_PRINTFILE ); + { + /* With SET PRINTER TO or Set( _SET_PRINTFILE, "" ) are expected to activate the default printer [jarabal] */ + if( hb_itemGetCLen( pArg2 ) == 0 ) + hb_set_PRINTFILE_default( pSet ); + else + pSet->HB_SET_PRINTFILE = set_string( pArg2, pSet->HB_SET_PRINTFILE ); + } if( args > 2 ) bFlag = set_logical( pArg3, FALSE ); else @@ -1096,15 +1118,8 @@ void hb_setInitialize( PHB_SET_STRUCT pSet ) pSet->hb_set_path = NULL; pSet->HB_SET_PRINTER = FALSE; /* Default printer device */ -#if defined(HB_OS_UNIX) - pSet->HB_SET_PRINTFILE = hb_strdup( "|lpr" ); -#elif defined(HB_OS_DOS) - pSet->HB_SET_PRINTFILE = hb_strdup( "PRN" ); -#elif defined(HB_OS_WIN) || defined(HB_OS_OS2) - pSet->HB_SET_PRINTFILE = hb_strdup( "LPT1" ); -#else - pSet->HB_SET_PRINTFILE = hb_strdup( "PRN" ); /* TOFIX */ -#endif + pSet->HB_SET_PRINTFILE = NULL; + hb_set_PRINTFILE_default( pSet ); pSet->hb_set_printhan = FS_ERROR; pSet->HB_SET_SCOREBOARD = TRUE; pSet->HB_SET_SCROLLBREAK = TRUE;