2007-09-12 02:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/std.ch
    * cover ENDSEQUENCE translation with HB_C52_STRICT macro
    + added translations for END SWITCH, END WITH, END OBJECT

  * harbour/source/compiler/complex.c
  * harbour/source/compiler/harbour.y
  * harbour/source/compiler/harbour.yyc
  * harbour/source/compiler/harbour.yyh
    + added support for ENDSEQ[UENCE], ENDSW[ITCH] and ENDW[ITH]

  * harbour/source/rtl/hbgtcore.c
    ! changed string to color number translation to be fully Clipper
      compatible. Now I do not know any examples which we translate
      differently - if someone will find any them then please inform me.
      The only one intentional difference between Harbour and Clipper
      is in color number to string translation and background highlighting
      attribute "*", Clipper put it just before "/" as part of foreground
      color (f.e.: 248 => "N*+/W") but Harbour as part background color
      (f.e.: 248 => "N+/W*") - Clipper compatible behavior is enabled when
      Harbour is compiled with HB_C52_STRICT macro

  * harbour/utils/hbtest/rt_misc.prg
    * control the position of background highlighting attribute (*) in
      expected results depending on HB_C52_STRICT. Harbour passes correctly
      all included color translation tests.
This commit is contained in:
Przemyslaw Czerpak
2007-09-12 00:10:09 +00:00
parent 709de529ef
commit 08a3551742
8 changed files with 3288 additions and 3264 deletions

View File

@@ -8,6 +8,33 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2007-09-12 02:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/std.ch
* cover ENDSEQUENCE translation with HB_C52_STRICT macro
+ added translations for END SWITCH, END WITH, END OBJECT
* harbour/source/compiler/complex.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/harbour.yyh
+ added support for ENDSEQ[UENCE], ENDSW[ITCH] and ENDW[ITH]
* harbour/source/rtl/hbgtcore.c
! changed string to color number translation to be fully Clipper
compatible. Now I do not know any examples which we translate
differently - if someone will find any them then please inform me.
The only one intentional difference between Harbour and Clipper
is in color number to string translation and background highlighting
attribute "*", Clipper put it just before "/" as part of foreground
color (f.e.: 248 => "N*+/W") but Harbour as part background color
(f.e.: 248 => "N+/W*") - Clipper compatible behavior is enabled when
Harbour is compiled with HB_C52_STRICT macro
* harbour/utils/hbtest/rt_misc.prg
* control the position of background highlighting attribute (*) in
expected results depending on HB_C52_STRICT. Harbour passes correctly
all included color translation tests.
2007-09-11 23:34 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* source/rtl/hbgtcore.c
! Fixed handling of some strangely formatted colorstrings

View File

@@ -55,15 +55,25 @@
#include "set.ch"
#ifdef HB_C52_STRICT
#command END SEQUENCE => end
#command ENDSEQUENCE => end
#else
#command END SEQUENCE => endsequence
#endif
/* Harbour extensions */
#command END SWITCH => endswitch
#command END WITH => endwith
#command END OBJECT => endwith
#command DO WHILE <exp> => while <exp>
#command END <x> => end
#command END SEQUENCE => end
#command ENDSEQUENCE => end
#command ENDDO <*x*> => enddo
#command ENDIF <*x*> => endif
#command ENDCASE <*x*> => endcase
#command ENDFOR [<*x*>] => next
#command NEXT <v> [TO <x>] [STEP <s>] => next
#command DO <proc>.prg [WITH <p,...>] => do <proc> [ WITH <p>]
#command CALL <proc>() [WITH <p,...>] => call <proc> [ WITH <p>]
#command STORE <v> TO <v1> [,<vN>] => <v1> := [ <vN> :=] <v>

View File

@@ -123,6 +123,9 @@ static const HB_LEX_KEY s_keytable[] =
{ "ENDCASE", 4, 7, ENDCASE },
{ "ENDDO", 4, 5, ENDDO },
{ "ENDIF", 4, 5, ENDIF },
{ "ENDSEQUENCE", 6, 11, ENDSEQ },
{ "ENDSWITCH", 5, 9, ENDSWITCH },
{ "ENDWITH", 4, 7, ENDWITH },
{ "EXIT", 4, 4, EXIT },
{ "EXTERNAL", 4, 8, EXTERN },
{ "FIELD", 4, 5, FIELD },
@@ -743,6 +746,13 @@ int hb_complex( YYSTYPE *yylval_ptr, HB_COMP_DECL )
HB_COMP_ERR_ENDDO, NULL, NULL );
break;
case ENDSEQ:
case ENDSWITCH:
case ENDWITH:
if( pLex->iState != LOOKUP || !HB_PP_TOKEN_ISEOC( pToken->pNext ) )
iType = IDENTIFIER;
break;
case INIT:
if( pLex->iState == LOOKUP && pToken->pNext &&
HB_PP_TOKEN_TYPE( pToken->pNext->type ) == HB_PP_TOKEN_KEYWORD &&

View File

@@ -160,14 +160,15 @@ extern void yyerror( HB_COMP_DECL, char * ); /* parsing error management fun
%token INC DEC ALIASOP DOCASE CASE OTHERWISE ENDCASE ENDDO MEMVAR
%token WHILE LOOP FOR NEXT TO STEP LE GE FIELD IN PARAMETERS
%token PLUSEQ MINUSEQ MULTEQ DIVEQ POWER EXPEQ MODEQ
%token PRIVATE BEGINSEQ BREAK RECOVER RECOVERUSING ALWAYS DO WITH SELF LINE
%token PRIVATE BEGINSEQ BREAK RECOVER RECOVERUSING ALWAYS ENDSEQ
%token DO WITH SELF LINE
%token MACROVAR MACROTEXT
%token AS_ARRAY AS_BLOCK AS_CHARACTER AS_CLASS AS_DATE AS_LOGICAL AS_NUMERIC AS_OBJECT AS_VARIANT DECLARE OPTIONAL DECLARE_CLASS DECLARE_MEMBER
%token AS_ARRAY_ARRAY AS_BLOCK_ARRAY AS_CHARACTER_ARRAY AS_CLASS_ARRAY AS_DATE_ARRAY AS_LOGICAL_ARRAY AS_NUMERIC_ARRAY AS_OBJECT_ARRAY
%token PROCREQ
%token CBSTART DOIDENT
%token FOREACH DESCEND
%token DOSWITCH WITHOBJECT
%token DOSWITCH ENDSWITCH WITHOBJECT ENDWITH
%token NUM_DATE
%token EPSILON
%token HASHOP
@@ -1390,41 +1391,45 @@ IfBegin : IF Expression
;
IfElse : ELSE Crlf { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
EmptyStats
EmptyStats
;
IfElseIf : ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
Expression Crlf
{ HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) );
Expression Crlf
{ HB_COMP_EXPR_DELETE( hb_compExprGenPush( $3, HB_COMP_PARAM ) );
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
}
EmptyStats
{ $$ = hb_compElseIfGen( HB_COMP_PARAM, NULL, hb_compGenJump( 0, HB_COMP_PARAM ) );
}
EmptyStats
{ $$ = hb_compElseIfGen( HB_COMP_PARAM, NULL, hb_compGenJump( 0, HB_COMP_PARAM ) );
hb_compGenJumpHere( $<iNumber>5, HB_COMP_PARAM );
}
}
| IfElseIf ELSEIF { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush( HB_COMP_PARAM ); }
Expression Crlf
{ HB_COMP_EXPR_DELETE( hb_compExprGenPush( $4, HB_COMP_PARAM ) );
Expression Crlf
{ HB_COMP_EXPR_DELETE( hb_compExprGenPush( $4, HB_COMP_PARAM ) );
$<iNumber>$ = hb_compGenJumpFalse( 0, HB_COMP_PARAM );
}
EmptyStats
{ $$ = hb_compElseIfGen( HB_COMP_PARAM, $1, hb_compGenJump( 0, HB_COMP_PARAM ) );
}
EmptyStats
{ $$ = hb_compElseIfGen( HB_COMP_PARAM, $1, hb_compGenJump( 0, HB_COMP_PARAM ) );
hb_compGenJumpHere( $<iNumber>6, HB_COMP_PARAM );
}
}
;
EndIf : ENDIF { if( HB_COMP_PARAM->wIfCounter )
--HB_COMP_PARAM->wIfCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); }
| END { if( HB_COMP_PARAM->wIfCounter )
--HB_COMP_PARAM->wIfCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); }
EndIf : EndIfID
{
if( HB_COMP_PARAM->wIfCounter )
--HB_COMP_PARAM->wIfCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
}
;
EndIfID : ENDIF
| END
;
DoCase : DoCaseBegin
Cases
EndCase { hb_compElseIfFix( HB_COMP_PARAM, $2 ); }
EndCase { hb_compElseIfFix( HB_COMP_PARAM, $2 ); }
| DoCaseBegin
Otherwise
@@ -1436,19 +1441,18 @@ DoCase : DoCaseBegin
| DoCaseBegin
Cases
Otherwise
EndCase { hb_compElseIfFix( HB_COMP_PARAM, $2 ); }
EndCase { hb_compElseIfFix( HB_COMP_PARAM, $2 ); }
;
EndCase : ENDCASE
EndCase : EndCaseID
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
}
;
EndCaseID : ENDCASE
| END
{ if( HB_COMP_PARAM->wCaseCounter )
--HB_COMP_PARAM->wCaseCounter;
HB_COMP_PARAM->functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE );
}
;
DoCaseStart : DOCASE { ++HB_COMP_PARAM->wCaseCounter; hb_compLinePushIfDebugger( HB_COMP_PARAM );} Crlf
@@ -1514,11 +1518,21 @@ DoWhile : WhileBegin Expression Crlf
}
;
WhileBegin : WHILE { $$ = HB_COMP_PARAM->functions.pLast->lPCodePos; hb_compLinePushIfInside( HB_COMP_PARAM ); ++HB_COMP_PARAM->wWhileCounter; hb_compLoopStart( HB_COMP_PARAM, TRUE ); }
WhileBegin : WHILE
{
$$ = HB_COMP_PARAM->functions.pLast->lPCodePos;
hb_compLinePushIfInside( HB_COMP_PARAM );
++HB_COMP_PARAM->wWhileCounter;
hb_compLoopStart( HB_COMP_PARAM, TRUE );
}
;
EndWhile : END { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
| ENDDO { HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
EndWhile : EndWhileID
{ HB_COMP_PARAM->functions.pLast->bFlags &= ~ FUN_BREAK_CODE; }
;
EndWhileID : ENDDO
| END
;
ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */
@@ -1588,18 +1602,18 @@ StepExpr : /* default step expression */ { $<asExpr>$ = NULL; }
| STEP Expression { $<asExpr>$ = hb_compExprReduce( $2, HB_COMP_PARAM ); }
;
ForStatements : EmptyStats NEXT { hb_compLinePush( HB_COMP_PARAM );
if( HB_COMP_PARAM->wForCounter )
--HB_COMP_PARAM->wForCounter; }
| EmptyStats NEXT IdentName { hb_compLinePush( HB_COMP_PARAM );
if( HB_COMP_PARAM->wForCounter )
--HB_COMP_PARAM->wForCounter; }
| EmptyStats END { hb_compLinePush( HB_COMP_PARAM );
if( HB_COMP_PARAM->wForCounter )
--HB_COMP_PARAM->wForCounter; }
| EmptyStats END IdentName { hb_compLinePush( HB_COMP_PARAM );
if( HB_COMP_PARAM->wForCounter )
--HB_COMP_PARAM->wForCounter; }
ForStatements : EmptyStats EndForID
{
hb_compLinePush( HB_COMP_PARAM );
if( HB_COMP_PARAM->wForCounter )
--HB_COMP_PARAM->wForCounter;
}
;
EndForID : NEXT
| NEXT IdentName
| END
| END IdentName
;
ForVar : IdentName { $$ = hb_compExprNewVarRef( $1, HB_COMP_PARAM ); }
@@ -1679,7 +1693,7 @@ DoSwitch : SwitchBegin
}
;
EndSwitch : END
EndSwitch : EndSwitchID
{
if( HB_COMP_PARAM->wSwitchCounter )
--HB_COMP_PARAM->wSwitchCounter;
@@ -1687,6 +1701,10 @@ EndSwitch : END
}
;
EndSwitchID : ENDSWITCH
| END
;
SwitchStart : DOSWITCH
{ ++HB_COMP_PARAM->wSwitchCounter;
hb_compLinePushIfInside( HB_COMP_PARAM );
@@ -1780,7 +1798,11 @@ BeginSeq : BEGINSEQ /* 1 */
hb_compSequenceFinish( HB_COMP_PARAM, $<lNumber>2, $<lNumber>6, $<lNumber>9,
$<lNumber>5 != 0, $<lNumber>7 != 0, $<lNumber>4 == lLoopCount );
}
END /* 10 */
EndSeqID /* 10 */
;
EndSeqID : ENDSEQ
| END
;
BlockSeq : /* no always */ { $<lNumber>$ = 0; }
@@ -1888,7 +1910,7 @@ WithObject : WITHOBJECT Expression Crlf
HB_COMP_PARAM->wWithObjectCnt++;
}
EmptyStats
END
EndWithID
{ if( HB_COMP_PARAM->wWithObjectCnt )
--HB_COMP_PARAM->wWithObjectCnt;
if( $<lNumber>5 )
@@ -1902,6 +1924,10 @@ WithObject : WITHOBJECT Expression Crlf
}
;
EndWithID : ENDWITH
| END
;
Crlf : '\n' { HB_COMP_PARAM->fError = FALSE; }
| ';'
;

File diff suppressed because it is too large Load Diff

View File

@@ -103,46 +103,49 @@
RECOVER = 319,
RECOVERUSING = 320,
ALWAYS = 321,
DO = 322,
WITH = 323,
SELF = 324,
LINE = 325,
MACROVAR = 326,
MACROTEXT = 327,
AS_ARRAY = 328,
AS_BLOCK = 329,
AS_CHARACTER = 330,
AS_CLASS = 331,
AS_DATE = 332,
AS_LOGICAL = 333,
AS_NUMERIC = 334,
AS_OBJECT = 335,
AS_VARIANT = 336,
DECLARE = 337,
OPTIONAL = 338,
DECLARE_CLASS = 339,
DECLARE_MEMBER = 340,
AS_ARRAY_ARRAY = 341,
AS_BLOCK_ARRAY = 342,
AS_CHARACTER_ARRAY = 343,
AS_CLASS_ARRAY = 344,
AS_DATE_ARRAY = 345,
AS_LOGICAL_ARRAY = 346,
AS_NUMERIC_ARRAY = 347,
AS_OBJECT_ARRAY = 348,
PROCREQ = 349,
CBSTART = 350,
DOIDENT = 351,
FOREACH = 352,
DESCEND = 353,
DOSWITCH = 354,
WITHOBJECT = 355,
NUM_DATE = 356,
EPSILON = 357,
HASHOP = 358,
POST = 359,
UNARY = 360,
PRE = 361
ENDSEQ = 322,
DO = 323,
WITH = 324,
SELF = 325,
LINE = 326,
MACROVAR = 327,
MACROTEXT = 328,
AS_ARRAY = 329,
AS_BLOCK = 330,
AS_CHARACTER = 331,
AS_CLASS = 332,
AS_DATE = 333,
AS_LOGICAL = 334,
AS_NUMERIC = 335,
AS_OBJECT = 336,
AS_VARIANT = 337,
DECLARE = 338,
OPTIONAL = 339,
DECLARE_CLASS = 340,
DECLARE_MEMBER = 341,
AS_ARRAY_ARRAY = 342,
AS_BLOCK_ARRAY = 343,
AS_CHARACTER_ARRAY = 344,
AS_CLASS_ARRAY = 345,
AS_DATE_ARRAY = 346,
AS_LOGICAL_ARRAY = 347,
AS_NUMERIC_ARRAY = 348,
AS_OBJECT_ARRAY = 349,
PROCREQ = 350,
CBSTART = 351,
DOIDENT = 352,
FOREACH = 353,
DESCEND = 354,
DOSWITCH = 355,
ENDSWITCH = 356,
WITHOBJECT = 357,
ENDWITH = 358,
NUM_DATE = 359,
EPSILON = 360,
HASHOP = 361,
POST = 362,
UNARY = 363,
PRE = 364
};
#endif
/* Tokens. */
@@ -210,46 +213,49 @@
#define RECOVER 319
#define RECOVERUSING 320
#define ALWAYS 321
#define DO 322
#define WITH 323
#define SELF 324
#define LINE 325
#define MACROVAR 326
#define MACROTEXT 327
#define AS_ARRAY 328
#define AS_BLOCK 329
#define AS_CHARACTER 330
#define AS_CLASS 331
#define AS_DATE 332
#define AS_LOGICAL 333
#define AS_NUMERIC 334
#define AS_OBJECT 335
#define AS_VARIANT 336
#define DECLARE 337
#define OPTIONAL 338
#define DECLARE_CLASS 339
#define DECLARE_MEMBER 340
#define AS_ARRAY_ARRAY 341
#define AS_BLOCK_ARRAY 342
#define AS_CHARACTER_ARRAY 343
#define AS_CLASS_ARRAY 344
#define AS_DATE_ARRAY 345
#define AS_LOGICAL_ARRAY 346
#define AS_NUMERIC_ARRAY 347
#define AS_OBJECT_ARRAY 348
#define PROCREQ 349
#define CBSTART 350
#define DOIDENT 351
#define FOREACH 352
#define DESCEND 353
#define DOSWITCH 354
#define WITHOBJECT 355
#define NUM_DATE 356
#define EPSILON 357
#define HASHOP 358
#define POST 359
#define UNARY 360
#define PRE 361
#define ENDSEQ 322
#define DO 323
#define WITH 324
#define SELF 325
#define LINE 326
#define MACROVAR 327
#define MACROTEXT 328
#define AS_ARRAY 329
#define AS_BLOCK 330
#define AS_CHARACTER 331
#define AS_CLASS 332
#define AS_DATE 333
#define AS_LOGICAL 334
#define AS_NUMERIC 335
#define AS_OBJECT 336
#define AS_VARIANT 337
#define DECLARE 338
#define OPTIONAL 339
#define DECLARE_CLASS 340
#define DECLARE_MEMBER 341
#define AS_ARRAY_ARRAY 342
#define AS_BLOCK_ARRAY 343
#define AS_CHARACTER_ARRAY 344
#define AS_CLASS_ARRAY 345
#define AS_DATE_ARRAY 346
#define AS_LOGICAL_ARRAY 347
#define AS_NUMERIC_ARRAY 348
#define AS_OBJECT_ARRAY 349
#define PROCREQ 350
#define CBSTART 351
#define DOIDENT 352
#define FOREACH 353
#define DESCEND 354
#define DOSWITCH 355
#define ENDSWITCH 356
#define WITHOBJECT 357
#define ENDWITH 358
#define NUM_DATE 359
#define EPSILON 360
#define HASHOP 361
#define POST 362
#define UNARY 363
#define PRE 364
@@ -299,7 +305,7 @@ typedef union YYSTYPE
} asMessage;
}
/* Line 1533 of yacc.c. */
#line 303 "harboury.h"
#line 309 "harboury.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1

View File

@@ -313,13 +313,13 @@ static void hb_gt_def_SetClearChar( int iChar )
s_uiClearChar = iChar;
}
static int hb_gt_def_ColorNum( const char * szColorString )
static const char * hb_gt_def_ColorDecode( const char * szColorString, int * piColor )
{
char c;
int nColor = 0;
BOOL bFore = TRUE;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_ColorNum(%s)", szColorString));
HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_ColorDecode(%p)", szColorString, piColor));
while( ( c = *szColorString++ ) != 0 )
{
@@ -334,7 +334,10 @@ static int hb_gt_def_ColorNum( const char * szColorString )
break;
case '/':
bFore = FALSE;
if( !bFore )
nColor = ( ( nColor >> 4 ) & 0x0F07 ) | ( nColor & 0x88 );
else
bFore = FALSE;
break;
case 'B':
@@ -354,53 +357,63 @@ static int hb_gt_def_ColorNum( const char * szColorString )
break;
case 'N':
nColor &= bFore ? 0xF8: 0x8F;
nColor &= bFore ? 0xFFF8: 0xFF8F;
break;
case 'I':
bFore = FALSE;
nColor &= 0x88;
nColor |= 0x70;
break;
case 'U':
nColor |= 0x01;
case 'X':
nColor &= 0x88;
break;
case ' ':
case 'U':
if( bFore )
nColor = ( nColor & 0xF0F8 ) | 0x0801;
else
nColor = ( nColor & 0x0F8F ) | 0x8010;
break;
case ',':
return nColor;
* piColor = nColor;
return szColorString;
default:
if( c >= '0' && c <= '9' &&
( nColor & ( bFore ? 0xFF : 0xF0 ) ) == 0 )
if( c >= '0' && c <= '9' )
{
int iColor = c - '0';
while( *szColorString >= '0' && *szColorString <= '9' )
iColor = iColor * 10 + ( *szColorString++ - '0' );
if( !bFore )
iColor <<= 4;
nColor |= iColor & 0xff;
iColor &= 0x0f;
if( bFore )
nColor = ( nColor & 0xF0F8 ) | iColor;
else
nColor = ( nColor & 0x0F8F ) | ( iColor << 4 );
}
}
}
* piColor = nColor;
return NULL;
}
static int hb_gt_def_ColorNum( const char * szColorString )
{
int nColor;
hb_gt_def_ColorDecode( szColorString, &nColor );
return nColor;
}
static void hb_gt_def_StringToColors( const char * szColorString, int ** pColorsPtr, int * piColorCount )
{
char c;
char buff[ 6 ];
BOOL bHasI = FALSE;
BOOL bHasU = FALSE;
BOOL bHasX = FALSE;
BOOL bSlash = FALSE;
int nPos = 0;
int nFore = 0;
int nColor = 0;
int nCount = -1, i = 0;
int * pColors;
int nPos = 0;
int nColor;
HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_StringToColors(%s,%p,%p)", szColorString, pColorsPtr, piColorCount));
@@ -423,124 +436,17 @@ static void hb_gt_def_StringToColors( const char * szColorString, int ** pColors
}
else do
{
c = *szColorString++;
szColorString = hb_gt_def_ColorDecode( szColorString, &nColor );
while( c >= '0' && c <= '9' && i < 6 )
if( nPos == *piColorCount )
{
buff[ i++ ] = c;
c = *szColorString++;
}
if( i > 0 )
{
buff[ i ] = '\0';
nColor = atoi( buff ) & 0x0F;
++nCount;
i = 0;
++*piColorCount;
pColors = *pColorsPtr = ( int * ) hb_xrealloc( pColors, *piColorCount * sizeof( int ) );
}
pColors[ nPos++ ] = nColor;
++nCount;
switch( toupper( ( UCHAR ) c ) )
{
case 'B':
nColor |= 1;
break;
case 'G':
nColor |= 2;
break;
case 'R':
nColor |= 4;
break;
case 'W':
nColor = 7;
break;
case 'N':
nColor = 0;
break;
case 'I':
bHasI = TRUE;
break;
case 'U':
bHasU = TRUE;
break;
case 'X': /* always sets forground to 'N' */
bHasX = TRUE;
break;
case '*':
nFore |= 128;
break;
case '+':
nFore |= 8;
break;
case '/':
if( bHasU )
{
bHasU = FALSE;
nFore |= 0x0800; /* foreground underline bit */
}
else if( bHasX )
{
nColor = 0;
bHasX = FALSE;
}
else if( bHasI )
{
nColor = 7;
bHasI = FALSE;
}
nFore |= nColor;
nColor = 0;
bSlash = TRUE;
break;
case ',':
case '\0':
if( nCount == 0 )
nFore = pColors[ nPos ];
nCount = -1;
if( nPos == *piColorCount )
{
++*piColorCount;
pColors = *pColorsPtr = ( int * ) hb_xrealloc( pColors, *piColorCount * sizeof( int ) );
}
if( bHasX )
nFore &= 0x88F8;
if( bHasU ) /* background if slash, else foreground */
nColor |= 0x0800;
if( bHasI )
{
if( bSlash )
{
nColor &= 0x088F;
nColor |= 0x0007;
nFore &= 0x88F8;
}
else
{
nColor &= 0x08F8;
nColor |= 0x0070;
nFore &= 0x888F;
}
}
if( ( nFore & 0x8800 ) != 0 && ( ( nFore | nColor ) & 0x0077 ) == 0 )
nFore |= 1;
if( bSlash )
pColors[ nPos++ ] = ( nColor << 4 ) | nFore;
else
pColors[ nPos++ ] = nColor | nFore;
nColor = nFore = 0;
bSlash = bHasX = bHasU = bHasI = FALSE;
}
}
while( c );
while( szColorString );
if( nPos >= 1 && nPos <= 3 )
pColors[ HB_CLR_UNSELECTED ] = pColors[ HB_CLR_ENHANCED ];
@@ -592,7 +498,6 @@ static void hb_gt_def_ColorsToString( int * pColors, int iColorCount, char * psz
which is quite ugly, otherwise it will put the "+" to the
first half and the "*" to the second (like "W+/B*"), which
is how it should be done. [vszakats] */
#ifdef HB_C52_STRICT
if( ( pColors[ iColorIndex ] & 0x80 ) != 0 )
pszColorString[ iPos++ ] = '*';

View File

@@ -57,6 +57,13 @@
/* Don't change the position of this #include. */
#include "rt_vars.ch"
#undef HB_C52_STRICT_OFF
#ifdef __HARBOUR__
#ifndef HB_C52_STRICT
#define HB_C52_STRICT_OFF
#endif
#endif
FUNCTION Main_MISC()
LOCAL oError
#ifdef __HARBOUR__
@@ -131,9 +138,15 @@ FUNCTION Main_MISC()
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "," ), SetColor() ) , "N/N,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( ",," ), SetColor() ) , "N/N,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "+" ), SetColor() ) , "N+/N,N/N,N/N,N/N,N/N" )
#ifdef HB_C52_STRICT_OFF
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "+*" ), SetColor() ) , "N+/N*,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "*" ), SetColor() ) , "N/N*,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "*+" ), SetColor() ) , "N+/N*,N/N,N/N,N/N,N/N" )
#else
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "+*" ), SetColor() ) , "N*+/N,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "*" ), SetColor() ) , "N*/N,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "*+" ), SetColor() ) , "N*+/N,N/N,N/N,N/N,N/N" )
#endif
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "BR/W+" ), SetColor() ) , "BR+/W,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "BR/W+" ), SetColor() ) , "BR+/W,N/N,N/N,N/N,N/N" )
TEST_LINE( ( SetColor( "N/N,N/N,N/N,N/N,N/N" ), SetColor( "RB/W+" ), SetColor() ) , "BR+/W,N/N,N/N,N/N,N/N" )
@@ -207,9 +220,15 @@ FUNCTION Main_MISC()
TEST_LINE( ( o:colorSpec := "," , o:colorSpec ) , "N/N,N/N" )
TEST_LINE( ( o:colorSpec := ",," , o:colorSpec ) , "N/N,N/N" )
TEST_LINE( ( o:colorSpec := "+" , o:colorSpec ) , "N+/N,N+/N" )
#ifdef HB_C52_STRICT_OFF
TEST_LINE( ( o:colorSpec := "+*" , o:colorSpec ) , "N+/N*,N+/N*" )
TEST_LINE( ( o:colorSpec := "*" , o:colorSpec ) , "N/N*,N/N*" )
TEST_LINE( ( o:colorSpec := "*+" , o:colorSpec ) , "N+/N*,N+/N*" )
#else
TEST_LINE( ( o:colorSpec := "+*" , o:colorSpec ) , "N*+/N,N*+/N" )
TEST_LINE( ( o:colorSpec := "*" , o:colorSpec ) , "N*/N,N*/N" )
TEST_LINE( ( o:colorSpec := "*+" , o:colorSpec ) , "N*+/N,N*+/N" )
#endif
TEST_LINE( ( o:colorSpec := "BR/W+" , o:colorSpec ) , "BR+/W,BR+/W" )
TEST_LINE( ( o:colorSpec := "BR/W+" , o:colorSpec ) , "BR+/W,BR+/W" )
TEST_LINE( ( o:colorSpec := "RB/W+" , o:colorSpec ) , "BR+/W,BR+/W" )