2006-11-17 14:55 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/source/common/hbstr.c
    ! fixed decoding strings without trailing ASCII NUL character in
      hb_strRemEscSeq()

  * harbour/source/pp/ppcore.c
    + added decoding C escaped strings (e"...") to PP so they can be
      preprocessed like a normal strings, it's not enabled when
      HB_C52_STRICT macro is set
This commit is contained in:
Przemyslaw Czerpak
2006-11-17 13:59:17 +00:00
parent 8d38c093b4
commit f474925255
3 changed files with 60 additions and 17 deletions

View File

@@ -8,6 +8,16 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
symbols then we should expect some farther speed improvement,
it will also resolve some set of memory leaks like in:
type("user input")
and will allow to make some parts of grammar parser common to
compiler and macro compiler by removing #if[n]def HB_MACRO_SUPPORT
2006-11-17 14:55 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/common/hbstr.c
! fixed decoding strings without trailing ASCII NUL character in
hb_strRemEscSeq()
* harbour/source/pp/ppcore.c
+ added decoding C escaped strings (e"...") to PP so they can be

View File

@@ -871,25 +871,32 @@ char * hb_strRemEscSeq( char *str, ULONG *pLen )
if( ch == '\\' )
{
++ulStripped;
ch = *ptr++;
switch( ch )
if( ul )
{
case 'r':
ch = '\r';
break;
case 'n':
ch = '\n';
break;
case 't':
ch = '\t';
break;
case 'b':
ch = '\b';
break;
case '\\':
default:
break;
ul--;
ch = *ptr++;
switch( ch )
{
case 'r':
ch = '\r';
break;
case 'n':
ch = '\n';
break;
case 't':
ch = '\t';
break;
case 'b':
ch = '\b';
break;
case '\\':
default:
break;
}
}
else
break;
}
*dst++ = ch;
}

View File

@@ -938,6 +938,32 @@ static void hb_pp_getLine( PHB_PP_STATE pState )
else
++ul;
}
#ifndef HB_C52_STRICT
else if( ( ch == 'e' || ch == 'E' ) && ulLen > 1 &&
pBuffer[ 1 ] == '"' )
{
ULONG ulStrip;
++ul;
while( ++ul < ulLen && pBuffer[ ul ] != '"' )
{
if( pBuffer[ ul ] == '\\' && ulLen - ul > 1 )
++ul;
}
ulStrip = ul - 2;
hb_strRemEscSeq( pBuffer + 2, &ulStrip );
hb_pp_tokenAddNext( pState, pBuffer + 2, ulStrip,
HB_PP_TOKEN_STRING );
if( ul == ulLen )
{
ULONG ulSkip = pBuffer - hb_membufPtr( pState->pBuffer );
hb_membufAddCh( pState->pBuffer, '\0' );
pBuffer = hb_membufPtr( pState->pBuffer ) + ulSkip;
hb_pp_error( pState, 'E', HB_PP_ERR_STRING_TERMINATOR, pBuffer + 1 );
}
else
++ul;
}
#endif
else if( ch == '[' && !pState->fDirective &&
hb_pp_canQuote( pState->fCanNextLine ||
HB_PP_TOKEN_CANQUOTE( pState->iLastType ),