From 68574c6e0d5c22d304491c4bc9848456d8bd3262 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 2 Mar 2006 00:11:37 +0000 Subject: [PATCH] 2006-03-02 01:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/pp/ppcore.c * fixed yest another problem with PP which caused GPF on minigui compilation --- harbour/ChangeLog | 5 ++ harbour/source/pp/ppcore.c | 116 +++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 63 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 40c84bd9d7..b76f8e3f7b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ * harbour/makefile.vc + * fixed translation of TEXT/ENDTEXT to be more Clipper compatible + +added new hidden preprocessor directive + __text|ParseBlockCode|EndBlockCode|StartBlockCode + + currently TEXT is preprocessed using: #command TEXT => __text|Qout(%s)|QQOut() #command TEXT TO FILE => ; __text|Qout(%s)|__TextRestore()|__TextSave() diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 5cb8fa38b7..5d1daf99b7 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -1100,56 +1100,46 @@ static int ConvertOptional( char *cpatt, int len ) static void RemoveOptional( char *cpatt ) { - int i = 0; - int len = strlen( cpatt ); - int iOpenBra = 0; + int i = 0; + int len = strlen( cpatt ); + int iOpenBra = 0; - while( cpatt[ i ] != '\0' ) - { - if( cpatt[ i ] == '"' || cpatt[ i ] == '\'' ) - { - char c = cpatt[ i ]; - i++; - while( cpatt[ i ] && cpatt[ i ] != c ) + while( cpatt[ i ] != '\0' ) + { + if( cpatt[ i ] == '"' || cpatt[ i ] == '\'' ) { - i++; - } - i++; - continue; /* skip "strings" */ - } - if( cpatt[ i ] == '[' ) - { - i++; - iOpenBra++; - while( cpatt[ i ] && (cpatt[ i ] != ']' || iOpenBra) ) - { - if( cpatt[i] == '[' ) - { - iOpenBra++; - } - else if( cpatt[i] == ']' ) - { - iOpenBra--; - if( iOpenBra == 0 ) - { + char c = cpatt[ i++ ]; + while( cpatt[ i ] && cpatt[ i ] != c ) + { i++; - break; - } - } - i++; + } + if( cpatt[ i ] ) + i++; + continue; /* skip "strings" */ } - i++; - continue; /* skip [strings] */ - } - - if( cpatt[ i ] == HB_PP_OPT_START || cpatt[ i ] == HB_PP_OPT_END ) - { - hb_pp_Stuff( "", cpatt + i, 0, 1, len - i + 1 ); - len--; - } - else - i++; - } + if( cpatt[ i ] == '[' ) + { + i++; + iOpenBra++; + while( cpatt[ i ] && iOpenBra ) + { + if( cpatt[i] == '[' ) + iOpenBra++; + else if( cpatt[i] == ']' ) + iOpenBra--; + i++; + } + continue; /* skip [strings] */ + } + + if( cpatt[ i ] == HB_PP_OPT_START || cpatt[ i ] == HB_PP_OPT_END ) + { + hb_pp_Stuff( "", cpatt + i, 0, 1, len - i + 1 ); + len--; + } + else + i++; + } } @@ -3927,29 +3917,29 @@ static int IsInStr( char symb, char * s ) */ void hb_pp_Stuff(char *ptri, char * ptro, int len1, int len2, int lenres ) { - char *ptr1, *ptr2; - int i; + char *ptr1, *ptr2; + int i; - HB_TRACE(HB_TR_DEBUG, ("hb_pp_Stuff(%s, %s, %d, %d, %d)", ptri, ptro, len1, len2, lenres)); + HB_TRACE(HB_TR_DEBUG, ("hb_pp_Stuff(%s, %s, %d, %d, %d)", ptri, ptro, len1, len2, lenres)); - if( len1 > len2 ) - { + if( len1 > len2 ) + { ptr1 = ptro + lenres; ptr2 = ptro + lenres + len1 - len2; - /* This is a static buffer - current inserting can erase the null char - than we need set it again. - */ - ptr2[1] = '\0'; - for( i=0; i<=lenres; ptr1--,ptr2--,i++ ) *ptr2 = *ptr1; - } - else - { + /* This is a static buffer - current inserting can erase the null char + than we need set it again. + */ + ptr2[1] = '\0'; + for( i = 0; i <= lenres; ptr1--, ptr2--, i++ ) *ptr2 = *ptr1; + } + else + { ptr1 = ptro + len2; ptr2 = ptro + len1; - for( ; ptr1 <= ptro+lenres; ptr1++,ptr2++ ) *ptr2 = *ptr1; - } - ptr2 = ptro; - for( i=0; i < len1; i++ ) *ptr2++ = *(ptri+i); + for( ; ptr1 <= ptro+lenres; ptr1++, ptr2++ ) *ptr2 = *ptr1; + } + ptr2 = ptro; + for( i = 0; i < len1; i++ ) *ptr2++ = *(ptri+i); } int hb_pp_strocpy( char * ptro, char * ptri )