diff options
author | Iain <qt-info@nokia.com> | 2009-08-21 13:23:16 (GMT) |
---|---|---|
committer | Iain <qt-info@nokia.com> | 2009-08-21 13:23:16 (GMT) |
commit | d2cfe342ff109e7135fe2fcb00f60d918a7bfaa5 (patch) | |
tree | 26a2edc99e561721fad57d27f84a2a6c0be73a3c /src/corelib/tools/qregexp.cpp | |
parent | 6df41a9378e39f4d46cee1a085463d55fe2af5aa (diff) | |
parent | ab1df6dea670a60bfef5efd81d6687f9534cfc5d (diff) | |
download | Qt-d2cfe342ff109e7135fe2fcb00f60d918a7bfaa5.zip Qt-d2cfe342ff109e7135fe2fcb00f60d918a7bfaa5.tar.gz Qt-d2cfe342ff109e7135fe2fcb00f60d918a7bfaa5.tar.bz2 |
Merge commit 'origin/master' into symbolVisibility
Diffstat (limited to 'src/corelib/tools/qregexp.cpp')
-rw-r--r-- | src/corelib/tools/qregexp.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index ed7fe9e..5e952ee 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -52,6 +52,7 @@ #include "qstringlist.h" #include "qstringmatcher.h" #include "qvector.h" +#include "private/qfunctions_p.h" #include <limits.h> @@ -832,7 +833,7 @@ struct QRegExpEngineKey } }; -bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key2) +Q_STATIC_GLOBAL_OPERATOR bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key2) { return key1.pattern == key2.pattern && key1.patternSyntax == key2.patternSyntax && key1.cs == key2.cs; @@ -1261,28 +1262,35 @@ struct QRegExpLookahead }; #endif -QRegExpEngine::QRegExpEngine(const QRegExpEngineKey &key) - : cs(key.cs), greedyQuantifiers(key.patternSyntax == QRegExp::RegExp2), - xmlSchemaExtensions(false) -{ - setup(); - - QString rx; +/*! \internal + convert the pattern string to the RegExp syntax. - switch (key.patternSyntax) { - case QRegExp::Wildcard: + This is also used by QScriptEngine::newRegExp to convert to a pattern that JavaScriptCore can understan + */ +Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &pattern, QRegExp::PatternSyntax patternSyntax) +{ + switch (patternSyntax) { #ifndef QT_NO_REGEXP_WILDCARD - rx = wc2rx(key.pattern); -#endif + case QRegExp::Wildcard: + return wc2rx(pattern); break; +#endif case QRegExp::FixedString: - rx = QRegExp::escape(key.pattern); + return QRegExp::escape(pattern); break; case QRegExp::W3CXmlSchema11: - xmlSchemaExtensions = true; default: - rx = key.pattern; + return pattern; } +} + +QRegExpEngine::QRegExpEngine(const QRegExpEngineKey &key) + : cs(key.cs), greedyQuantifiers(key.patternSyntax == QRegExp::RegExp2), + xmlSchemaExtensions(key.patternSyntax == QRegExp::W3CXmlSchema11) +{ + setup(); + + QString rx = qt_regexp_toCanonical(key.pattern, key.patternSyntax); valid = (parse(rx.unicode(), rx.length()) == rx.length()); if (!valid) { |