summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2011-10-06 14:56:24 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-06 19:24:26 +0200
commit2bf2bb3daf32935e3642447d40732998df819556 (patch)
treed12419f56ded95b6eec385a79597bdb0b0898a9b
parentdf08cb70906abce38cd54fb38f5b349424bd31a9 (diff)
fix QChar::isSpace() to handle codepoint U+0085
according to the Unicode specs, code point U+0085 should be treated like a white space character (an exceptional Cc one) Change-Id: Ib17ae0c4d3cdafe667cafa38b645138ef24c238c Merge-request: 32 Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com> Reviewed-on: http://codereview.qt-project.org/6158 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
-rw-r--r--src/corelib/tools/qchar.h2
-rw-r--r--src/corelib/tools/qregexp.cpp4
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp12
3 files changed, 15 insertions, 3 deletions
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index b82addb4c5..697b506ca3 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -234,7 +234,7 @@ public:
bool isPunct() const;
inline bool isSpace() const {
return ucs == 0x20 || (ucs <= 0x0D && ucs >= 0x09)
- || (ucs > 127 && isSpace(ucs));
+ || (ucs > 127 && (ucs == 0x0085 || isSpace(ucs)));
}
bool isMark() const;
inline bool isLetter() const {
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 5e2e56ea34..59a54f3eb7 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -2950,7 +2950,8 @@ int QRegExpEngine::getEscape()
FLAG(QChar::Other_Control)));
yyCharClass->addRange(0x0000, 0x0008);
yyCharClass->addRange(0x000e, 0x001f);
- yyCharClass->addRange(0x007f, 0x009f);
+ yyCharClass->addRange(0x007f, 0x0084);
+ yyCharClass->addRange(0x0086, 0x009f);
return Tok_CharClass;
case 'W':
// see QChar::isLetterOrNumber() and QChar::isMark()
@@ -2991,6 +2992,7 @@ int QRegExpEngine::getEscape()
FLAG(QChar::Separator_Line) |
FLAG(QChar::Separator_Paragraph));
yyCharClass->addRange(0x0009, 0x000d);
+ yyCharClass->addSingleton(0x0085);
return Tok_CharClass;
case 'w':
// see QChar::isLetterOrNumber() and QChar::isMark()
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index 195abcd578..7f5747120c 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -84,6 +84,7 @@ private slots:
void isLower();
void isSpace_data();
void isSpace();
+ void isSpaceSpecial();
void isTitle();
void category();
void direction();
@@ -343,7 +344,7 @@ void tst_QChar::isSpace_data()
QTest::addColumn<bool>("expected");
for (ushort ucs = 0; ucs < 256; ++ucs) {
- bool isSpace = (ucs <= 0x0D && ucs >= 0x09) || ucs == 0x20 || ucs == 0xA0;
+ bool isSpace = (ucs <= 0x0D && ucs >= 0x09) || ucs == 0x20 || ucs == 0xA0 || ucs == 0x85;
QString tag = QString::fromLatin1("0x%0").arg(QString::number(ucs, 16));
QTest::newRow(tag.toLatin1()) << ucs << isSpace;
}
@@ -356,6 +357,15 @@ void tst_QChar::isSpace()
QCOMPARE(QChar(ucs).isSpace(), expected);
}
+void tst_QChar::isSpaceSpecial()
+{
+ QVERIFY(!QChar(QChar::Null).isSpace());
+ QVERIFY(QChar(QChar::Nbsp).isSpace());
+ QVERIFY(QChar(QChar::ParagraphSeparator).isSpace());
+ QVERIFY(QChar(QChar::LineSeparator).isSpace());
+ QVERIFY(QChar(0x1680).isSpace());
+}
+
void tst_QChar::isTitle()
{
for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {