2006-12-04 19:20 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/macro/macro.y
* harbour/source/macro/macro.yyc
* harbour/source/macro/macro.yyh
* harbour/source/macro/macrolex.c
* added support for extended string (e"...") to macro compiler and
strings with embedded ASCII NUL character (chr(0))
* harbour/source/rtl/valtostr.c
* added HB_STRTOEXP() function which converts string item to valid
expression which can be compiled by macro compiler. String may
contain any characters.
* harbour/source/rtl/persist.prg
* use HB_STRTOEXP() for sting conversion and 0d....... for date
constants
* harbour/source/rtl/readvar.prg
* harbour/source/rtl/xsavescr.c
* minor cleanup
This commit is contained in:
@@ -8,6 +8,27 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2006-12-04 19:20 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/macro/macro.y
|
||||
* harbour/source/macro/macro.yyc
|
||||
* harbour/source/macro/macro.yyh
|
||||
* harbour/source/macro/macrolex.c
|
||||
* added support for extended string (e"...") to macro compiler and
|
||||
strings with embedded ASCII NUL character (chr(0))
|
||||
|
||||
* harbour/source/rtl/valtostr.c
|
||||
* added HB_STRTOEXP() function which converts string item to valid
|
||||
expression which can be compiled by macro compiler. String may
|
||||
contain any characters.
|
||||
|
||||
* harbour/source/rtl/persist.prg
|
||||
* use HB_STRTOEXP() for sting conversion and 0d....... for date
|
||||
constants
|
||||
|
||||
* harbour/source/rtl/readvar.prg
|
||||
* harbour/source/rtl/xsavescr.c
|
||||
* minor cleanup
|
||||
|
||||
2006-12-01 18:55 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/bin/pack_src.sh
|
||||
+ added packing *.yy[ch] files
|
||||
|
||||
@@ -125,6 +125,11 @@
|
||||
void * pVoid; /* to hold any memory structure we may need */
|
||||
HB_EXPR_PTR asExpr;
|
||||
struct
|
||||
{
|
||||
char * string;
|
||||
int length;
|
||||
} valChar;
|
||||
struct
|
||||
{
|
||||
int iNumber; /* to hold a number returned by lex */
|
||||
} valInteger;
|
||||
@@ -192,7 +197,8 @@ static void hb_macroIdentNew( HB_COMP_DECL, char * );
|
||||
%right ','
|
||||
/*the highest precedence*/
|
||||
|
||||
%type <string> IDENTIFIER LITERAL MACROVAR MACROTEXT
|
||||
%type <string> IDENTIFIER MACROVAR MACROTEXT
|
||||
%type <valChar> LITERAL
|
||||
%type <valDouble> NUM_DOUBLE
|
||||
%type <valLong> NUM_LONG
|
||||
%type <valLong> NUM_DATE
|
||||
@@ -283,7 +289,7 @@ NilValue : NIL { $$ = hb_compExprNewNil( HB_COMP_PARAM ); }
|
||||
|
||||
/* Literal string value
|
||||
*/
|
||||
LiteralValue : LITERAL { $$ = hb_compExprNewString( $1, strlen($1), FALSE, HB_COMP_PARAM ); }
|
||||
LiteralValue : LITERAL { $$ = hb_compExprNewString( $1.string, $1.length, FALSE, HB_COMP_PARAM ); }
|
||||
;
|
||||
|
||||
/* Logical value
|
||||
@@ -990,7 +996,8 @@ int hb_macrolex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro )
|
||||
return NUM_DATE;
|
||||
|
||||
case HB_PP_TOKEN_STRING:
|
||||
yylval_ptr->string = pToken->value;
|
||||
yylval_ptr->valChar.string = pToken->value;
|
||||
yylval_ptr->valChar.length = pToken->len;
|
||||
return LITERAL;
|
||||
|
||||
case HB_PP_TOKEN_LOGICAL:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -128,6 +128,11 @@ typedef union YYSTYPE
|
||||
void * pVoid; /* to hold any memory structure we may need */
|
||||
HB_EXPR_PTR asExpr;
|
||||
struct
|
||||
{
|
||||
char * string;
|
||||
int length;
|
||||
} valChar;
|
||||
struct
|
||||
{
|
||||
int iNumber; /* to hold a number returned by lex */
|
||||
} valInteger;
|
||||
@@ -144,7 +149,7 @@ typedef union YYSTYPE
|
||||
} valDouble;
|
||||
}
|
||||
/* Line 1529 of yacc.c. */
|
||||
#line 148 "macroy.h"
|
||||
#line 153 "macroy.h"
|
||||
YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
|
||||
@@ -131,22 +131,59 @@ static int hb_lexStringCopy( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro,
|
||||
PHB_MACRO_LEX pLex, char cDelim )
|
||||
{
|
||||
pLex->quote = FALSE;
|
||||
yylval_ptr->string = pLex->pDst;
|
||||
yylval_ptr->valChar.string = pLex->pDst;
|
||||
while( pLex->ulSrc < pLex->ulLen )
|
||||
{
|
||||
char ch = pLex->pString[ pLex->ulSrc++ ];
|
||||
if( ch == cDelim )
|
||||
{
|
||||
yylval_ptr->valChar.length = pLex->pDst - yylval_ptr->valChar.string;
|
||||
*pLex->pDst++ = '\0';
|
||||
return LITERAL;
|
||||
}
|
||||
*pLex->pDst++ = ch;
|
||||
}
|
||||
yylval_ptr->valChar.length = pLex->pDst - yylval_ptr->valChar.string;
|
||||
*pLex->pDst++ = '\0';
|
||||
hb_macroError( EG_SYNTAX, pMacro );
|
||||
return LITERAL;
|
||||
}
|
||||
|
||||
static int hb_lexStringExtCopy( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro,
|
||||
PHB_MACRO_LEX pLex )
|
||||
{
|
||||
ULONG ulLen;
|
||||
pLex->quote = FALSE;
|
||||
yylval_ptr->valChar.string = pLex->pDst;
|
||||
while( pLex->ulSrc < pLex->ulLen )
|
||||
{
|
||||
char ch = pLex->pString[ pLex->ulSrc++ ];
|
||||
if( ch == '\\' )
|
||||
{
|
||||
if( pLex->ulSrc < pLex->ulLen )
|
||||
{
|
||||
*pLex->pDst++ = ch;
|
||||
ch = pLex->pString[ pLex->ulSrc++ ];
|
||||
}
|
||||
}
|
||||
else if( ch == '"' )
|
||||
{
|
||||
ulLen = pLex->pDst - yylval_ptr->valChar.string;
|
||||
*pLex->pDst++ = '\0';
|
||||
hb_strRemEscSeq( yylval_ptr->valChar.string, &ulLen );
|
||||
yylval_ptr->valChar.length = ( int ) ulLen;
|
||||
return LITERAL;
|
||||
}
|
||||
*pLex->pDst++ = ch;
|
||||
}
|
||||
ulLen = pLex->pDst - yylval_ptr->valChar.string;
|
||||
*pLex->pDst++ = '\0';
|
||||
hb_strRemEscSeq( yylval_ptr->valChar.string, &ulLen );
|
||||
yylval_ptr->valChar.length = ( int ) ulLen;
|
||||
hb_macroError( EG_SYNTAX, pMacro );
|
||||
return LITERAL;
|
||||
}
|
||||
|
||||
static int hb_lexNumConv( YYSTYPE *yylval_ptr, PHB_MACRO_LEX pLex, ULONG ulLen )
|
||||
{
|
||||
HB_LONG lNumber;
|
||||
@@ -550,7 +587,17 @@ int hb_macrolex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro )
|
||||
return MACROTEXT;
|
||||
}
|
||||
*pLex->pDst++ = '\0';
|
||||
if( pLex->pDst - yylval_ptr->string == 3 )
|
||||
if( pLex->pDst - yylval_ptr->string == 2 )
|
||||
{
|
||||
if( yylval_ptr->string[ 0 ] == 'E' &&
|
||||
pLex->ulLen > pLex->ulSrc &&
|
||||
pLex->pString[ pLex->ulSrc ] == '"' )
|
||||
{
|
||||
pLex->ulSrc++;
|
||||
return hb_lexStringExtCopy( yylval_ptr, pMacro, pLex );
|
||||
}
|
||||
}
|
||||
else if( pLex->pDst - yylval_ptr->string == 3 )
|
||||
{
|
||||
if( yylval_ptr->string[ 0 ] == 'I' &&
|
||||
yylval_ptr->string[ 1 ] == 'F' )
|
||||
|
||||
@@ -211,26 +211,17 @@ static function ValToText( uValue )
|
||||
|
||||
local cType := ValType( uValue )
|
||||
local cText
|
||||
local cQuote := '"'
|
||||
|
||||
do case
|
||||
case cType == "C"
|
||||
if cQuote $ uValue
|
||||
cQuote := "'"
|
||||
if cQuote $ uValue
|
||||
cText := "["+ uValue + "]"
|
||||
else
|
||||
cText := cQuote + uValue + cQuote
|
||||
endif
|
||||
else
|
||||
cText := cQuote + uValue + cQuote
|
||||
endif
|
||||
cText := HB_StrToExp( uValue )
|
||||
|
||||
case cType == "N"
|
||||
cText := AllTrim( Str( uValue ) )
|
||||
|
||||
case cType == "D"
|
||||
cText := 'HB_STOD( "' + DToS( uValue ) + '" )'
|
||||
cText := DToS( uValue )
|
||||
cText := "0d" + iif( Empty( cText ), "00000000", cText )
|
||||
|
||||
otherwise
|
||||
cText := HB_ValToStr( uValue )
|
||||
|
||||
@@ -56,9 +56,11 @@ FUNCTION ReadVar( cVarName )
|
||||
STATIC s_cVarName := ""
|
||||
|
||||
LOCAL cOldVarName
|
||||
LOCAL oGetList
|
||||
|
||||
IF __GetListActive() != NIL
|
||||
RETURN __GetListActive():ReadVar( cVarName )
|
||||
oGetList := __GetListActive()
|
||||
IF oGetList != NIL
|
||||
RETURN oGetList:ReadVar( cVarName )
|
||||
ENDIF
|
||||
|
||||
cOldVarName := s_cVarName
|
||||
|
||||
@@ -67,5 +67,88 @@ HB_FUNC( HB_VALTOSTR )
|
||||
hb_retclen( buffer, ulLen );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_STRTOEXP )
|
||||
{
|
||||
char * pszString = hb_parc( 1 );
|
||||
if( pszString )
|
||||
{
|
||||
ULONG ulLen = hb_parclen( 1 ), ulRet, ul;
|
||||
int iType = 0, iQ = 0;
|
||||
char ch, * pDst, * pszResult;
|
||||
|
||||
for( ul = 0; ul < ulLen; ++ul )
|
||||
{
|
||||
if( pszString[ ul ] == '"' )
|
||||
{
|
||||
++iQ;
|
||||
iType |= 1;
|
||||
}
|
||||
else if( pszString[ ul ] == '\\' )
|
||||
++iQ;
|
||||
else if( pszString[ ul ] == '\'' )
|
||||
iType |= 2;
|
||||
else if( pszString[ ul ] == ']' )
|
||||
iType |= 4;
|
||||
else if( pszString[ ul ] == '\r' ||
|
||||
pszString[ ul ] == '\n' ||
|
||||
pszString[ ul ] == '\0' )
|
||||
{
|
||||
iType |= 7;
|
||||
iQ += 3;
|
||||
}
|
||||
}
|
||||
if( iType == 7 )
|
||||
{
|
||||
ulRet = ulLen + 3 + iQ;
|
||||
pDst = pszResult = ( char * ) hb_xgrab( ulRet + 1 );
|
||||
*pDst++ = 'e';
|
||||
*pDst++ = '"';
|
||||
for( ul = 0; ul < ulLen; ++ul )
|
||||
{
|
||||
ch = pszString[ ul ];
|
||||
if( ch == '"' )
|
||||
{
|
||||
*pDst++ = '\\';
|
||||
*pDst++ = '"';
|
||||
}
|
||||
else if( ch == '\\' )
|
||||
{
|
||||
*pDst++ = '\\';
|
||||
*pDst++ = '\\';
|
||||
}
|
||||
else if( ch == '\r' || ch == '\n' || ch == '\0' )
|
||||
{
|
||||
*pDst++ = '\\';
|
||||
*pDst++ = '0';
|
||||
*pDst++ = '0' + ( ch >> 3 );
|
||||
*pDst++ = '0' + ( ch & 7 );
|
||||
}
|
||||
else
|
||||
*pDst++ = ch;
|
||||
}
|
||||
*pDst++ = '"';
|
||||
}
|
||||
else
|
||||
{
|
||||
ulRet = ulLen + 2;
|
||||
pDst = pszResult = ( char * ) hb_xgrab( ulRet + 1 );
|
||||
if( ( iType & 1 ) == 0 )
|
||||
*pDst++ = ch = '"';
|
||||
else if( ( iType & 2 ) == 0 )
|
||||
*pDst++ = ch = '\'';
|
||||
else
|
||||
{
|
||||
*pDst++ = '[';
|
||||
ch = ']';
|
||||
}
|
||||
memcpy( pDst, pszString, ulLen );
|
||||
pDst += ulLen;
|
||||
*pDst++ = ch;
|
||||
}
|
||||
*pDst = '\0';
|
||||
hb_retclen_buffer( pszResult, ulRet );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -83,12 +83,10 @@ HB_FUNC( __XSAVESCREEN )
|
||||
{
|
||||
ULONG ulSize;
|
||||
|
||||
hb_gtGetPos( &s_iRow, &s_iCol );
|
||||
hb_gtRectSize( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), &ulSize );
|
||||
if( s_pBuffer != NULL )
|
||||
hb_xfree( s_pBuffer );
|
||||
|
||||
hb_gtGetPos( &s_iRow, &s_iCol );
|
||||
|
||||
hb_gtRectSize( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), &ulSize );
|
||||
s_pBuffer = hb_xgrab( ulSize );
|
||||
hb_gtSave( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), s_pBuffer );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user