diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b30938e217..03fc3a90bb 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,22 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-05 14:03 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbct/video.c + % use hb_gtColorToN() function instead of own code to decode Clipper + color in VGAPALETTE() + ! added protection against possible transfer buffer overflow in + SETFONT() function + ! return -2 when SETFONT() is not implemented + + TODO: clean these functions, add support for other DOS compilers, + add some missing functions and redirect few of them like + VGAPALETTE() to hb_gtInfo() in non DOS builds + + * harbour/src/rtl/hbgtcore.c + ! fixed missing ';' => CHR( 13 ) translation in __KEYBOARD() function + [TOMERGE 2.0] + 2010-01-05 02:59 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbxbp/xbpmenubar.prg * contrib/hbxbp/xbptoolbar.prg diff --git a/harbour/contrib/hbct/video.c b/harbour/contrib/hbct/video.c index ff7665d29d..b357bcd901 100644 --- a/harbour/contrib/hbct/video.c +++ b/harbour/contrib/hbct/video.c @@ -57,6 +57,7 @@ */ #include "hbapi.h" +#include "hbapigt.h" #if defined( HB_OS_DOS ) @@ -147,7 +148,7 @@ HB_FUNC( VGAPALETTE ) { const char *color_string; char red, green, blue; - char attr = 0; + char attr; if( hb_pcount() < 4 ) { @@ -155,57 +156,16 @@ HB_FUNC( VGAPALETTE ) hb_retl( FALSE ); return; } - if( HB_ISNUM( 1 ) && hb_parni( 1 ) < 16 ) - { - attr = hb_parni( 1 ); - } - else if( HB_ISCHAR( 1 ) ) - { - const char *s; - color_string = hb_parcx( 1 ); - for( s = color_string; *s; s++ ) - { - switch ( *s ) - { - case 'N': - case 'n': - attr |= 0; - break; - case 'B': - case 'b': - attr |= 1; - break; - case 'G': - case 'g': - attr |= 2; - break; - case 'R': - case 'r': - attr |= 4; - break; - case 'W': - case 'w': - attr |= 7; - break; - case '+': - attr |= 8; - break; - case 'U': - case 'u': - case 'I': - case 'i': - case 'X': - case 'x': - /* these seem to be used only in mono */ - break; - default: - hb_retl( FALSE ); - return; - } - } - } + color_string = hb_parc( 1 ); + if( color_string ) + attr = hb_gtColorToN( color_string ); + else if( HB_ISNUM( 1 ) ) + attr = hb_parni( 1 ); else + attr = -1; + + if( attr < 0 || attr >= 16 ) { /* An invalid argument */ hb_retl( FALSE ); @@ -352,9 +312,8 @@ HB_FUNC( SETFONT ) offset = hb_parni( 3 ); if( HB_ISNUM( 4 ) ) count = hb_parni( 4 ); - if( HB_ISLOG( 3 ) ) - if( hb_parl( 3 ) && count != 0 ) - height = len / count; + if( HB_ISLOG( 3 ) && hb_parl( 3 ) && count != 0 ) + height = len / count; # ifdef __DJGPP__ { @@ -367,12 +326,13 @@ HB_FUNC( SETFONT ) r.x.dx = offset; r.x.es = __tb >> 4; r.x.bp = __tb & 0xF; - dosmemput( font, len, __tb ); + dosmemput( font, HB_MIN( len, __tb_size ), __tb ); __dpmi_int( 0x10, &r ); + hb_retni( 0 ); } +# else + hb_retni( -2 ); # endif - - hb_retni( 0 ); } #endif /* HB_OS_DOS */ diff --git a/harbour/src/rtl/hbgtcore.c b/harbour/src/rtl/hbgtcore.c index 22c37d7509..072068383c 100644 --- a/harbour/src/rtl/hbgtcore.c +++ b/harbour/src/rtl/hbgtcore.c @@ -2524,6 +2524,12 @@ static void hb_gt_def_InkeySetText( PHB_GT pGT, const char * szText, ULONG ulLen memcpy( pGT->StrBuffer, szText, ulLen ); pGT->StrBufferSize = ulLen; pGT->StrBufferPos = 0; + do + { + if( pGT->StrBuffer[ --ulLen ] == ';' ) + pGT->StrBuffer[ ulLen ] = HB_CHAR_CR; + } + while( ulLen ); } }