| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qversionnumber.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | QVector<int> QVersionNumber::segments() const | - | ||||||||||||||||||||||||
| 13 | { | - | ||||||||||||||||||||||||
| 14 | if (m_segments.isUsingPointer()
| 135-311 | ||||||||||||||||||||||||
| 15 | return executed 135 times by 1 test: *m_segments.pointer_segments;return *m_segments.pointer_segments;Executed by:
executed 135 times by 1 test: return *m_segments.pointer_segments;Executed by:
| 135 | ||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||
| 17 | QVector<int> result; | - | ||||||||||||||||||||||||
| 18 | result.resize(segmentCount()); | - | ||||||||||||||||||||||||
| 19 | for (int i = 0; i < segmentCount()
| 311-720 | ||||||||||||||||||||||||
| 20 | result[i] = segmentAt(i); executed 720 times by 1 test: result[i] = segmentAt(i);Executed by:
| 720 | ||||||||||||||||||||||||
| 21 | return executed 311 times by 1 test: result;return result;Executed by:
executed 311 times by 1 test: return result;Executed by:
| 311 | ||||||||||||||||||||||||
| 22 | } | - | ||||||||||||||||||||||||
| 23 | QVersionNumber QVersionNumber::normalized() const | - | ||||||||||||||||||||||||
| 24 | { | - | ||||||||||||||||||||||||
| 25 | int i; | - | ||||||||||||||||||||||||
| 26 | for (i = m_segments.size(); i
| 2-32 | ||||||||||||||||||||||||
| 27 | if (m_segments.at(i - 1) != 0
| 16 | ||||||||||||||||||||||||
| 28 | break; executed 16 times by 1 test: break;Executed by:
| 16 | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | QVersionNumber result(*this); | - | ||||||||||||||||||||||||
| 31 | result.m_segments.resize(i); | - | ||||||||||||||||||||||||
| 32 | return executed 18 times by 1 test: result;return result;Executed by:
executed 18 times by 1 test: return result;Executed by:
| 18 | ||||||||||||||||||||||||
| 33 | } | - | ||||||||||||||||||||||||
| 34 | bool QVersionNumber::isPrefixOf(const QVersionNumber &other) const noexcept | - | ||||||||||||||||||||||||
| 35 | { | - | ||||||||||||||||||||||||
| 36 | if (segmentCount() > other.segmentCount()
| 10-41 | ||||||||||||||||||||||||
| 37 | return executed 10 times by 1 test: false;return false;Executed by:
executed 10 times by 1 test: return false;Executed by:
| 10 | ||||||||||||||||||||||||
| 38 | for (int i = 0; i < segmentCount()
| 17-123 | ||||||||||||||||||||||||
| 39 | if (segmentAt(i) != other.segmentAt(i)
| 24-99 | ||||||||||||||||||||||||
| 40 | return executed 24 times by 1 test: false;return false;Executed by:
executed 24 times by 1 test: return false;Executed by:
| 24 | ||||||||||||||||||||||||
| 41 | } executed 99 times by 1 test: end of blockExecuted by:
| 99 | ||||||||||||||||||||||||
| 42 | return executed 17 times by 1 test: true;return true;Executed by:
executed 17 times by 1 test: return true;Executed by:
| 17 | ||||||||||||||||||||||||
| 43 | } | - | ||||||||||||||||||||||||
| 44 | int QVersionNumber::compare(const QVersionNumber &v1, const QVersionNumber &v2) noexcept | - | ||||||||||||||||||||||||
| 45 | { | - | ||||||||||||||||||||||||
| 46 | int commonlen; | - | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | if (__builtin_expect(!!(!v1.m_segments.isUsingPointer() && !v2.m_segments.isUsingPointer()), true)
| 190-324 | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | const qint8 *ptr1 = v1.m_segments.inline_segments + InlineSegmentStartIdx; | - | ||||||||||||||||||||||||
| 51 | const qint8 *ptr2 = v2.m_segments.inline_segments + InlineSegmentStartIdx; | - | ||||||||||||||||||||||||
| 52 | commonlen = qMin(v1.m_segments.size(), | - | ||||||||||||||||||||||||
| 53 | v2.m_segments.size()); | - | ||||||||||||||||||||||||
| 54 | for (int i = 0; i < commonlen
| 237-498 | ||||||||||||||||||||||||
| 55 | if (int x = ptr1[i] - ptr2[i]
| 87-411 | ||||||||||||||||||||||||
| 56 | return executed 87 times by 2 tests: x;return x;Executed by:
executed 87 times by 2 tests: return x;Executed by:
| 87 | ||||||||||||||||||||||||
| 57 | } executed 237 times by 1 test: else {end of blockExecuted by:
| 237 | ||||||||||||||||||||||||
| 58 | commonlen = qMin(v1.segmentCount(), v2.segmentCount()); | - | ||||||||||||||||||||||||
| 59 | for (int i = 0; i < commonlen
| 104-997 | ||||||||||||||||||||||||
| 60 | if (v1.segmentAt(i) != v2.segmentAt(i)
| 86-911 | ||||||||||||||||||||||||
| 61 | return executed 86 times by 2 tests: v1.segmentAt(i) - v2.segmentAt(i);return v1.segmentAt(i) - v2.segmentAt(i);Executed by:
executed 86 times by 2 tests: return v1.segmentAt(i) - v2.segmentAt(i);Executed by:
| 86 | ||||||||||||||||||||||||
| 62 | } executed 911 times by 2 tests: end of blockExecuted by:
| 911 | ||||||||||||||||||||||||
| 63 | } executed 104 times by 1 test: end of blockExecuted by:
| 104 | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | - | |||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | if (v1.segmentCount() > commonlen
| 70-271 | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | if (v1.segmentAt(commonlen) != 0
| 14-56 | ||||||||||||||||||||||||
| 70 | return executed 56 times by 1 test: v1.segmentAt(commonlen);return v1.segmentAt(commonlen);Executed by:
executed 56 times by 1 test: return v1.segmentAt(commonlen);Executed by:
| 56 | ||||||||||||||||||||||||
| 71 | else | - | ||||||||||||||||||||||||
| 72 | return executed 14 times by 1 test: 1;return 1;Executed by:
executed 14 times by 1 test: return 1;Executed by:
| 14 | ||||||||||||||||||||||||
| 73 | } else if (v2.segmentCount() > commonlen
| 70-201 | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | if (v2.segmentAt(commonlen) != 0
| 14-56 | ||||||||||||||||||||||||
| 76 | return executed 56 times by 1 test: -v2.segmentAt(commonlen);return -v2.segmentAt(commonlen);Executed by:
executed 56 times by 1 test: return -v2.segmentAt(commonlen);Executed by:
| 56 | ||||||||||||||||||||||||
| 77 | else | - | ||||||||||||||||||||||||
| 78 | return executed 14 times by 1 test: -1;return -1;Executed by:
executed 14 times by 1 test: return -1;Executed by:
| 14 | ||||||||||||||||||||||||
| 79 | } | - | ||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | return executed 201 times by 1 test: 0;return 0;Executed by:
executed 201 times by 1 test: return 0;Executed by:
| 201 | ||||||||||||||||||||||||
| 83 | } | - | ||||||||||||||||||||||||
| 84 | QVersionNumber QVersionNumber::commonPrefix(const QVersionNumber &v1, | - | ||||||||||||||||||||||||
| 85 | const QVersionNumber &v2) | - | ||||||||||||||||||||||||
| 86 | { | - | ||||||||||||||||||||||||
| 87 | int commonlen = qMin(v1.segmentCount(), v2.segmentCount()); | - | ||||||||||||||||||||||||
| 88 | int i; | - | ||||||||||||||||||||||||
| 89 | for (i = 0; i < commonlen
| 27-150 | ||||||||||||||||||||||||
| 90 | if (v1.segmentAt(i) != v2.segmentAt(i)
| 24-126 | ||||||||||||||||||||||||
| 91 | break; executed 24 times by 1 test: break;Executed by:
| 24 | ||||||||||||||||||||||||
| 92 | } executed 126 times by 1 test: end of blockExecuted by:
| 126 | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | if (i == 0
| 15-36 | ||||||||||||||||||||||||
| 95 | return executed 15 times by 1 test: QVersionNumber();return QVersionNumber();Executed by:
executed 15 times by 1 test: return QVersionNumber();Executed by:
| 15 | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | QVersionNumber result(!v1.m_segments.isUsingPointer() ? v1 : v2); | - | ||||||||||||||||||||||||
| 99 | result.m_segments.resize(i); | - | ||||||||||||||||||||||||
| 100 | return executed 36 times by 1 test: result;return result;Executed by:
executed 36 times by 1 test: return result;Executed by:
| 36 | ||||||||||||||||||||||||
| 101 | } | - | ||||||||||||||||||||||||
| 102 | QString QVersionNumber::toString() const | - | ||||||||||||||||||||||||
| 103 | { | - | ||||||||||||||||||||||||
| 104 | QString version; | - | ||||||||||||||||||||||||
| 105 | version.reserve(qMax(segmentCount() * 2 - 1, 0)); | - | ||||||||||||||||||||||||
| 106 | bool first = true; | - | ||||||||||||||||||||||||
| 107 | for (int i = 0; i < segmentCount()
| 40-140 | ||||||||||||||||||||||||
| 108 | if (!first
| 35-105 | ||||||||||||||||||||||||
| 109 | version += QLatin1Char('.'); executed 105 times by 1 test: version += QLatin1Char('.');Executed by:
| 105 | ||||||||||||||||||||||||
| 110 | version += QString::number(segmentAt(i)); | - | ||||||||||||||||||||||||
| 111 | first = false; | - | ||||||||||||||||||||||||
| 112 | } executed 140 times by 1 test: end of blockExecuted by:
| 140 | ||||||||||||||||||||||||
| 113 | return executed 40 times by 1 test: version;return version;Executed by:
executed 40 times by 1 test: return version;Executed by:
| 40 | ||||||||||||||||||||||||
| 114 | } | - | ||||||||||||||||||||||||
| 115 | QVersionNumber QVersionNumber::fromString(const QString &string, int *suffixIndex) | - | ||||||||||||||||||||||||
| 116 | { | - | ||||||||||||||||||||||||
| 117 | QVector<int> seg; | - | ||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | const QByteArray cString(string.toLatin1()); | - | ||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||
| 121 | const char *start = cString.constData(); | - | ||||||||||||||||||||||||
| 122 | const char *end = start; | - | ||||||||||||||||||||||||
| 123 | const char *lastGoodEnd = start; | - | ||||||||||||||||||||||||
| 124 | const char *endOfString = cString.constData() + cString.size(); | - | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | do { | - | ||||||||||||||||||||||||
| 127 | bool ok = false; | - | ||||||||||||||||||||||||
| 128 | const qulonglong value = qstrtoull(start, &end, 10, &ok); | - | ||||||||||||||||||||||||
| 129 | if (!ok
| 4-296 | ||||||||||||||||||||||||
| 130 | break; executed 28 times by 1 test: break;Executed by:
| 28 | ||||||||||||||||||||||||
| 131 | seg.append(int(value)); | - | ||||||||||||||||||||||||
| 132 | start = end + 1; | - | ||||||||||||||||||||||||
| 133 | lastGoodEnd = end; | - | ||||||||||||||||||||||||
| 134 | } executed 292 times by 2 tests: while (start < endOfStringend of blockExecuted by:
| 0-292 | ||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | if (suffixIndex
| 41-48 | ||||||||||||||||||||||||
| 137 | * executed 41 times by 1 test: suffixIndex = int(lastGoodEnd - cString.constData());*suffixIndex = int(lastGoodEnd - cString.constData());Executed by:
executed 41 times by 1 test: *suffixIndex = int(lastGoodEnd - cString.constData());Executed by:
| 41 | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | return executed 89 times by 2 tests: QVersionNumber(std::move(seg));return QVersionNumber(std::move(seg));Executed by:
executed 89 times by 2 tests: return QVersionNumber(std::move(seg));Executed by:
| 89 | ||||||||||||||||||||||||
| 140 | } | - | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | void QVersionNumber::SegmentStorage::setVector(int len, int maj, int min, int mic) | - | ||||||||||||||||||||||||
| 143 | { | - | ||||||||||||||||||||||||
| 144 | pointer_segments = new QVector<int>; | - | ||||||||||||||||||||||||
| 145 | pointer_segments->resize(len); | - | ||||||||||||||||||||||||
| 146 | pointer_segments->data()[0] = maj; | - | ||||||||||||||||||||||||
| 147 | if (len > 1
| 36-171 | ||||||||||||||||||||||||
| 148 | pointer_segments->data()[1] = min; | - | ||||||||||||||||||||||||
| 149 | if (len > 2
| 81-90 | ||||||||||||||||||||||||
| 150 | pointer_segments->data()[2] = mic; | - | ||||||||||||||||||||||||
| 151 | } executed 81 times by 1 test: end of blockExecuted by:
| 81 | ||||||||||||||||||||||||
| 152 | } executed 171 times by 1 test: end of blockExecuted by:
| 171 | ||||||||||||||||||||||||
| 153 | } executed 207 times by 1 test: end of blockExecuted by:
| 207 | ||||||||||||||||||||||||
| 154 | QDataStream& operator<<(QDataStream &out, const QVersionNumber &version) | - | ||||||||||||||||||||||||
| 155 | { | - | ||||||||||||||||||||||||
| 156 | out << version.segments(); | - | ||||||||||||||||||||||||
| 157 | return executed 37 times by 1 test: out;return out;Executed by:
executed 37 times by 1 test: return out;Executed by:
| 37 | ||||||||||||||||||||||||
| 158 | } | - | ||||||||||||||||||||||||
| 159 | QDataStream& operator>>(QDataStream &in, QVersionNumber &version) | - | ||||||||||||||||||||||||
| 160 | { | - | ||||||||||||||||||||||||
| 161 | if (!version.m_segments.isUsingPointer()
| 0-37 | ||||||||||||||||||||||||
| 162 | version.m_segments.pointer_segments = new QVector<int>; executed 37 times by 1 test: version.m_segments.pointer_segments = new QVector<int>;Executed by:
| 37 | ||||||||||||||||||||||||
| 163 | in >> *version.m_segments.pointer_segments; | - | ||||||||||||||||||||||||
| 164 | return executed 37 times by 1 test: in;return in;Executed by:
executed 37 times by 1 test: return in;Executed by:
| 37 | ||||||||||||||||||||||||
| 165 | } | - | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||
| 169 | QDebug operator<<(QDebug debug, const QVersionNumber &version) | - | ||||||||||||||||||||||||
| 170 | { | - | ||||||||||||||||||||||||
| 171 | QDebugStateSaver saver(debug); | - | ||||||||||||||||||||||||
| 172 | debug.noquote() << version.toString(); | - | ||||||||||||||||||||||||
| 173 | return never executed: debug;return debug;never executed: return debug; | 0 | ||||||||||||||||||||||||
| 174 | } | - | ||||||||||||||||||||||||
| 175 | uint qHash(const QVersionNumber &key, uint seed) | - | ||||||||||||||||||||||||
| 176 | { | - | ||||||||||||||||||||||||
| 177 | QtPrivate::QHashCombine hash; | - | ||||||||||||||||||||||||
| 178 | for (int i = 0; i < key.segmentCount()
| 0 | ||||||||||||||||||||||||
| 179 | seed = hash(seed, key.segmentAt(i)); never executed: seed = hash(seed, key.segmentAt(i)); | 0 | ||||||||||||||||||||||||
| 180 | return never executed: seed;return seed;never executed: return seed; | 0 | ||||||||||||||||||||||||
| 181 | } | - | ||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |