diff options
Diffstat (limited to 'src/tools/tqregexp.cpp')
| -rw-r--r-- | src/tools/tqregexp.cpp | 216 |
1 files changed, 108 insertions, 108 deletions
diff --git a/src/tools/tqregexp.cpp b/src/tools/tqregexp.cpp index 6ed3e3a15..5eddb8e0c 100644 --- a/src/tools/tqregexp.cpp +++ b/src/tools/tqregexp.cpp @@ -529,11 +529,11 @@ example, to match the Perl regexp <b>ro+?m</b> requires: \code TQRegExp rx( "ro+m" ); - rx.setMinimal( TRUE ); + rx.setMinimal( true ); \endcode The equivalent of Perl's \c{/i} option is - setCaseSensitive(FALSE). + setCaseSensitive(false). Perl's \c{/g} option can be emulated using a \link #cap_in_a_loop loop \endlink. @@ -694,10 +694,10 @@ \code TQRegExp rx( "*.html" ); // invalid regexp: * doesn't quantify anything - rx.setWildcard( TRUE ); // now it's a valid wildcard regexp - rx.exactMatch( "index.html" ); // returns TRUE - rx.exactMatch( "default.htm" ); // returns FALSE - rx.exactMatch( "readme.txt" ); // returns FALSE + rx.setWildcard( true ); // now it's a valid wildcard regexp + rx.exactMatch( "index.html" ); // returns true + rx.exactMatch( "default.htm" ); // returns false + rx.exactMatch( "readme.txt" ); // returns false \endcode Wildcard matching can be convenient because of its simplicity, but @@ -1219,7 +1219,7 @@ private: void parseExpression( Box *box ); int yyTok; // the last token read - bool yyMayCapture; // set this to FALSE to disable capturing + bool yyMayCapture; // set this to false to disable capturing /* This is the engine state during matching. @@ -1260,7 +1260,7 @@ TQRegExpEngine::TQRegExpEngine( const TQString& rx, bool caseSensitive ) valid = ( parse(rx.unicode(), rx.length()) == (int) rx.length() ); if ( !valid ) { #ifndef TQT_NO_REGEXP_OPTIM - trivial = FALSE; + trivial = false; #endif error( RXERR_LEFTDELIM ); } @@ -1280,7 +1280,7 @@ void TQRegExpEngine::match( const TQString& str, int pos, bool minimal, bool oneTest, int caretIndex, TQMemArray<int>& captured ) { - bool matched = FALSE; + bool matched = false; #ifndef TQT_NO_REGEXP_OPTIM if ( trivial && !oneTest ) { @@ -1483,9 +1483,9 @@ void TQRegExpEngine::addAnchors( int from, int to, int a ) void TQRegExpEngine::heuristicallyChooseHeuristic() { if ( minl == 0 ) { - useGoodStringHeuristic = FALSE; + useGoodStringHeuristic = false; } else if ( trivial ) { - useGoodStringHeuristic = TRUE; + useGoodStringHeuristic = true; } else { /* Magic formula: The good string has to constitute a good @@ -1566,7 +1566,7 @@ void TQRegExpEngine::dump() const void TQRegExpEngine::setup( bool caseSensitive ) { - s.setAutoDelete( TRUE ); + s.setAutoDelete( true ); s.resize( 32 ); ns = 0; #ifndef TQT_NO_REGEXP_CAPTURE @@ -1577,22 +1577,22 @@ void TQRegExpEngine::setup( bool caseSensitive ) officialncap = 0; ncap = 0; #ifndef TQT_NO_REGEXP_CCLASS - cl.setAutoDelete( TRUE ); + cl.setAutoDelete( true ); #endif #ifndef TQT_NO_REGEXP_LOOKAHEAD - ahead.setAutoDelete( TRUE ); + ahead.setAutoDelete( true ); #endif #ifndef TQT_NO_REGEXP_OPTIM - caretAnchored = TRUE; - trivial = TRUE; + caretAnchored = true; + trivial = true; #endif - valid = FALSE; + valid = false; cs = caseSensitive; #ifndef TQT_NO_REGEXP_BACKREF nbrefs = 0; #endif #ifndef TQT_NO_REGEXP_OPTIM - useGoodStringHeuristic = TRUE; + useGoodStringHeuristic = true; minl = 0; occ1.fill( 0, NumBadChars ); #endif @@ -1659,13 +1659,13 @@ bool TQRegExpEngine::isBetterCapture( const int *begin1, const int *end1, if ( delta != 0 ) return delta > 0; } - return FALSE; + return false; } #endif /* - Returns TRUE if anchor a matches at position mmPos + i in the input - string, otherwise FALSE. + Returns true if anchor a matches at position mmPos + i in the input + string, otherwise false. */ bool TQRegExpEngine::testAnchor( int i, int a, const int *capBegin ) { @@ -1680,24 +1680,24 @@ bool TQRegExpEngine::testAnchor( int i, int a, const int *capBegin ) if ( (a & Anchor_Caret) != 0 ) { if ( mmPos + i != mmCaretPos ) - return FALSE; + return false; } if ( (a & Anchor_Dollar) != 0 ) { if ( mmPos + i != mmLen ) - return FALSE; + return false; } #ifndef TQT_NO_REGEXP_ESCAPE if ( (a & (Anchor_Word | Anchor_NonWord)) != 0 ) { - bool before = FALSE; - bool after = FALSE; + bool before = false; + bool after = false; if ( mmPos + i != 0 ) before = isWord( mmIn[mmPos + i - 1] ); if ( mmPos + i != mmLen ) after = isWord( mmIn[mmPos + i] ); if ( (a & Anchor_Word) != 0 && (before == after) ) - return FALSE; + return false; if ( (a & Anchor_NonWord) != 0 && (before != after) ) - return FALSE; + return false; } #endif #ifndef TQT_NO_REGEXP_LOOKAHEAD @@ -1707,10 +1707,10 @@ bool TQRegExpEngine::testAnchor( int i, int a, const int *capBegin ) for ( j = 0; j < (int) ahead.size(); j++ ) { if ( (a & (Anchor_FirstLookahead << j)) != 0 ) { TQMemArray<int> captured; - ahead[j]->eng->match( cstr.string(), 0, TRUE, TRUE, + ahead[j]->eng->match( cstr.string(), 0, true, true, mmCaretPos - mmPos - i, captured ); if ( (captured[0] == 0) == ahead[j]->neg ) - return FALSE; + return false; } } } @@ -1720,12 +1720,12 @@ bool TQRegExpEngine::testAnchor( int i, int a, const int *capBegin ) for ( j = 0; j < nbrefs; j++ ) { if ( (a & (Anchor_BackRef1Empty << j)) != 0 ) { if ( capBegin[j] != EmptyCapture ) - return FALSE; + return false; } } #endif #endif - return TRUE; + return true; } #ifndef TQT_NO_REGEXP_OPTIM @@ -1746,12 +1746,12 @@ bool TQRegExpEngine::goodStringMatch() while ( mmPos <= to ) { if ( matchHere() ) - return TRUE; + return true; mmPos++; } k++; } - return FALSE; + return false; } bool TQRegExpEngine::badCharMatch() @@ -1782,7 +1782,7 @@ bool TQRegExpEngine::badCharMatch() } if ( mmPos > lastPos ) - return FALSE; + return false; for ( ;; ) { if ( ++slideNext >= mmSlideTabSize ) @@ -1793,7 +1793,7 @@ bool TQRegExpEngine::badCharMatch() mmSlideTab[slideHead] = 0; } else { if ( matchHere() ) - return TRUE; + return true; } if ( mmPos == lastPos ) @@ -1816,17 +1816,17 @@ bool TQRegExpEngine::badCharMatch() slideHead = slideNext; mmPos++; } - return FALSE; + return false; } #else bool TQRegExpEngine::bruteMatch() { while ( mmPos <= mmLen ) { if ( matchHere() ) - return TRUE; + return true; mmPos++; } - return FALSE; + return false; } #endif @@ -1837,7 +1837,7 @@ bool TQRegExpEngine::matchHere() { int ncur = 1, nnext = 0; int i = 0, j, k, m; - bool stop = FALSE; + bool stop = false; mmMatchLen = -1; mmOneTestMatchedLen = -1; @@ -1869,7 +1869,7 @@ bool TQRegExpEngine::matchHere() for ( k = 0; k < (int) outs.size(); k++ ) { int next = outs[k]; State *snext = s[next]; - bool in = TRUE; + bool in = true; #ifndef TQT_NO_REGEXP_BACKREF int needSomeSleep = 0; #endif @@ -1880,7 +1880,7 @@ bool TQRegExpEngine::matchHere() if ( scur->anchors != 0 ) { int a = at( *scur->anchors, next ); if ( a != 0 && !testAnchor(i, a, mmCurCapBegin + j * ncap) ) - in = FALSE; + in = false; } /* If indeed they are, check if the input character is @@ -1896,7 +1896,7 @@ bool TQRegExpEngine::matchHere() } else if ( next == FinalState ) { mmMatchLen = i; stop = mmMinimal; - in = TRUE; + in = true; } else if ( (m & CharClassBit) != 0 ) { #ifndef TQT_NO_REGEXP_CCLASS const CharClass *cc = cl[m ^ CharClassBit]; @@ -2021,11 +2021,11 @@ bool TQRegExpEngine::matchHere() if ( scur->reenter != 0 && (q = at(*scur->reenter, next)) != 0 ) { TQBitArray b; - b.fill( FALSE, nf ); - b.setBit( q, TRUE ); + b.fill( false, nf ); + b.setBit( q, true ); for ( int ell = q + 1; ell < nf; ell++ ) { if ( b.testBit(f[ell].parent) ) { - b.setBit( ell, TRUE ); + b.setBit( ell, true ); cap = f[ell].capture; if ( cap >= 0 ) { capBegin[cap] = EmptyCapture; @@ -2138,7 +2138,7 @@ bool TQRegExpEngine::matchHere() int next = zzZ[0]; int *capBegin = zzZ + 1; int *capEnd = zzZ + 1 + ncap; - bool copyOver = TRUE; + bool copyOver = true; if ( (m = mmInNextStack[zzZ[0]]) == -1 ) { m = nnext++; @@ -2169,7 +2169,7 @@ bool TQRegExpEngine::matchHere() && mmSleeping.isEmpty() #endif ) - stop = TRUE; + stop = true; tqSwap( mmCurStack, mmNextStack ); #ifndef TQT_NO_REGEXP_CAPTURE @@ -2199,7 +2199,7 @@ bool TQRegExpEngine::matchHere() #ifndef TQT_NO_REGEXP_CCLASS TQRegExpEngine::CharClass::CharClass() - : c( 0 ), n( FALSE ) + : c( 0 ), n( false ) { #ifndef TQT_NO_REGEXP_OPTIM occ1.fill( NoOccurrence, NumBadChars ); @@ -2222,7 +2222,7 @@ void TQRegExpEngine::CharClass::clear() { c = 0; r.resize( 0 ); - n = FALSE; + n = false; } void TQRegExpEngine::CharClass::setNegative( bool negative ) @@ -2818,7 +2818,7 @@ int TQRegExpEngine::getToken() return Tok_Quantifier; case '.': #ifndef TQT_NO_REGEXP_CCLASS - yyCharClass->setNegative( TRUE ); + yyCharClass->setNegative( true ); #endif return Tok_CharClass; case '?': @@ -2828,19 +2828,19 @@ int TQRegExpEngine::getToken() case '[': #ifndef TQT_NO_REGEXP_CCLASS if ( yyCh == '^' ) { - yyCharClass->setNegative( TRUE ); + yyCharClass->setNegative( true ); yyCh = getChar(); } - charPending = FALSE; - rangePending = FALSE; + charPending = false; + rangePending = false; do { if ( yyCh == '-' && charPending && !rangePending ) { - rangePending = TRUE; + rangePending = true; yyCh = getChar(); } else { if ( charPending && !rangePending ) { yyCharClass->addSingleton( pendingCh ); - charPending = FALSE; + charPending = false; } if ( yyCh == '\\' ) { yyCh = getChar(); @@ -2855,17 +2855,17 @@ int TQRegExpEngine::getToken() if ( rangePending ) { yyCharClass->addSingleton( '-' ); yyCharClass->addSingleton( pendingCh ); - charPending = FALSE; - rangePending = FALSE; + charPending = false; + rangePending = false; } } else if ( (tok & Tok_Char) != 0 ) { if ( rangePending ) { yyCharClass->addRange( pendingCh, tok ^ Tok_Char ); - charPending = FALSE; - rangePending = FALSE; + charPending = false; + rangePending = false; } else { pendingCh = tok ^ Tok_Char; - charPending = TRUE; + charPending = true; } } else { error( RXERR_CHARCLASS ); @@ -2922,17 +2922,17 @@ int TQRegExpEngine::getToken() int TQRegExpEngine::parse( const TQChar *pattern, int len ) { - valid = TRUE; + valid = true; startTokenizer( pattern, len ); yyTok = getToken(); #ifndef TQT_NO_REGEXP_CAPTURE - yyMayCapture = TRUE; + yyMayCapture = true; #else - yyMayCapture = FALSE; + yyMayCapture = false; #endif #ifndef TQT_NO_REGEXP_CAPTURE - int atom = startAtom( FALSE ); + int atom = startAtom( false ); #endif CharClass anything; Box box( this ); // create InitialState @@ -3002,7 +3002,7 @@ int TQRegExpEngine::parse( const TQChar *pattern, int len ) (*a & Anchor_Alternation) != 0 || #endif (*a & Anchor_Caret) == 0 ) { - caretAnchored = FALSE; + caretAnchored = false; break; } } @@ -3023,7 +3023,7 @@ void TQRegExpEngine::parseAtom( Box *box ) box->set( TQChar(yyTok ^ Tok_Char) ); } else { #ifndef TQT_NO_REGEXP_OPTIM - trivial = FALSE; + trivial = false; #endif switch ( yyTok ) { case Tok_Dollar: @@ -3113,7 +3113,7 @@ void TQRegExpEngine::parseFactor( Box *box ) if ( yyTok == Tok_Quantifier ) { #ifndef TQT_NO_REGEXP_OPTIM - trivial = FALSE; + trivial = false; #endif if ( yyMaxRep == InftyRep ) { box->plus( atom ); @@ -3126,7 +3126,7 @@ void TQRegExpEngine::parseFactor( Box *box ) box->opt(); #ifndef TQT_NO_REGEXP_INTERVAL - yyMayCapture = FALSE; + yyMayCapture = false; int alpha = ( yyMinRep == 0 ) ? 0 : yyMinRep - 1; int beta = ( yyMaxRep == InftyRep ) ? 0 : yyMaxRep - ( alpha + 1 ); @@ -3177,7 +3177,7 @@ void TQRegExpEngine::parseExpression( Box *box ) parseTerm( box ); while ( yyTok == Tok_Bar ) { #ifndef TQT_NO_REGEXP_OPTIM - trivial = FALSE; + trivial = false; #endif Box rightBox( this ); yyTok = getToken(); @@ -3257,7 +3257,7 @@ static void regexpEngine( TQRegExpEngine *&eng, const TQString &pattern, { if ( engineCache == 0 ) { engineCache = new TQCache<TQRegExpEngine>; - engineCache->setAutoDelete( TRUE ); + engineCache->setAutoDelete( true ); # ifdef TQT_THREAD_SUPPORT engineCaches.setLocalData(engineCache); # else @@ -3302,17 +3302,17 @@ TQRegExp::TQRegExp() { priv = new TQRegExpPrivate; #ifndef TQT_NO_REGEXP_WILDCARD - priv->wc = FALSE; + priv->wc = false; #endif - priv->min = FALSE; - priv->cs = TRUE; + priv->min = false; + priv->cs = true; } /*! Constructs a regular expression object for the given \a pattern string. The pattern must be given using wildcard notation if \a - wildcard is TRUE (default is FALSE). The pattern is case - sensitive, unless \a caseSensitive is FALSE. Matching is greedy + wildcard is true (default is false). The pattern is case + sensitive, unless \a caseSensitive is false. Matching is greedy (maximal), but can be changed by calling setMinimal(). \sa setPattern() setCaseSensitive() setWildcard() setMinimal() @@ -3325,7 +3325,7 @@ TQRegExp::TQRegExp( const TQString& pattern, bool caseSensitive, bool wildcard ) #ifndef TQT_NO_REGEXP_WILDCARD priv->wc = wildcard; #endif - priv->min = FALSE; + priv->min = false; priv->cs = caseSensitive; } @@ -3378,8 +3378,8 @@ TQRegExp& TQRegExp::operator=( const TQRegExp& rx ) } /*! - Returns TRUE if this regular expression is equal to \a rx; - otherwise returns FALSE. + Returns true if this regular expression is equal to \a rx; + otherwise returns false. Two TQRegExp objects are equal if they have the same pattern strings and the same settings for case sensitivity, wildcard and @@ -3398,18 +3398,18 @@ bool TQRegExp::operator==( const TQRegExp& rx ) const /*! \fn bool TQRegExp::operator!=( const TQRegExp& rx ) const - Returns TRUE if this regular expression is not equal to \a rx; - otherwise returns FALSE. + Returns true if this regular expression is not equal to \a rx; + otherwise returns false. \sa operator==() */ /*! - Returns TRUE if the pattern string is empty; otherwise returns - FALSE. + Returns true if the pattern string is empty; otherwise returns + false. If you call exactMatch() with an empty pattern on an empty string - it will return TRUE; otherwise it returns FALSE since it operates + it will return true; otherwise it returns false since it operates over the whole string. If you call search() with an empty pattern on \e any string it will return the start offset (0 by default) because the empty pattern matches the 'emptiness' at the start of @@ -3425,8 +3425,8 @@ bool TQRegExp::isEmpty() const } /*! - Returns TRUE if the regular expression is valid; otherwise returns - FALSE. An invalid regular expression never matches. + Returns true if the regular expression is valid; otherwise returns + false. An invalid regular expression never matches. The pattern <b>[a-z</b> is an example of an invalid pattern, since it lacks a closing square bracket. @@ -3440,7 +3440,7 @@ bool TQRegExp::isEmpty() const bool TQRegExp::isValid() const { if ( priv->pattern.isEmpty() ) { - return TRUE; + return true; } else { prepareEngine(); return eng->isValid(); @@ -3474,8 +3474,8 @@ void TQRegExp::setPattern( const TQString& pattern ) } /*! - Returns TRUE if case sensitivity is enabled; otherwise returns - FALSE. The default is TRUE. + Returns true if case sensitivity is enabled; otherwise returns + false. The default is true. \sa setCaseSensitive() */ @@ -3487,7 +3487,7 @@ bool TQRegExp::caseSensitive() const /*! Sets case sensitive matching to \a sensitive. - If \a sensitive is TRUE, <b>\\.txt$</b> matches \c{readme.txt} but + If \a sensitive is true, <b>\\.txt$</b> matches \c{readme.txt} but not \c{README.TXT}. \sa caseSensitive() @@ -3502,8 +3502,8 @@ void TQRegExp::setCaseSensitive( bool sensitive ) #ifndef TQT_NO_REGEXP_WILDCARD /*! - Returns TRUE if wildcard mode is enabled; otherwise returns FALSE. - The default is FALSE. + Returns true if wildcard mode is enabled; otherwise returns false. + The default is false. \sa setWildcard() */ @@ -3514,9 +3514,9 @@ bool TQRegExp::wildcard() const /*! Sets the wildcard mode for the regular expression. The default is - FALSE. + false. - Setting \a wildcard to TRUE enables simple shell-like wildcard + Setting \a wildcard to true enables simple shell-like wildcard matching. (See \link #wildcard-matching wildcard matching (globbing) \endlink.) @@ -3535,8 +3535,8 @@ void TQRegExp::setWildcard( bool wildcard ) #endif /*! - Returns TRUE if minimal (non-greedy) matching is enabled; - otherwise returns FALSE. + Returns true if minimal (non-greedy) matching is enabled; + otherwise returns false. \sa setMinimal() */ @@ -3546,7 +3546,7 @@ bool TQRegExp::minimal() const } /*! - Enables or disables minimal matching. If \a minimal is FALSE, + Enables or disables minimal matching. If \a minimal is false, matching is greedy (maximal) which is the default. For example, suppose we have the input string "We must be @@ -3568,8 +3568,8 @@ void TQRegExp::setMinimal( bool minimal ) } /*! - Returns TRUE if \a str is matched exactly by this regular - expression; otherwise returns FALSE. You can determine how much of + Returns true if \a str is matched exactly by this regular + expression; otherwise returns false. You can determine how much of the string was matched by calling matchedLength(). For a given regexp string, R, exactMatch("R") is the equivalent of @@ -3578,8 +3578,8 @@ void TQRegExp::setMinimal( bool minimal ) sets matchedLength() differently. For example, if the regular expression is <b>blue</b>, then - exactMatch() returns TRUE only for input \c blue. For inputs \c - bluebell, \c blutak and \c lightblue, exactMatch() returns FALSE + exactMatch() returns true only for input \c blue. For inputs \c + bluebell, \c blutak and \c lightblue, exactMatch() returns false and matchedLength() will return 4, 3 and 0 respectively. Although const, this function sets matchedLength(), @@ -3590,13 +3590,13 @@ void TQRegExp::setMinimal( bool minimal ) bool TQRegExp::exactMatch( const TQString& str ) const { prepareEngineForMatch( str ); - eng->match( str, 0, priv->min, TRUE, 0, priv->captured ); + eng->match( str, 0, priv->min, true, 0, priv->captured ); if ( priv->captured[1] == (int) str.length() ) { - return TRUE; + return true; } else { priv->captured[0] = 0; priv->captured[1] = eng->partialMatchLength(); - return FALSE; + return false; } } @@ -3609,7 +3609,7 @@ bool TQRegExp::exactMatch( const TQString& str ) const The length of the match is stored in \a *len, unless \a len is a null pointer. - If \a indexIsStart is TRUE (the default), the position \a index in + If \a indexIsStart is true (the default), the position \a index in the string will match the start of string anchor, <b>^</b>, in the regexp, if present. Otherwise, position 0 in \a str will match. @@ -3671,7 +3671,7 @@ int TQRegExp::search( const TQString& str, int offset, CaretMode caretMode ) con prepareEngineForMatch( str ); if ( offset < 0 ) offset += str.length(); - eng->match( str, offset, priv->min, FALSE, caretIndex(offset, caretMode), + eng->match( str, offset, priv->min, false, caretIndex(offset, caretMode), priv->captured ); return priv->captured[0]; } @@ -3715,7 +3715,7 @@ int TQRegExp::searchRev( const TQString& str, int offset, } while ( offset >= 0 ) { - eng->match( str, offset, priv->min, TRUE, caretIndex(offset, caretMode), + eng->match( str, offset, priv->min, true, caretIndex(offset, caretMode), priv->captured ); if ( priv->captured[0] == offset ) return offset; @@ -3956,7 +3956,7 @@ void TQRegExp::prepareEngine() const : priv->pattern; TQRegExp *that = (TQRegExp *) this; // that->eng = newEngine( priv->rxpattern, priv->cs ); - regexpEngine( that->eng, priv->rxpattern, priv->cs, FALSE ); + regexpEngine( that->eng, priv->rxpattern, priv->cs, false ); priv->captured.detach(); priv->captured.fill( -1, 2 + 2 * eng->numCaptures() ); } @@ -3976,7 +3976,7 @@ void TQRegExp::prepareEngineForMatch( const TQString& str ) const void TQRegExp::invalidateEngine() { if ( eng != 0 ) { - regexpEngine( eng, priv->rxpattern, priv->cs, TRUE ); + regexpEngine( eng, priv->rxpattern, priv->cs, true ); priv->rxpattern = TQString(); eng = 0; } |
