From 97066f92655acc7b116cd06b938bcbaa2c1f4e6e Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Thu, 3 May 2001 04:16:35 +0000 Subject: [PATCH] 2001-05-02 21:20 UTC-0800 Ron Pinkas * source/pp/ppcore.c ! Correceted bug in getExpReal() where strings could be appended to an invalid expression. --- harbour/ChangeLog | 4 + harbour/source/pp/ppcore.c | 208 ++++++++++++++++++++----------------- 2 files changed, 114 insertions(+), 98 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3d49318b52..053575b543 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,7 @@ +2001-05-02 21:20 UTC-0800 Ron Pinkas + * source/pp/ppcore.c + ! Correceted bug in getExpReal() where strings could be appended to an invalid expression. + 2001-05-02 15:00 UTC-0400 David G. Holm * include/hbapigt.h diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index a618b47c9e..b3bf1e02e6 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -1873,144 +1873,156 @@ static int getExpReal( char * expreal, char ** ptri, BOOL prlist, int maxrez, BO while( **ptri != '\0' && !rez && lens < maxrez ) { /* Added by Ron Pinkas 2000-11-08 ( removed lots of related scattered logic below! */ - if( **ptri == '"' ) + if( State == STATE_EXPRES || strchr( "({[,$!#=<>^%*/+-", cLastChar ) ) /* Ron Pinkas added if on State 2001-05-02 to avoid multiple strings concatination. */ { - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - (*ptri)++; - lens++; - - while( **ptri != '\0' && lens < maxrez ) + if( **ptri == '"' ) { if( expreal != NULL ) { *expreal++ = **ptri; } - if( **ptri == '"' ) + (*ptri)++; + lens++; + + while( **ptri != '\0' && lens < maxrez ) { - break; + if( expreal != NULL ) + { + *expreal++ = **ptri; + } + + if( **ptri == '"' ) + { + break; + } + + (*ptri)++; + lens++; } (*ptri)++; lens++; + + State = ( StBr1==0 && StBr2==0 && StBr3==0 )? STATE_ID_END: STATE_BRACKET; + continue; } - - (*ptri)++; - lens++; - - State = ( StBr1==0 && StBr2==0 && StBr3==0 )? STATE_ID_END: STATE_BRACKET; - continue; - } - else if( **ptri == '\'' ) - { - char *pString; - - if( expreal != NULL ) + else if( **ptri == '\'' ) { - *expreal++ = **ptri; - } + char *pString; - (*ptri)++; - lens++; - - pString = expreal; - - while( **ptri != '\0' && lens < maxrez ) - { if( expreal != NULL ) { *expreal++ = **ptri; } - if( **ptri == '\'' ) + (*ptri)++; + lens++; + + pString = expreal; + + while( **ptri != '\0' && lens < maxrez ) { - break; + if( expreal != NULL ) + { + *expreal++ = **ptri; + } + + if( **ptri == '\'' ) + { + break; + } + + (*ptri)++; + lens++; + } + + if( expreal != NULL ) + { + *(expreal - 1) = '\0'; + if( strchr( pString, '"' ) == NULL ) + { + *(pString - 1) = '"'; + *(expreal - 1) = '"'; + } + else + { + *(expreal - 1) = '\''; + } } (*ptri)++; lens++; + + State = ( StBr1==0 && StBr2==0 && StBr3==0 )? STATE_ID_END: STATE_BRACKET; + continue; } - - if( expreal != NULL ) + else if( **ptri == '[' /* ( see below 5-2-2001 && ( State == STATE_EXPRES || ( strchr( ")]}.", cLastChar ) == NULL && ! ISNAME( cLastChar ) ) )*/ ) { - *(expreal - 1) = '\0'; - if( strchr( pString, '"' ) == NULL ) - { - *(pString - 1) = '"'; - *(expreal - 1) = '"'; - } - else - { - *(expreal - 1) = '\''; - } - } + char *pString; - (*ptri)++; - lens++; - - State = ( StBr1==0 && StBr2==0 && StBr3==0 )? STATE_ID_END: STATE_BRACKET; - continue; - } - else if( **ptri == '[' && ( State == STATE_EXPRES || ( strchr( ")]}.", cLastChar ) == NULL && ! ISNAME( cLastChar ) ) ) ) - { - char *pString; - - if( expreal != NULL ) - { - *expreal++ = **ptri; - } - - (*ptri)++; - lens++; - - pString = expreal; - - while( **ptri != '\0' && lens < maxrez ) - { if( expreal != NULL ) { *expreal++ = **ptri; } - if( **ptri == ']' ) + (*ptri)++; + lens++; + + pString = expreal; + + while( **ptri != '\0' && lens < maxrez ) { - break; + if( expreal != NULL ) + { + *expreal++ = **ptri; + } + + if( **ptri == ']' ) + { + break; + } + + (*ptri)++; + lens++; + } + + if( expreal != NULL ) + { + *(expreal - 1) = '\0'; + if( strchr( pString, '"' ) == NULL ) + { + *(pString - 1) = '"'; + *(expreal - 1) = '"'; + } + else if( strchr( pString, '\'' ) == NULL ) + { + *(pString - 1) = '\''; + *(expreal - 1) = '\''; + } + else + { + *(expreal - 1) = ']'; + } } (*ptri)++; lens++; + + State = ( StBr1==0 && StBr2==0 && StBr3==0 )? STATE_ID_END: STATE_BRACKET; + continue; } - - if( expreal != NULL ) - { - *(expreal - 1) = '\0'; - if( strchr( pString, '"' ) == NULL ) - { - *(pString - 1) = '"'; - *(expreal - 1) = '"'; - } - else if( strchr( pString, '\'' ) == NULL ) - { - *(pString - 1) = '\''; - *(expreal - 1) = '\''; - } - else - { - *(expreal - 1) = ']'; - } - } - - (*ptri)++; - lens++; - - State = ( StBr1==0 && StBr2==0 && StBr3==0 )? STATE_ID_END: STATE_BRACKET; - continue; + /* Added by Ron Pinkas 2001-05-02 ( removed lots of related scattered logic below! */ } - /* END - Added by Ron Pinkas 2000-11-05 */ + else if( strchr( "'\"", **ptri ) ) /* New String, can't belong to extracted expression. */ + { + break; + } + else if( **ptri == '[' && ( strchr( ")]}.", cLastChar ) == NULL && ! ISNAME( cLastChar ) ) ) /* New String, can't belong to extracted expression. */ + { + break; + } + /* End - END - Added by Ron Pinkas 2000-11-05 */ #if 0 printf( "State: %i Char:%c\n", State, **ptri );