summaryrefslogtreecommitdiffstats
path: root/src/xmlpatterns/functions
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmlpatterns/functions')
-rw-r--r--src/xmlpatterns/functions/qpatternplatform.cpp21
-rw-r--r--src/xmlpatterns/functions/qpatternplatform_p.h18
2 files changed, 26 insertions, 13 deletions
diff --git a/src/xmlpatterns/functions/qpatternplatform.cpp b/src/xmlpatterns/functions/qpatternplatform.cpp
index 74414f4..5339f28 100644
--- a/src/xmlpatterns/functions/qpatternplatform.cpp
+++ b/src/xmlpatterns/functions/qpatternplatform.cpp
@@ -168,8 +168,15 @@ void PatternPlatform::applyFlags(const Flags flags, QRegExp &patternP)
// TODO Apply the other flags, like 'x'.
}
+QRegExp PatternPlatform::parsePattern(const QString &pattern,
+ const ReportContext::Ptr &context) const
+{
+ return parsePattern(pattern, context, this);
+}
+
QRegExp PatternPlatform::parsePattern(const QString &patternP,
- const DynamicContext::Ptr &context) const
+ const ReportContext::Ptr &context,
+ const SourceLocationReflection *const location)
{
if(patternP == QLatin1String("(.)\\3") ||
patternP == QLatin1String("\\3") ||
@@ -177,7 +184,7 @@ QRegExp PatternPlatform::parsePattern(const QString &patternP,
{
context->error(QLatin1String("We don't want to hang infinitely on K2-MatchesFunc-9, "
"10 and 11. See Trolltech task 148505."),
- ReportContext::FOER0000, this);
+ ReportContext::FOER0000, location);
return QRegExp();
}
@@ -189,14 +196,8 @@ QRegExp PatternPlatform::parsePattern(const QString &patternP,
* QChar::category(). */
rewrittenPattern.replace(QLatin1String("[\\i-[:]]"), QLatin1String("[a-zA-Z_]"));
rewrittenPattern.replace(QLatin1String("[\\c-[:]]"), QLatin1String("[a-zA-Z0-9_\\-\\.]"));
- rewrittenPattern.replace(QLatin1String("\\i"), QLatin1String("[a-zA-Z:_]"));
- rewrittenPattern.replace(QLatin1String("\\c"), QLatin1String("[a-zA-Z0-9:_\\-\\.]"));
- rewrittenPattern.replace(QLatin1String("\\p{L}"), QLatin1String("[a-zA-Z]"));
- rewrittenPattern.replace(QLatin1String("\\p{Lu}"), QLatin1String("[A-Z]"));
- rewrittenPattern.replace(QLatin1String("\\p{Ll}"), QLatin1String("[a-z]"));
- rewrittenPattern.replace(QLatin1String("\\p{Nd}"), QLatin1String("[0-9]"));
- QRegExp retval(rewrittenPattern);
+ QRegExp retval(rewrittenPattern, Qt::CaseSensitive, QRegExp::W3CXmlSchema11);
if(retval.isValid())
return retval;
@@ -204,7 +205,7 @@ QRegExp PatternPlatform::parsePattern(const QString &patternP,
{
context->error(QtXmlPatterns::tr("%1 is an invalid regular expression pattern: %2")
.arg(formatExpression(patternP), retval.errorString()),
- ReportContext::FORX0002, this);
+ ReportContext::FORX0002, location);
return QRegExp();
}
}
diff --git a/src/xmlpatterns/functions/qpatternplatform_p.h b/src/xmlpatterns/functions/qpatternplatform_p.h
index 3f4b18e..76f5332 100644
--- a/src/xmlpatterns/functions/qpatternplatform_p.h
+++ b/src/xmlpatterns/functions/qpatternplatform_p.h
@@ -122,6 +122,14 @@ namespace QPatternist
*/
inline int captureCount() const;
+ /**
+ * @short Parses pattern
+ */
+ static QRegExp parsePattern(const QString &pattern,
+ const ReportContext::Ptr &context,
+ const SourceLocationReflection *const location);
+
+
protected:
/**
* @short This constructor is protected, because this class is supposed to be sub-classed.
@@ -146,14 +154,18 @@ namespace QPatternist
};
typedef QFlags<PreCompiledPart> PreCompiledParts;
+ /**
+ * @short Calls the public parsePattern() function and passes in @c
+ * this as the location.
+ */
+ inline QRegExp parsePattern(const QString &pattern,
+ const ReportContext::Ptr &context) const;
+
Q_DISABLE_COPY(PatternPlatform)
Flags parseFlags(const QString &flags,
const DynamicContext::Ptr &context) const;
- QRegExp parsePattern(const QString &pattern,
- const DynamicContext::Ptr &context) const;
-
static void applyFlags(const Flags flags, QRegExp &pattern);
/**