From 11843e0629b7fbf6ef5d8a995585cc02e488069e Mon Sep 17 00:00:00 2001 From: Andreas Becker Date: Tue, 26 Apr 2011 01:04:29 +0200 Subject: [PATCH] fix wrong starbasic comment highlighting --- svtools/source/edit/syntaxhighlight.cxx | 125 ++++++++++++------------------ 1 files changed, 50 insertions(+), 75 deletions(-) diff --git a/svtools/source/edit/syntaxhighlight.cxx b/svtools/source/edit/syntaxhighlight.cxx index d6626f4..719a3f9 100644 --- a/svtools/source/edit/syntaxhighlight.cxx +++ b/svtools/source/edit/syntaxhighlight.cxx @@ -451,100 +451,75 @@ sal_Bool SimpleTokenizer_Impl::getNextToken( /*out*/TokenTypes& reType, if ( aByteStr.Equals( "rem" ) ) { - // Alle Zeichen bis Zeilen-Ende oder EOF entfernen - sal_Unicode cPeek = peekChar(); - while( cPeek != CHAR_EOF && testCharFlags( cPeek, CHAR_EOL ) == sal_False ) + // move to end of line + // current c = character behind "REM", may already be EOF or EOL + while(c != CHAR_EOF && testCharFlags(c, CHAR_EOL) == sal_False) { - c = getChar(); - cPeek = peekChar(); + getChar(); + c = peekChar(); } - reType = TT_COMMENT; } } } } } + // BASIC comment + else if(c == '\'' && aLanguage == HIGHLIGHT_BASIC) + { + do + { + getChar(); + c = peekChar(); + } + while(c != CHAR_EOF && testCharFlags(c, CHAR_EOL) == sal_False); - // Operator? - // only for BASIC '\'' should be a comment, otherwise it is a normal string and handled there - else if ( ( testCharFlags( c, CHAR_OPERATOR ) == sal_True ) || ( (c == '\'') && (aLanguage==HIGHLIGHT_BASIC)) ) + reType = TT_COMMENT; + } + else if(c == ':' && aLanguage == HIGHLIGHT_SQL) { - // paramters for SQL view - if ( (c==':') || (c=='?')) + // parameters for SQL view + sal_Bool bIdentifierChar; + do { - if (c!='?') - { - sal_Bool bIdentifierChar; - do - { - // Naechstes Zeichen holen - c = peekChar(); - bIdentifierChar = BasicSimpleCharClass::isAlpha( c, true ); - if( bIdentifierChar ) - getChar(); - } - while( bIdentifierChar ); - } - reType = TT_PARAMETER; + // Naechstes Zeichen holen + c = peekChar(); + bIdentifierChar = BasicSimpleCharClass::isAlpha( c, true ); + if( bIdentifierChar ) + getChar(); } - else if ((c=='-')) + while( bIdentifierChar ); + reType = TT_PARAMETER; + } + else if(c == '?' && aLanguage == HIGHLIGHT_SQL) + { + reType = TT_PARAMETER; + } + else if(c == '-' && aLanguage == HIGHLIGHT_SQL) + { + c = peekChar(); + if (c == '-') { - sal_Unicode cPeekNext = peekChar(); - if (cPeekNext=='-') + // set position to the second "-" + getChar(); + do { - // Alle Zeichen bis Zeilen-Ende oder EOF entfernen - while( cPeekNext != CHAR_EOF && testCharFlags( cPeekNext, CHAR_EOL ) == sal_False ) - { - getChar(); - cPeekNext = peekChar(); - } - reType = TT_COMMENT; + getChar(); + c = peekChar(); } + while(c != CHAR_EOF && testCharFlags(c, CHAR_EOL) == sal_False); + + reType = TT_COMMENT; } - else if (c=='/') - { - sal_Unicode cPeekNext = peekChar(); - if (cPeekNext=='/') - { - // Alle Zeichen bis Zeilen-Ende oder EOF entfernen - while( cPeekNext != CHAR_EOF && testCharFlags( cPeekNext, CHAR_EOL ) == sal_False ) - { - getChar(); - cPeekNext = peekChar(); - } - reType = TT_COMMENT; - } - } else { - // Kommentar ? - if ( c == '\'' ) - { - c = getChar(); // '/' entfernen - - // Alle Zeichen bis Zeilen-Ende oder EOF entfernen - sal_Unicode cPeek = c; - while( cPeek != CHAR_EOF && testCharFlags( cPeek, CHAR_EOL ) == sal_False ) - { - getChar(); - cPeek = peekChar(); - } - - reType = TT_COMMENT; - } - - // Echter Operator, kann hier einfach behandelt werden, - // da nicht der wirkliche Operator, wie z.B. += interessiert, - // sondern nur die Tatsache, dass es sich um einen handelt. - if( reType != TT_COMMENT ) - { - reType = TT_OPERATOR; - } - + reType = TT_OPERATOR; } } - + else if((testCharFlags(c, CHAR_OPERATOR) == sal_True)) + { + reType = TT_OPERATOR; + } // Objekt-Trenner? Muss vor Number abgehandelt werden else if( c == '.' && ( peekChar() < '0' || peekChar() > '9' ) ) { @@ -602,7 +577,7 @@ sal_Bool SimpleTokenizer_Impl::getNextToken( /*out*/TokenTypes& reType, (bAfterExpChar && peekChar() == '-' ) ) // Nach Exponent auch +/- OK { - c = getChar(); // Zeichen lesen + c = getChar(); bAfterExpChar = ( c == 'e' || c == 'E' ); } } -- 1.7.4.4