Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qcollator_icu.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | void QCollatorPrivate::init() | - | ||||||||||||
10 | { | - | ||||||||||||
11 | cleanup(); | - | ||||||||||||
12 | - | |||||||||||||
13 | UErrorCode status = U_ZERO_ERROR; | - | ||||||||||||
14 | QByteArray name = locale.bcp47Name().replace(QLatin1Char('-'), QLatin1Char('_')).toLatin1(); | - | ||||||||||||
15 | collator = ucol_open_52(name.constData(), &status); | - | ||||||||||||
16 | if (U_FAILURE(status)
| 0-336 | ||||||||||||
17 | QMessageLogger(__FILE__, 62, __PRETTY_FUNCTION__).warning("Could not create collator: %d", status); | - | ||||||||||||
18 | collator = 0; | - | ||||||||||||
19 | dirty = false; | - | ||||||||||||
20 | return; never executed: return; | 0 | ||||||||||||
21 | } | - | ||||||||||||
22 | - | |||||||||||||
23 | - | |||||||||||||
24 | ucol_setAttribute_52(collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); | - | ||||||||||||
25 | UColAttributeValue val = (
| 138-198 | ||||||||||||
26 | - | |||||||||||||
27 | status = U_ZERO_ERROR; | - | ||||||||||||
28 | ucol_setAttribute_52(collator, UCOL_STRENGTH, val, &status); | - | ||||||||||||
29 | if (U_FAILURE(status)
| 0-336 | ||||||||||||
30 | QMessageLogger(__FILE__, 83, __PRETTY_FUNCTION__).warning("ucol_setAttribute: Case First failed: %d", status); never executed: QMessageLogger(__FILE__, 83, __PRETTY_FUNCTION__).warning("ucol_setAttribute: Case First failed: %d", status); | 0 | ||||||||||||
31 | - | |||||||||||||
32 | status = U_ZERO_ERROR; | - | ||||||||||||
33 | ucol_setAttribute_52(collator, UCOL_NUMERIC_COLLATION, numericMode ? UCOL_ON : UCOL_OFF, &status); | - | ||||||||||||
34 | if (U_FAILURE(status)
| 0-336 | ||||||||||||
35 | QMessageLogger(__FILE__, 88, __PRETTY_FUNCTION__).warning("ucol_setAttribute: numeric collation failed: %d", status); never executed: QMessageLogger(__FILE__, 88, __PRETTY_FUNCTION__).warning("ucol_setAttribute: numeric collation failed: %d", status); | 0 | ||||||||||||
36 | - | |||||||||||||
37 | status = U_ZERO_ERROR; | - | ||||||||||||
38 | ucol_setAttribute_52(collator, UCOL_ALTERNATE_HANDLING, ignorePunctuation ? UCOL_SHIFTED : UCOL_NON_IGNORABLE, &status); | - | ||||||||||||
39 | if (U_FAILURE(status)
| 0-336 | ||||||||||||
40 | QMessageLogger(__FILE__, 93, __PRETTY_FUNCTION__).warning("ucol_setAttribute: Alternate handling failed: %d", status); never executed: QMessageLogger(__FILE__, 93, __PRETTY_FUNCTION__).warning("ucol_setAttribute: Alternate handling failed: %d", status); | 0 | ||||||||||||
41 | - | |||||||||||||
42 | dirty = false; | - | ||||||||||||
43 | } executed 336 times by 13 tests: end of block Executed by:
| 336 | ||||||||||||
44 | - | |||||||||||||
45 | void QCollatorPrivate::cleanup() | - | ||||||||||||
46 | { | - | ||||||||||||
47 | if (collator
| 336-386 | ||||||||||||
48 | ucol_close_52(collator); executed 336 times by 13 tests: ucol_close_52(collator); Executed by:
| 336 | ||||||||||||
49 | collator = 0; | - | ||||||||||||
50 | } executed 722 times by 19 tests: end of block Executed by:
| 722 | ||||||||||||
51 | - | |||||||||||||
52 | int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const | - | ||||||||||||
53 | { | - | ||||||||||||
54 | if (d->dirty
| 143-18877 | ||||||||||||
55 | d->init(); executed 143 times by 6 tests: d->init(); Executed by:
| 143 | ||||||||||||
56 | - | |||||||||||||
57 | if (d->collator
| 0-19020 | ||||||||||||
58 | return executed 19020 times by 12 tests: ucol_strcoll_52(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2);return ucol_strcoll_52(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); Executed by:
executed 19020 times by 12 tests: return ucol_strcoll_52(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); Executed by:
| 19020 | ||||||||||||
59 | - | |||||||||||||
60 | return never executed: QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity);return QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity); never executed: return QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity); | 0 | ||||||||||||
61 | } | - | ||||||||||||
62 | - | |||||||||||||
63 | int QCollator::compare(const QString &s1, const QString &s2) const | - | ||||||||||||
64 | { | - | ||||||||||||
65 | if (d->collator
| 0-7625 | ||||||||||||
66 | return executed 7625 times by 6 tests: compare(s1.constData(), s1.size(), s2.constData(), s2.size());return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); Executed by:
executed 7625 times by 6 tests: return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); Executed by:
| 7625 | ||||||||||||
67 | - | |||||||||||||
68 | return never executed: QString::compare(s1, s2, d->caseSensitivity);return QString::compare(s1, s2, d->caseSensitivity); never executed: return QString::compare(s1, s2, d->caseSensitivity); | 0 | ||||||||||||
69 | } | - | ||||||||||||
70 | - | |||||||||||||
71 | int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const | - | ||||||||||||
72 | { | - | ||||||||||||
73 | if (d->collator
| 0 | ||||||||||||
74 | return never executed: compare(s1.constData(), s1.size(), s2.constData(), s2.size());return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); never executed: return compare(s1.constData(), s1.size(), s2.constData(), s2.size()); | 0 | ||||||||||||
75 | - | |||||||||||||
76 | return never executed: QStringRef::compare(s1, s2, d->caseSensitivity);return QStringRef::compare(s1, s2, d->caseSensitivity); never executed: return QStringRef::compare(s1, s2, d->caseSensitivity); | 0 | ||||||||||||
77 | } | - | ||||||||||||
78 | - | |||||||||||||
79 | QCollatorSortKey QCollator::sortKey(const QString &string) const | - | ||||||||||||
80 | { | - | ||||||||||||
81 | if (d->dirty
| 0 | ||||||||||||
82 | d->init(); never executed: d->init(); | 0 | ||||||||||||
83 | - | |||||||||||||
84 | if (d->collator
| 0 | ||||||||||||
85 | QByteArray result(16 + string.size() + (string.size() >> 2), Qt::Uninitialized); | - | ||||||||||||
86 | int size = ucol_getSortKey_52(d->collator, (const UChar *)string.constData(), | - | ||||||||||||
87 | string.size(), (uint8_t *)result.data(), result.size()); | - | ||||||||||||
88 | if (size > result.size()
| 0 | ||||||||||||
89 | result.resize(size); | - | ||||||||||||
90 | size = ucol_getSortKey_52(d->collator, (const UChar *)string.constData(), | - | ||||||||||||
91 | string.size(), (uint8_t *)result.data(), result.size()); | - | ||||||||||||
92 | } never executed: end of block | 0 | ||||||||||||
93 | result.truncate(size); | - | ||||||||||||
94 | return never executed: QCollatorSortKey(new QCollatorSortKeyPrivate(result));return QCollatorSortKey(new QCollatorSortKeyPrivate(result)); never executed: return QCollatorSortKey(new QCollatorSortKeyPrivate(result)); | 0 | ||||||||||||
95 | } | - | ||||||||||||
96 | - | |||||||||||||
97 | return never executed: QCollatorSortKey(new QCollatorSortKeyPrivate(QByteArray()));return QCollatorSortKey(new QCollatorSortKeyPrivate(QByteArray())); never executed: return QCollatorSortKey(new QCollatorSortKeyPrivate(QByteArray())); | 0 | ||||||||||||
98 | } | - | ||||||||||||
99 | - | |||||||||||||
100 | int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const | - | ||||||||||||
101 | { | - | ||||||||||||
102 | return never executed: qstrcmp(d->m_key, otherKey.d->m_key);return qstrcmp(d->m_key, otherKey.d->m_key); never executed: return qstrcmp(d->m_key, otherKey.d->m_key); | 0 | ||||||||||||
103 | } | - | ||||||||||||
104 | - | |||||||||||||
105 | - | |||||||||||||
Switch to Source code | Preprocessed file |