if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative());
// fall through
+ } else {
+ break;
}
case 'i':
if (xmlSchemaExtensions) {
yyCharClass->addRange(0xf900, 0xfdcf);
yyCharClass->addRange(0xfdf0, 0xfffd);
yyCharClass->addRange((ushort)0x10000, (ushort)0xeffff);
+ return Tok_CharClass;
+ } else {
+ break;
}
- return Tok_CharClass;
case 'C':
if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative());
// fall through
+ } else {
+ break;
}
case 'c':
if (xmlSchemaExtensions) {
yyCharClass->addRange((ushort)0x10000, (ushort)0xeffff);
yyCharClass->addRange(0x0300, 0x036f);
yyCharClass->addRange(0x203f, 0x2040);
+ return Tok_CharClass;
+ } else {
+ break;
}
- return Tok_CharClass;
case 'P':
if (xmlSchemaExtensions) {
yyCharClass->setNegative(!yyCharClass->negative());
// fall through
+ } else {
+ break;
}
case 'p':
if (xmlSchemaExtensions) {
} else {
error(RXERR_CATEGORY);
}
+ return Tok_CharClass;
+ } else {
+ break;
}
- return Tok_CharClass;
#endif
#ifndef QT_NO_REGEXP_ESCAPE
case 'x':
return Tok_Char | val;
#endif
default:
- if (prevCh >= '1' && prevCh <= '9') {
+ break;
+ }
+ if (prevCh >= '1' && prevCh <= '9') {
#ifndef QT_NO_REGEXP_BACKREF
- val = prevCh - '0';
- while (yyCh >= '0' && yyCh <= '9') {
- val = (val * 10) + (yyCh - '0');
- yyCh = getChar();
- }
- return Tok_BackRef | val;
+ val = prevCh - '0';
+ while (yyCh >= '0' && yyCh <= '9') {
+ val = (val * 10) + (yyCh - '0');
+ yyCh = getChar();
+ }
+ return Tok_BackRef | val;
#else
- error(RXERR_DISABLED);
+ error(RXERR_DISABLED);
#endif
- }
- return Tok_Char | prevCh;
}
+ return Tok_Char | prevCh;
}
#ifndef QT_NO_REGEXP_INTERVAL
void interval();
void validityCheck_data();
void validityCheck();
+ void escapeSequences();
};
// Testing get/set functions
QCOMPARE(rx2.cap(), QString(""));
}
+void tst_QRegExp::escapeSequences()
+{
+ QString perlSyntaxSpecialChars("0123456789afnrtvbBdDwWsSx\\|[]{}()^$?+*");
+ QString w3cXmlSchema11SyntaxSpecialChars("cCiIpP"); // as well as the perl ones
+ for (int i = ' '; i <= 127; ++i) {
+ QLatin1Char c(i);
+ if (perlSyntaxSpecialChars.indexOf(c) == -1) {
+ QRegExp rx(QString("\\%1").arg(c), Qt::CaseSensitive, QRegExp::RegExp);
+ // we'll never have c == 'a' since it's a special character
+ QString s = QString("aaa%1aaa").arg(c);
+ QCOMPARE(rx.indexIn(s), 3);
+
+ rx.setPatternSyntax(QRegExp::RegExp2);
+ QCOMPARE(rx.indexIn(s), 3);
+
+ if (w3cXmlSchema11SyntaxSpecialChars.indexOf(c) == -1) {
+ rx.setPatternSyntax(QRegExp::W3CXmlSchema11);
+ QCOMPARE(rx.indexIn(s), 3);
+ }
+ }
+ }
+}
+
QTEST_APPLESS_MAIN(tst_QRegExp)
#include "tst_qregexp.moc"