-rw-r--r-- | qmake/tools/qregexp.cpp | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/qmake/tools/qregexp.cpp b/qmake/tools/qregexp.cpp index 500efed..0c1f060 100644 --- a/qmake/tools/qregexp.cpp +++ b/qmake/tools/qregexp.cpp | |||
@@ -265,3 +265,3 @@ | |||
265 | \row \i <b>\\d</b> | 265 | \row \i <b>\\d</b> |
266 | \i This matches a digit (see QChar::isDigit()). | 266 | \i This matches a digit (QChar::isDigit()). |
267 | \row \i <b>\\D</b> | 267 | \row \i <b>\\D</b> |
@@ -269,3 +269,3 @@ | |||
269 | \row \i <b>\\s</b> | 269 | \row \i <b>\\s</b> |
270 | \i This matches a whitespace (see QChar::isSpace()). | 270 | \i This matches a whitespace (QChar::isSpace()). |
271 | \row \i <b>\\S</b> | 271 | \row \i <b>\\S</b> |
@@ -273,3 +273,3 @@ | |||
273 | \row \i <b>\\w</b> | 273 | \row \i <b>\\w</b> |
274 | \i This matches a word character (see QChar::isLetterOrNumber()). | 274 | \i This matches a word character (QChar::isLetterOrNumber() or '_'). |
275 | \row \i <b>\\W</b> | 275 | \row \i <b>\\W</b> |
@@ -549,3 +549,10 @@ | |||
549 | Perl's extended \c{/x} syntax is not supported, nor are | 549 | Perl's extended \c{/x} syntax is not supported, nor are |
550 | regexp comments (?#comment) or directives, e.g. (?i). | 550 | directives, e.g. (?i), or regexp comments, e.g. (?#comment). On |
551 | the other hand, C++'s rules for literal strings can be used to | ||
552 | achieve the same: | ||
553 | \code | ||
554 | QRegExp mark( "\\b" // word boundary | ||
555 | "[Mm]ark" // the word we want to match | ||
556 | ); | ||
557 | \endcode | ||
551 | 558 | ||
@@ -679,7 +686,7 @@ | |||
679 | \code | 686 | \code |
680 | QRegExp rx( "*.html" ); // invalid regexp: * doesn't quantify anything | 687 | QRegExp rx( "*.html" ); // invalid regexp: * doesn't quantify anything |
681 | rx.setWildcard( TRUE ); // now it's a valid wildcard regexp | 688 | rx.setWildcard( TRUE ); // now it's a valid wildcard regexp |
682 | rx.search( "index.html" ); // returns 0 (matched at position 0) | 689 | rx.exactMatch( "index.html" ); // returns TRUE |
683 | rx.search( "default.htm" ); // returns -1 (no match) | 690 | rx.exactMatch( "default.htm" ); // returns FALSE |
684 | rx.search( "readme.txt" ); // returns -1 (no match) | 691 | rx.exactMatch( "readme.txt" ); // returns FALSE |
685 | \endcode | 692 | \endcode |
@@ -717,2 +724,7 @@ const int EOS = -1; | |||
717 | 724 | ||
725 | static bool isWord( QChar ch ) | ||
726 | { | ||
727 | return ch.isLetterOrNumber() || ch == QChar( '_' ); | ||
728 | } | ||
729 | |||
718 | /* | 730 | /* |
@@ -1682,5 +1694,5 @@ bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin ) | |||
1682 | if ( mmPos + i != 0 ) | 1694 | if ( mmPos + i != 0 ) |
1683 | before = mmIn[mmPos + i - 1].isLetterOrNumber(); | 1695 | before = isWord( mmIn[mmPos + i - 1] ); |
1684 | if ( mmPos + i != mmLen ) | 1696 | if ( mmPos + i != mmLen ) |
1685 | after = mmIn[mmPos + i].isLetterOrNumber(); | 1697 | after = isWord( mmIn[mmPos + i] ); |
1686 | if ( (a & Anchor_Word) != 0 && (before == after) ) | 1698 | if ( (a & Anchor_Word) != 0 && (before == after) ) |
@@ -2634,3 +2646,10 @@ int QRegExpEngine::getEscape() | |||
2634 | // see QChar::isLetterOrNumber() | 2646 | // see QChar::isLetterOrNumber() |
2635 | yyCharClass->addCategories( 0x7ff07f8f ); | 2647 | yyCharClass->addCategories( 0x7fe07f8f ); |
2648 | yyCharClass->addRange( 0x203f, 0x2040 ); | ||
2649 | yyCharClass->addSingleton( 0x2040 ); | ||
2650 | yyCharClass->addSingleton( 0x30fb ); | ||
2651 | yyCharClass->addRange( 0xfe33, 0xfe34 ); | ||
2652 | yyCharClass->addRange( 0xfe4d, 0xfe4f ); | ||
2653 | yyCharClass->addSingleton( 0xff3f ); | ||
2654 | yyCharClass->addSingleton( 0xff65 ); | ||
2636 | return Tok_CharClass; | 2655 | return Tok_CharClass; |
@@ -2654,2 +2673,3 @@ int QRegExpEngine::getEscape() | |||
2654 | yyCharClass->addCategories( 0x000f8070 ); | 2673 | yyCharClass->addCategories( 0x000f8070 ); |
2674 | yyCharClass->addSingleton( 0x005f ); // '_' | ||
2655 | return Tok_CharClass; | 2675 | return Tok_CharClass; |
@@ -3185,3 +3205,4 @@ static QRegExpEngine *newEngine( const QString& pattern, bool caseSensitive ) | |||
3185 | #ifdef QT_THREAD_SUPPORT | 3205 | #ifdef QT_THREAD_SUPPORT |
3186 | QMutexLocker locker( qt_global_mutexpool->get( &engineCache ) ); | 3206 | QMutexLocker locker( qt_global_mutexpool ? |
3207 | qt_global_mutexpool->get( &engineCache ) : 0 ); | ||
3187 | #endif | 3208 | #endif |
@@ -3201,7 +3222,8 @@ static void derefEngine( QRegExpEngine *eng, const QString& pattern ) | |||
3201 | { | 3222 | { |
3202 | if ( eng != 0 && eng->deref() ) { | ||
3203 | #ifndef QT_NO_REGEXP_OPTIM | ||
3204 | #ifdef QT_THREAD_SUPPORT | 3223 | #ifdef QT_THREAD_SUPPORT |
3205 | QMutexLocker locker( qt_global_mutexpool->get( &engineCache ) ); | 3224 | QMutexLocker locker( qt_global_mutexpool ? |
3225 | qt_global_mutexpool->get( &engineCache ) : 0 ); | ||
3206 | #endif | 3226 | #endif |
3227 | if ( eng != 0 && eng->deref() ) { | ||
3228 | #ifndef QT_NO_REGEXP_OPTIM | ||
3207 | if ( engineCache == 0 ) { | 3229 | if ( engineCache == 0 ) { |
@@ -3567,9 +3589,2 @@ int QRegExp::match( const QString& str, int index, int *len, | |||
3567 | 3589 | ||
3568 | /*! | ||
3569 | \overload | ||
3570 | |||
3571 | This convenience function searches with a \c CaretMode of \c | ||
3572 | CaretAtZero which is the most common usage. | ||
3573 | */ | ||
3574 | |||
3575 | int QRegExp::search( const QString& str, int offset ) const | 3590 | int QRegExp::search( const QString& str, int offset ) const |
@@ -3627,9 +3642,2 @@ int QRegExp::search( const QString& str, int offset, CaretMode caretMode ) const | |||
3627 | 3642 | ||
3628 | /*! | ||
3629 | \overload | ||
3630 | |||
3631 | This convenience function searches with a \c CaretMode of \c | ||
3632 | CaretAtZero which is the most common usage. | ||
3633 | */ | ||
3634 | |||
3635 | int QRegExp::searchRev( const QString& str, int offset ) const | 3643 | int QRegExp::searchRev( const QString& str, int offset ) const |
@@ -3696,3 +3704,3 @@ int QRegExp::matchedLength() const | |||
3696 | #ifndef QT_NO_REGEXP_CAPTURE | 3704 | #ifndef QT_NO_REGEXP_CAPTURE |
3697 | /*! | 3705 | /*! |
3698 | Returns the number of captures contained in the regular expression. | 3706 | Returns the number of captures contained in the regular expression. |