Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | struct QConfFileCustomFormat | - |
15 | { | - |
16 | QString extension; | - |
17 | QSettings::ReadFunc readFunc; | - |
18 | QSettings::WriteFunc writeFunc; | - |
19 | Qt::CaseSensitivity caseSensitivity; | - |
20 | }; | - |
21 | | - |
22 | typedef QHash<QString, QConfFile *> ConfFileHash; | - |
23 | typedef QCache<QString, QConfFile> ConfFileCache; | - |
24 | typedef QHash<int, QString> PathHash; | - |
25 | typedef QVector<QConfFileCustomFormat> CustomFormatVector; | - |
26 | | - |
27 | static ConfFileHash *usedHashFunc() { static QGlobalStatic<ConfFileHash > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { ConfFileHash *x = new ConfFileHash; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<ConfFileHash > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:5404 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:6 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:6 | yes Evaluation Count:5398 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-5404 |
28 | static ConfFileCache *unusedCacheFunc() { static QGlobalStatic<ConfFileCache > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { ConfFileCache *x = new ConfFileCache; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<ConfFileCache > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:2572 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:6 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:6 | yes Evaluation Count:2566 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-2572 |
29 | static PathHash *pathHashFunc() { static QGlobalStatic<PathHash > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { PathHash *x = new PathHash; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<PathHash > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:1958 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:5 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:5 | yes Evaluation Count:1953 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-1958 |
30 | static CustomFormatVector *customFormatVectorFunc() { static QGlobalStatic<CustomFormatVector > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { CustomFormatVector *x = new CustomFormatVector; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<CustomFormatVector > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:1 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:1 | yes Evaluation Count:92 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:1 | no Evaluation Count:0 |
never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:93 | 0-93 |
31 | | - |
32 | static QBasicMutex settingsGlobalMutex; | - |
33 | | - |
34 | static QSettings::Format globalDefaultFormat = QSettings::NativeFormat; | - |
35 | | - |
36 | | - |
37 | inline bool qt_isEvilFsTypeName(const char *name) | - |
38 | { | - |
39 | return (qstrncmp(name, "nfs", 3) == 0 | 0 |
40 | || qstrncmp(name, "autofs", 6) == 0 | 0 |
41 | || qstrncmp(name, "cachefs", 7) == 0); never executed: return (qstrncmp(name, "nfs", 3) == 0 || qstrncmp(name, "autofs", 6) == 0 || qstrncmp(name, "cachefs", 7) == 0); | 0 |
42 | } | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | | - |
48 | | - |
49 | bool qIsLikelyToBeNfs(int handle) | - |
50 | { | - |
51 | struct statfs buf; | - |
52 | if (fstatfs(handle, &buf) != 0) evaluated: fstatfs(handle, &buf) != 0 yes Evaluation Count:5 | yes Evaluation Count:944 |
| 5-944 |
53 | return false; executed: return false; Execution Count:5 | 5 |
54 | return buf.f_type == 0x00006969 | 944 |
55 | || buf.f_type == 0x00000187 | 944 |
56 | || buf.f_type == 0x7d92b1a0; executed: return buf.f_type == 0x00006969 || buf.f_type == 0x00000187 || buf.f_type == 0x7d92b1a0; Execution Count:944 | 944 |
57 | } | - |
58 | static bool unixLock(int handle, int lockType) | - |
59 | { | - |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | if (qIsLikelyToBeNfs(handle)) partially evaluated: qIsLikelyToBeNfs(handle) no Evaluation Count:0 | yes Evaluation Count:949 |
| 0-949 |
67 | return false; never executed: return false; | 0 |
68 | | - |
69 | struct flock fl; | - |
70 | fl.l_whence = 0; | - |
71 | fl.l_start = 0; | - |
72 | fl.l_len = 0; | - |
73 | fl.l_type = lockType; | - |
74 | return fcntl(handle, 7, &fl) == 0; executed: return fcntl(handle, 7, &fl) == 0; Execution Count:949 | 949 |
75 | } | - |
76 | | - |
77 | | - |
78 | QConfFile::QConfFile(const QString &fileName, bool _userPerms) | - |
79 | : name(fileName), size(0), ref(1), userPerms(_userPerms) | - |
80 | { | - |
81 | usedHashFunc()->insert(name, this); | - |
82 | } executed: } Execution Count:944 | 944 |
83 | | - |
84 | QConfFile::~QConfFile() | - |
85 | { | - |
86 | if (usedHashFunc()) partially evaluated: usedHashFunc() yes Evaluation Count:944 | no Evaluation Count:0 |
| 0-944 |
87 | usedHashFunc()->remove(name); executed: usedHashFunc()->remove(name); Execution Count:944 | 944 |
88 | } executed: } Execution Count:944 | 944 |
89 | | - |
90 | ParsedSettingsMap QConfFile::mergedKeyMap() const | - |
91 | { | - |
92 | ParsedSettingsMap result = originalKeys; | - |
93 | ParsedSettingsMap::const_iterator i; | - |
94 | | - |
95 | for (i = removedKeys.begin(); i != removedKeys.end(); ++i) evaluated: i != removedKeys.end() yes Evaluation Count:134 | yes Evaluation Count:495 |
| 134-495 |
96 | result.remove(i.key()); executed: result.remove(i.key()); Execution Count:134 | 134 |
97 | for (i = addedKeys.begin(); i != addedKeys.end(); ++i) evaluated: i != addedKeys.end() yes Evaluation Count:770 | yes Evaluation Count:495 |
| 495-770 |
98 | result.insert(i.key(), i.value()); executed: result.insert(i.key(), i.value()); Execution Count:770 | 770 |
99 | return result; executed: return result; Execution Count:495 | 495 |
100 | } | - |
101 | | - |
102 | bool QConfFile::isWritable() const | - |
103 | { | - |
104 | QFileInfo fileInfo(name); | - |
105 | | - |
106 | | - |
107 | if (fileInfo.exists()) { evaluated: fileInfo.exists() yes Evaluation Count:417 | yes Evaluation Count:98 |
| 98-417 |
108 | | - |
109 | QFile file(name); | - |
110 | return file.open(QFile::ReadWrite); executed: return file.open(QFile::ReadWrite); Execution Count:417 | 417 |
111 | | - |
112 | } else { | - |
113 | | - |
114 | QDir dir(fileInfo.absolutePath()); | - |
115 | if (!dir.exists()) { evaluated: !dir.exists() yes Evaluation Count:75 | yes Evaluation Count:23 |
| 23-75 |
116 | if (!dir.mkpath(dir.absolutePath())) partially evaluated: !dir.mkpath(dir.absolutePath()) no Evaluation Count:0 | yes Evaluation Count:75 |
| 0-75 |
117 | return false; never executed: return false; | 0 |
118 | } executed: } Execution Count:75 | 75 |
119 | | - |
120 | | - |
121 | QTemporaryFile file(name); | - |
122 | return file.open(); executed: return file.open(); Execution Count:98 | 98 |
123 | } | - |
124 | | - |
125 | } | - |
126 | | - |
127 | QConfFile *QConfFile::fromName(const QString &fileName, bool _userPerms) | - |
128 | { | - |
129 | QString absPath = QFileInfo(fileName).absoluteFilePath(); | - |
130 | | - |
131 | ConfFileHash *usedHash = usedHashFunc(); | - |
132 | ConfFileCache *unusedCache = unusedCacheFunc(); | - |
133 | | - |
134 | QConfFile *confFile = 0; | - |
135 | QMutexLocker locker(&settingsGlobalMutex); | - |
136 | | - |
137 | if (!(confFile = usedHash->value(absPath))) { evaluated: !(confFile = usedHash->value(absPath)) yes Evaluation Count:1220 | yes Evaluation Count:551 |
| 551-1220 |
138 | if ((confFile = unusedCache->take(absPath))) evaluated: (confFile = unusedCache->take(absPath)) yes Evaluation Count:276 | yes Evaluation Count:944 |
| 276-944 |
139 | usedHash->insert(absPath, confFile); executed: usedHash->insert(absPath, confFile); Execution Count:276 | 276 |
140 | } executed: } Execution Count:1220 | 1220 |
141 | if (confFile) { evaluated: confFile yes Evaluation Count:827 | yes Evaluation Count:944 |
| 827-944 |
142 | confFile->ref.ref(); | - |
143 | return confFile; executed: return confFile; Execution Count:827 | 827 |
144 | } | - |
145 | return new QConfFile(absPath, _userPerms); executed: return new QConfFile(absPath, _userPerms); Execution Count:944 | 944 |
146 | } | - |
147 | | - |
148 | void QConfFile::clearCache() | - |
149 | { | - |
150 | QMutexLocker locker(&settingsGlobalMutex); | - |
151 | unusedCacheFunc()->clear(); | - |
152 | } | 0 |
153 | | - |
154 | | - |
155 | | - |
156 | | - |
157 | QSettingsPrivate::QSettingsPrivate(QSettings::Format format) | - |
158 | : format(format), scope(QSettings::UserScope ), iniCodec(0), spec(0), fallbacks(true), | - |
159 | pendingChanges(false), status(QSettings::NoError) | - |
160 | { | - |
161 | } executed: } Execution Count:44 | 44 |
162 | | - |
163 | QSettingsPrivate::QSettingsPrivate(QSettings::Format format, QSettings::Scope scope, | - |
164 | const QString &organization, const QString &application) | - |
165 | : format(format), scope(scope), organizationName(organization), applicationName(application), | - |
166 | iniCodec(0), spec(0), fallbacks(true), pendingChanges(false), status(QSettings::NoError) | - |
167 | { | - |
168 | } executed: } Execution Count:758 | 758 |
169 | | - |
170 | QSettingsPrivate::~QSettingsPrivate() | - |
171 | { | - |
172 | } | - |
173 | | - |
174 | QString QSettingsPrivate::actualKey(const QString &key) const | - |
175 | { | - |
176 | QString n = normalizedKey(key); | - |
177 | qt_noop(); | - |
178 | n.prepend(groupPrefix); | - |
179 | return n; executed: return n; Execution Count:3566 | 3566 |
180 | } | - |
181 | QString QSettingsPrivate::normalizedKey(const QString &key) | - |
182 | { | - |
183 | QString result = key; | - |
184 | | - |
185 | int i = 0; | - |
186 | while (i < result.size()) { evaluated: i < result.size() yes Evaluation Count:8424 | yes Evaluation Count:10 |
| 10-8424 |
187 | while (result.at(i) == QLatin1Char('/')) { evaluated: result.at(i) == QLatin1Char('/') yes Evaluation Count:181 | yes Evaluation Count:8412 |
| 181-8412 |
188 | result.remove(i, 1); | - |
189 | if (i == result.size()) evaluated: i == result.size() yes Evaluation Count:12 | yes Evaluation Count:169 |
| 12-169 |
190 | goto after_loop; executed: goto after_loop; Execution Count:12 | 12 |
191 | } executed: } Execution Count:169 | 169 |
192 | while (result.at(i) != QLatin1Char('/')) { evaluated: result.at(i) != QLatin1Char('/') yes Evaluation Count:48349 | yes Evaluation Count:4078 |
| 4078-48349 |
193 | ++i; | - |
194 | if (i == result.size()) evaluated: i == result.size() yes Evaluation Count:4334 | yes Evaluation Count:44015 |
| 4334-44015 |
195 | return result; executed: return result; Execution Count:4334 | 4334 |
196 | } executed: } Execution Count:44015 | 44015 |
197 | ++i; | - |
198 | } executed: } Execution Count:4078 | 4078 |
199 | | - |
200 | after_loop: code before this statement executed: after_loop: Execution Count:10 | 10 |
201 | if (!result.isEmpty()) evaluated: !result.isEmpty() yes Evaluation Count:12 | yes Evaluation Count:10 |
| 10-12 |
202 | result.truncate(i - 1); executed: result.truncate(i - 1); Execution Count:12 | 12 |
203 | return result; executed: return result; Execution Count:22 | 22 |
204 | } | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
209 | QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope, | - |
210 | const QString &organization, const QString &application) | - |
211 | { | - |
212 | return new QConfFileSettingsPrivate(format, scope, organization, application); executed: return new QConfFileSettingsPrivate(format, scope, organization, application); Execution Count:758 | 758 |
213 | } | - |
214 | | - |
215 | | - |
216 | | - |
217 | QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format) | - |
218 | { | - |
219 | return new QConfFileSettingsPrivate(fileName, format); executed: return new QConfFileSettingsPrivate(fileName, format); Execution Count:44 | 44 |
220 | } | - |
221 | | - |
222 | | - |
223 | void QSettingsPrivate::processChild(QString key, ChildSpec spec, QMap<QString, QString> &result) | - |
224 | { | - |
225 | if (spec != AllKeys) { evaluated: spec != AllKeys yes Evaluation Count:208 | yes Evaluation Count:1349 |
| 208-1349 |
226 | int slashPos = key.indexOf(QLatin1Char('/')); | - |
227 | if (slashPos == -1) { evaluated: slashPos == -1 yes Evaluation Count:40 | yes Evaluation Count:168 |
| 40-168 |
228 | if (spec != ChildKeys) evaluated: spec != ChildKeys yes Evaluation Count:20 | yes Evaluation Count:20 |
| 20 |
229 | return; executed: return; Execution Count:20 | 20 |
230 | } else { executed: } Execution Count:20 | 20 |
231 | if (spec != ChildGroups) evaluated: spec != ChildGroups yes Evaluation Count:64 | yes Evaluation Count:104 |
| 64-104 |
232 | return; executed: return; Execution Count:64 | 64 |
233 | key.truncate(slashPos); | - |
234 | } executed: } Execution Count:104 | 104 |
235 | } | - |
236 | result.insert(key, QString()); | - |
237 | } executed: } Execution Count:1473 | 1473 |
238 | | - |
239 | void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group) | - |
240 | { | - |
241 | groupStack.push(group); | - |
242 | if (!group.name().isEmpty()) { evaluated: !group.name().isEmpty() yes Evaluation Count:657 | yes Evaluation Count:7 |
| 7-657 |
243 | groupPrefix += group.name(); | - |
244 | groupPrefix += QLatin1Char('/'); | - |
245 | } executed: } Execution Count:657 | 657 |
246 | } executed: } Execution Count:664 | 664 |
247 | | - |
248 | | - |
249 | | - |
250 | | - |
251 | | - |
252 | | - |
253 | void QSettingsPrivate::setStatus(QSettings::Status status) const | - |
254 | { | - |
255 | if (status == QSettings::NoError || this->status == QSettings::NoError) partially evaluated: status == QSettings::NoError no Evaluation Count:0 | yes Evaluation Count:15 |
evaluated: this->status == QSettings::NoError yes Evaluation Count:13 | yes Evaluation Count:2 |
| 0-15 |
256 | this->status = status; executed: this->status = status; Execution Count:13 | 13 |
257 | } executed: } Execution Count:15 | 15 |
258 | | - |
259 | void QSettingsPrivate::update() | - |
260 | { | - |
261 | flush(); | - |
262 | pendingChanges = false; | - |
263 | } executed: } Execution Count:4 | 4 |
264 | | - |
265 | void QSettingsPrivate::requestUpdate() | - |
266 | { | - |
267 | if (!pendingChanges) { evaluated: !pendingChanges yes Evaluation Count:495 | yes Evaluation Count:479 |
| 479-495 |
268 | pendingChanges = true; | - |
269 | | - |
270 | QSettings * const q = q_func(); | - |
271 | QCoreApplication::postEvent(q, new QEvent(QEvent::UpdateRequest)); | - |
272 | | - |
273 | | - |
274 | | - |
275 | } executed: } Execution Count:495 | 495 |
276 | } executed: } Execution Count:974 | 974 |
277 | | - |
278 | QStringList QSettingsPrivate::variantListToStringList(const QVariantList &l) | - |
279 | { | - |
280 | QStringList result; | - |
281 | QVariantList::const_iterator it = l.constBegin(); | - |
282 | for (; it != l.constEnd(); ++it) evaluated: it != l.constEnd() yes Evaluation Count:34 | yes Evaluation Count:16 |
| 16-34 |
283 | result.append(variantToString(*it)); executed: result.append(variantToString(*it)); Execution Count:34 | 34 |
284 | return result; executed: return result; Execution Count:16 | 16 |
285 | } | - |
286 | | - |
287 | QVariant QSettingsPrivate::stringListToVariantList(const QStringList &l) | - |
288 | { | - |
289 | QStringList outStringList = l; | - |
290 | for (int i = 0; i < outStringList.count(); ++i) { evaluated: i < outStringList.count() yes Evaluation Count:254 | yes Evaluation Count:21 |
| 21-254 |
291 | const QString &str = outStringList.at(i); | - |
292 | | - |
293 | if (str.startsWith(QLatin1Char('@'))) { partially evaluated: str.startsWith(QLatin1Char('@')) no Evaluation Count:0 | yes Evaluation Count:254 |
| 0-254 |
294 | if (str.length() >= 2 && str.at(1) == QLatin1Char('@')) { never evaluated: str.length() >= 2 never evaluated: str.at(1) == QLatin1Char('@') | 0 |
295 | outStringList[i].remove(0, 1); | - |
296 | } else { | 0 |
297 | QVariantList variantList; | - |
298 | for (int j = 0; j < l.count(); ++j) never evaluated: j < l.count() | 0 |
299 | variantList.append(stringToVariant(l.at(j))); never executed: variantList.append(stringToVariant(l.at(j))); | 0 |
300 | return variantList; never executed: return variantList; | 0 |
301 | } | - |
302 | } | - |
303 | } executed: } Execution Count:254 | 254 |
304 | return outStringList; executed: return outStringList; Execution Count:21 | 21 |
305 | } | - |
306 | | - |
307 | QString QSettingsPrivate::variantToString(const QVariant &v) | - |
308 | { | - |
309 | QString result; | - |
310 | | - |
311 | switch (v.type()) { | - |
312 | case QVariant::Invalid: | - |
313 | result = QLatin1String("@Invalid()"); | - |
314 | break; | 0 |
315 | | - |
316 | case QVariant::ByteArray: { | - |
317 | QByteArray a = v.toByteArray(); | - |
318 | result = QLatin1String("@ByteArray("); | - |
319 | result += QString::fromLatin1(a.constData(), a.size()); | - |
320 | result += QLatin1Char(')'); | - |
321 | break; executed: break; Execution Count:279 | 279 |
322 | } | - |
323 | | - |
324 | case QVariant::String: | - |
325 | case QVariant::LongLong: | - |
326 | case QVariant::ULongLong: | - |
327 | case QVariant::Int: | - |
328 | case QVariant::UInt: | - |
329 | case QVariant::Bool: | - |
330 | case QVariant::Double: | - |
331 | case QVariant::KeySequence: { | - |
332 | result = v.toString(); | - |
333 | if (result.startsWith(QLatin1Char('@'))) partially evaluated: result.startsWith(QLatin1Char('@')) no Evaluation Count:0 | yes Evaluation Count:6239 |
| 0-6239 |
334 | result.prepend(QLatin1Char('@')); never executed: result.prepend(QLatin1Char('@')); | 0 |
335 | break; executed: break; Execution Count:6239 | 6239 |
336 | } | - |
337 | | - |
338 | case QVariant::Rect: { | - |
339 | QRect r = qvariant_cast<QRect>(v); | - |
340 | result += QLatin1String("@Rect("); | - |
341 | result += QString::number(r.x()); | - |
342 | result += QLatin1Char(' '); | - |
343 | result += QString::number(r.y()); | - |
344 | result += QLatin1Char(' '); | - |
345 | result += QString::number(r.width()); | - |
346 | result += QLatin1Char(' '); | - |
347 | result += QString::number(r.height()); | - |
348 | result += QLatin1Char(')'); | - |
349 | break; | 0 |
350 | } | - |
351 | case QVariant::Size: { | - |
352 | QSize s = qvariant_cast<QSize>(v); | - |
353 | result += QLatin1String("@Size("); | - |
354 | result += QString::number(s.width()); | - |
355 | result += QLatin1Char(' '); | - |
356 | result += QString::number(s.height()); | - |
357 | result += QLatin1Char(')'); | - |
358 | break; | 0 |
359 | } | - |
360 | case QVariant::Point: { | - |
361 | QPoint p = qvariant_cast<QPoint>(v); | - |
362 | result += QLatin1String("@Point("); | - |
363 | result += QString::number(p.x()); | - |
364 | result += QLatin1Char(' '); | - |
365 | result += QString::number(p.y()); | - |
366 | result += QLatin1Char(')'); | - |
367 | break; | 0 |
368 | } | - |
369 | | - |
370 | | - |
371 | default: { | - |
372 | | - |
373 | QByteArray a; | - |
374 | { | - |
375 | QDataStream s(&a, QIODevice::WriteOnly); | - |
376 | s.setVersion(QDataStream::Qt_4_0); | - |
377 | s << v; | - |
378 | } | - |
379 | | - |
380 | result = QLatin1String("@Variant("); | - |
381 | result += QString::fromLatin1(a.constData(), a.size()); | - |
382 | result += QLatin1Char(')'); | - |
383 | | - |
384 | | - |
385 | | - |
386 | break; executed: break; Execution Count:9 | 9 |
387 | } | - |
388 | } | - |
389 | | - |
390 | return result; executed: return result; Execution Count:6527 | 6527 |
391 | } | - |
392 | | - |
393 | | - |
394 | QVariant QSettingsPrivate::stringToVariant(const QString &s) | - |
395 | { | - |
396 | if (s.startsWith(QLatin1Char('@'))) { evaluated: s.startsWith(QLatin1Char('@')) yes Evaluation Count:287 | yes Evaluation Count:6697 |
| 287-6697 |
397 | if (s.endsWith(QLatin1Char(')'))) { partially evaluated: s.endsWith(QLatin1Char(')')) yes Evaluation Count:287 | no Evaluation Count:0 |
| 0-287 |
398 | if (s.startsWith(QLatin1String("@ByteArray("))) { evaluated: s.startsWith(QLatin1String("@ByteArray(")) yes Evaluation Count:279 | yes Evaluation Count:8 |
| 8-279 |
399 | return QVariant(s.toLatin1().mid(11, s.size() - 12)); executed: return QVariant(s.toLatin1().mid(11, s.size() - 12)); Execution Count:279 | 279 |
400 | } else if (s.startsWith(QLatin1String("@Variant("))) { evaluated: s.startsWith(QLatin1String("@Variant(")) yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
401 | | - |
402 | QByteArray a(s.toLatin1().mid(9)); | - |
403 | QDataStream stream(&a, QIODevice::ReadOnly); | - |
404 | stream.setVersion(QDataStream::Qt_4_0); | - |
405 | QVariant result; | - |
406 | stream >> result; | - |
407 | return result; executed: return result; Execution Count:4 | 4 |
408 | | - |
409 | | - |
410 | | - |
411 | | - |
412 | } else if (s.startsWith(QLatin1String("@Rect("))) { partially evaluated: s.startsWith(QLatin1String("@Rect(")) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
413 | QStringList args = QSettingsPrivate::splitArgs(s, 5); | - |
414 | if (args.size() == 4) never evaluated: args.size() == 4 | 0 |
415 | return QVariant(QRect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt())); never executed: return QVariant(QRect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt())); | 0 |
416 | } else if (s.startsWith(QLatin1String("@Size("))) { partially evaluated: s.startsWith(QLatin1String("@Size(")) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
417 | QStringList args = QSettingsPrivate::splitArgs(s, 5); | - |
418 | if (args.size() == 2) never evaluated: args.size() == 2 | 0 |
419 | return QVariant(QSize(args[0].toInt(), args[1].toInt())); never executed: return QVariant(QSize(args[0].toInt(), args[1].toInt())); | 0 |
420 | } else if (s.startsWith(QLatin1String("@Point("))) { partially evaluated: s.startsWith(QLatin1String("@Point(")) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
421 | QStringList args = QSettingsPrivate::splitArgs(s, 6); | - |
422 | if (args.size() == 2) never evaluated: args.size() == 2 | 0 |
423 | return QVariant(QPoint(args[0].toInt(), args[1].toInt())); never executed: return QVariant(QPoint(args[0].toInt(), args[1].toInt())); | 0 |
424 | | - |
425 | } else if (s == QLatin1String("@Invalid()")) { partially evaluated: s == QLatin1String("@Invalid()") yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
426 | return QVariant(); executed: return QVariant(); Execution Count:4 | 4 |
427 | } | - |
428 | | - |
429 | } | - |
430 | if (s.startsWith(QLatin1String("@@"))) never evaluated: s.startsWith(QLatin1String("@@")) | 0 |
431 | return QVariant(s.mid(1)); never executed: return QVariant(s.mid(1)); | 0 |
432 | } | 0 |
433 | | - |
434 | return QVariant(s); executed: return QVariant(s); Execution Count:6697 | 6697 |
435 | } | - |
436 | | - |
437 | static const char hexDigits[] = "0123456789ABCDEF"; | - |
438 | | - |
439 | void QSettingsPrivate::iniEscapedKey(const QString &key, QByteArray &result) | - |
440 | { | - |
441 | result.reserve(result.length() + key.length() * 3 / 2); | - |
442 | for (int i = 0; i < key.size(); ++i) { evaluated: i < key.size() yes Evaluation Count:89997 | yes Evaluation Count:6972 |
| 6972-89997 |
443 | uint ch = key.at(i).unicode(); | - |
444 | | - |
445 | if (ch == '/') { evaluated: ch == '/' yes Evaluation Count:6027 | yes Evaluation Count:83970 |
| 6027-83970 |
446 | result += '\\'; | - |
447 | } else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') evaluated: ch >= 'a' yes Evaluation Count:69357 | yes Evaluation Count:14613 |
partially evaluated: ch <= 'z' yes Evaluation Count:69357 | no Evaluation Count:0 |
evaluated: ch >= 'A' yes Evaluation Count:6201 | yes Evaluation Count:8412 |
partially evaluated: ch <= 'Z' yes Evaluation Count:6201 | no Evaluation Count:0 |
evaluated: ch >= '0' yes Evaluation Count:8338 | yes Evaluation Count:74 |
partially evaluated: ch <= '9' yes Evaluation Count:8338 | no Evaluation Count:0 |
executed: } Execution Count:6027 | 0-69357 |
448 | || ch == '_' || ch == '-' || ch == '.') { partially evaluated: ch == '_' no Evaluation Count:0 | yes Evaluation Count:74 |
partially evaluated: ch == '-' no Evaluation Count:0 | yes Evaluation Count:74 |
evaluated: ch == '.' yes Evaluation Count:2 | yes Evaluation Count:72 |
| 0-74 |
449 | result += (char)ch; | - |
450 | } else if (ch <= 0xFF) { partially evaluated: ch <= 0xFF yes Evaluation Count:72 | no Evaluation Count:0 |
executed: } Execution Count:83898 | 0-83898 |
451 | result += '%'; | - |
452 | result += hexDigits[ch / 16]; | - |
453 | result += hexDigits[ch % 16]; | - |
454 | } else { executed: } Execution Count:72 | 72 |
455 | result += "%U"; | - |
456 | QByteArray hexCode; | - |
457 | for (int i = 0; i < 4; ++i) { | 0 |
458 | hexCode.prepend(hexDigits[ch % 16]); | - |
459 | ch >>= 4; | - |
460 | } | 0 |
461 | result += hexCode; | - |
462 | } | 0 |
463 | } | - |
464 | } executed: } Execution Count:6972 | 6972 |
465 | | - |
466 | bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to, QString &result) | - |
467 | { | - |
468 | bool lowercaseOnly = true; | - |
469 | int i = from; | - |
470 | result.reserve(result.length() + (to - from)); | - |
471 | while (i < to) { evaluated: i < to yes Evaluation Count:94334 | yes Evaluation Count:7582 |
| 7582-94334 |
472 | int ch = (uchar)key.at(i); | - |
473 | | - |
474 | if (ch == '\\') { evaluated: ch == '\\' yes Evaluation Count:5894 | yes Evaluation Count:88440 |
| 5894-88440 |
475 | result += QLatin1Char('/'); | - |
476 | ++i; | - |
477 | continue; executed: continue; Execution Count:5894 | 5894 |
478 | } | - |
479 | | - |
480 | if (ch != '%' || i == to - 1) { evaluated: ch != '%' yes Evaluation Count:88405 | yes Evaluation Count:35 |
partially evaluated: i == to - 1 no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-88405 |
481 | if (uint(ch - 'A') <= 'Z' - 'A') evaluated: uint(ch - 'A') <= 'Z' - 'A' yes Evaluation Count:6899 | yes Evaluation Count:81506 |
| 6899-81506 |
482 | lowercaseOnly = false; executed: lowercaseOnly = false; Execution Count:6899 | 6899 |
483 | result += QLatin1Char(ch); | - |
484 | ++i; | - |
485 | continue; executed: continue; Execution Count:88405 | 88405 |
486 | } | - |
487 | | - |
488 | int numDigits = 2; | - |
489 | int firstDigitPos = i + 1; | - |
490 | | - |
491 | ch = key.at(i + 1); | - |
492 | if (ch == 'U') { partially evaluated: ch == 'U' no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
493 | ++firstDigitPos; | - |
494 | numDigits = 4; | - |
495 | } | 0 |
496 | | - |
497 | if (firstDigitPos + numDigits > to) { partially evaluated: firstDigitPos + numDigits > to no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
498 | result += QLatin1Char('%'); | - |
499 | | - |
500 | ++i; | - |
501 | continue; never executed: continue; | 0 |
502 | } | - |
503 | | - |
504 | bool ok; | - |
505 | ch = key.mid(firstDigitPos, numDigits).toInt(&ok, 16); | - |
506 | if (!ok) { partially evaluated: !ok no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
507 | result += QLatin1Char('%'); | - |
508 | | - |
509 | ++i; | - |
510 | continue; never executed: continue; | 0 |
511 | } | - |
512 | | - |
513 | QChar qch(ch); | - |
514 | if (qch.isUpper()) partially evaluated: qch.isUpper() no Evaluation Count:0 | yes Evaluation Count:35 |
| 0-35 |
515 | lowercaseOnly = false; never executed: lowercaseOnly = false; | 0 |
516 | result += qch; | - |
517 | i = firstDigitPos + numDigits; | - |
518 | } executed: } Execution Count:35 | 35 |
519 | return lowercaseOnly; executed: return lowercaseOnly; Execution Count:7582 | 7582 |
520 | } | - |
521 | | - |
522 | void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, QTextCodec *codec) | - |
523 | { | - |
524 | bool needsQuotes = false; | - |
525 | bool escapeNextIfDigit = false; | - |
526 | int i; | - |
527 | int startPos = result.size(); | - |
528 | | - |
529 | result.reserve(startPos + str.size() * 3 / 2); | - |
530 | for (i = 0; i < str.size(); ++i) { evaluated: i < str.size() yes Evaluation Count:182761 | yes Evaluation Count:6527 |
| 6527-182761 |
531 | uint ch = str.at(i).unicode(); | - |
532 | if (ch == ';' || ch == ',' || ch == '=') partially evaluated: ch == ';' no Evaluation Count:0 | yes Evaluation Count:182761 |
partially evaluated: ch == ',' no Evaluation Count:0 | yes Evaluation Count:182761 |
evaluated: ch == '=' yes Evaluation Count:486 | yes Evaluation Count:182275 |
| 0-182761 |
533 | needsQuotes = true; executed: needsQuotes = true; Execution Count:486 | 486 |
534 | | - |
535 | if (escapeNextIfDigit evaluated: escapeNextIfDigit yes Evaluation Count:92087 | yes Evaluation Count:90674 |
| 90674-92087 |
536 | && ((ch >= '0' && ch <= '9') evaluated: ch >= '0' yes Evaluation Count:32117 | yes Evaluation Count:59970 |
evaluated: ch <= '9' yes Evaluation Count:699 | yes Evaluation Count:31418 |
| 699-59970 |
537 | || (ch >= 'a' && ch <= 'f') evaluated: ch >= 'a' yes Evaluation Count:30063 | yes Evaluation Count:61325 |
evaluated: ch <= 'f' yes Evaluation Count:8159 | yes Evaluation Count:21904 |
| 8159-61325 |
538 | || (ch >= 'A' && ch <= 'F'))) { evaluated: ch >= 'A' yes Evaluation Count:22496 | yes Evaluation Count:60733 |
evaluated: ch <= 'F' yes Evaluation Count:118 | yes Evaluation Count:22378 |
| 118-60733 |
539 | result += "\\x"; | - |
540 | result += QByteArray::number(ch, 16); | - |
541 | continue; executed: continue; Execution Count:8976 | 8976 |
542 | } | - |
543 | | - |
544 | escapeNextIfDigit = false; | - |
545 | | - |
546 | switch (ch) { | - |
547 | case '\0': | - |
548 | result += "\\0"; | - |
549 | escapeNextIfDigit = true; | - |
550 | break; executed: break; Execution Count:71831 | 71831 |
551 | case '\a': | - |
552 | result += "\\a"; | - |
553 | break; executed: break; Execution Count:1 | 1 |
554 | case '\b': | - |
555 | result += "\\b"; | - |
556 | break; executed: break; Execution Count:134 | 134 |
557 | case '\f': | - |
558 | result += "\\f"; | - |
559 | break; executed: break; Execution Count:1 | 1 |
560 | case '\n': | - |
561 | result += "\\n"; | - |
562 | break; executed: break; Execution Count:27 | 27 |
563 | case '\r': | - |
564 | result += "\\r"; | - |
565 | break; executed: break; Execution Count:2 | 2 |
566 | case '\t': | - |
567 | result += "\\t"; | - |
568 | break; executed: break; Execution Count:17 | 17 |
569 | case '\v': | - |
570 | result += "\\v"; | - |
571 | break; | 0 |
572 | case '"': | - |
573 | case '\\': | - |
574 | result += '\\'; | - |
575 | result += (char)ch; | - |
576 | break; | 0 |
577 | default: | - |
578 | if (ch <= 0x1F || (ch >= 0x7F && !codec)) { evaluated: ch <= 0x1F yes Evaluation Count:7046 | yes Evaluation Count:94726 |
evaluated: ch >= 0x7F yes Evaluation Count:4234 | yes Evaluation Count:90492 |
partially evaluated: !codec yes Evaluation Count:4234 | no Evaluation Count:0 |
| 0-94726 |
579 | result += "\\x"; | - |
580 | result += QByteArray::number(ch, 16); | - |
581 | escapeNextIfDigit = true; | - |
582 | | - |
583 | } else if (codec) { executed: } Execution Count:11280 partially evaluated: codec no Evaluation Count:0 | yes Evaluation Count:90492 |
| 0-90492 |
584 | | - |
585 | result += codec->fromUnicode(str.at(i)); | - |
586 | | - |
587 | } else { | 0 |
588 | result += (char)ch; | - |
589 | } executed: } Execution Count:90492 | 90492 |
590 | } | - |
591 | } executed: } Execution Count:173785 | 173785 |
592 | | - |
593 | if (needsQuotes evaluated: needsQuotes yes Evaluation Count:276 | yes Evaluation Count:6251 |
| 276-6251 |
594 | || (startPos < result.size() && (result.at(startPos) == ' ' evaluated: startPos < result.size() yes Evaluation Count:6234 | yes Evaluation Count:17 |
partially evaluated: result.at(startPos) == ' ' no Evaluation Count:0 | yes Evaluation Count:6234 |
| 0-6234 |
595 | || result.at(result.size() - 1) == ' '))) { partially evaluated: result.at(result.size() - 1) == ' ' no Evaluation Count:0 | yes Evaluation Count:6234 |
| 0-6234 |
596 | result.insert(startPos, '"'); | - |
597 | result += '"'; | - |
598 | } executed: } Execution Count:276 | 276 |
599 | } executed: } Execution Count:6527 | 6527 |
600 | | - |
601 | inline static void iniChopTrailingSpaces(QString &str) | - |
602 | { | - |
603 | int n = str.size() - 1; | - |
604 | QChar ch; | - |
605 | while (n >= 0 && ((ch = str.at(n)) == QLatin1Char(' ') || ch == QLatin1Char('\t'))) evaluated: n >= 0 yes Evaluation Count:6948 | yes Evaluation Count:14 |
partially evaluated: (ch = str.at(n)) == QLatin1Char(' ') no Evaluation Count:0 | yes Evaluation Count:6948 |
partially evaluated: ch == QLatin1Char('\t') no Evaluation Count:0 | yes Evaluation Count:6948 |
| 0-6948 |
606 | str.truncate(n--); never executed: str.truncate(n--); | 0 |
607 | } executed: } Execution Count:6962 | 6962 |
608 | | - |
609 | void QSettingsPrivate::iniEscapedStringList(const QStringList &strs, QByteArray &result, QTextCodec *codec) | - |
610 | { | - |
611 | if (strs.isEmpty()) { evaluated: strs.isEmpty() yes Evaluation Count:4 | yes Evaluation Count:12 |
| 4-12 |
612 | result += "@Invalid()"; | - |
613 | } else { executed: } Execution Count:4 | 4 |
614 | for (int i = 0; i < strs.size(); ++i) { evaluated: i < strs.size() yes Evaluation Count:34 | yes Evaluation Count:12 |
| 12-34 |
615 | if (i != 0) evaluated: i != 0 yes Evaluation Count:22 | yes Evaluation Count:12 |
| 12-22 |
616 | result += ", "; executed: result += ", "; Execution Count:22 | 22 |
617 | iniEscapedString(strs.at(i), result, codec); | - |
618 | } executed: } Execution Count:34 | 34 |
619 | } executed: } Execution Count:12 | 12 |
620 | } | - |
621 | | - |
622 | bool QSettingsPrivate::iniUnescapedStringList(const QByteArray &str, int from, int to, | - |
623 | QString &stringResult, QStringList &stringListResult, | - |
624 | QTextCodec *codec) | - |
625 | { | - |
626 | static const char escapeCodes[][2] = | - |
627 | { | - |
628 | { 'a', '\a' }, | - |
629 | { 'b', '\b' }, | - |
630 | { 'f', '\f' }, | - |
631 | { 'n', '\n' }, | - |
632 | { 'r', '\r' }, | - |
633 | { 't', '\t' }, | - |
634 | { 'v', '\v' }, | - |
635 | { '"', '"' }, | - |
636 | { '?', '?' }, | - |
637 | { '\'', '\'' }, | - |
638 | { '\\', '\\' } | - |
639 | }; | - |
640 | static const int numEscapeCodes = sizeof(escapeCodes) / sizeof(escapeCodes[0]); | - |
641 | | - |
642 | bool isStringList = false; | - |
643 | bool inQuotedString = false; | - |
644 | bool currentValueIsQuoted = false; | - |
645 | int escapeVal = 0; | - |
646 | int i = from; | - |
647 | char ch; | - |
648 | | - |
649 | StSkipSpaces: code before this statement executed: StSkipSpaces: Execution Count:7005 | 7005 |
650 | while (i < to && ((ch = str.at(i)) == ' ' || ch == '\t')) evaluated: i < to yes Evaluation Count:7242 | yes Evaluation Count:286 |
evaluated: (ch = str.at(i)) == ' ' yes Evaluation Count:14 | yes Evaluation Count:7228 |
partially evaluated: ch == '\t' no Evaluation Count:0 | yes Evaluation Count:7228 |
| 0-7242 |
651 | ++i; executed: ++i; Execution Count:14 | 14 |
652 | | - |
653 | | - |
654 | StNormal: code before this statement executed: StNormal: Execution Count:7514 | 7514 |
655 | while (i < to) { evaluated: i < to yes Evaluation Count:122853 | yes Evaluation Count:7005 |
| 7005-122853 |
656 | switch (str.at(i)) { | - |
657 | case '\\': | - |
658 | ++i; | - |
659 | if (i >= to) partially evaluated: i >= to no Evaluation Count:0 | yes Evaluation Count:91760 |
| 0-91760 |
660 | goto end; never executed: goto end; | 0 |
661 | | - |
662 | ch = str.at(i++); | - |
663 | for (int j = 0; j < numEscapeCodes; ++j) { evaluated: j < numEscapeCodes yes Evaluation Count:1008120 | yes Evaluation Count:91619 |
| 91619-1008120 |
664 | if (ch == escapeCodes[j][0]) { evaluated: ch == escapeCodes[j][0] yes Evaluation Count:141 | yes Evaluation Count:1007979 |
| 141-1007979 |
665 | stringResult += QLatin1Char(escapeCodes[j][1]); | - |
666 | goto StNormal; executed: goto StNormal; Execution Count:141 | 141 |
667 | } | - |
668 | } executed: } Execution Count:1007979 | 1007979 |
669 | | - |
670 | if (ch == 'x') { evaluated: ch == 'x' yes Evaluation Count:20135 | yes Evaluation Count:71484 |
| 20135-71484 |
671 | escapeVal = 0; | - |
672 | | - |
673 | if (i >= to) partially evaluated: i >= to no Evaluation Count:0 | yes Evaluation Count:20135 |
| 0-20135 |
674 | goto end; never executed: goto end; | 0 |
675 | | - |
676 | ch = str.at(i); | - |
677 | if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) partially evaluated: ch >= '0' yes Evaluation Count:20135 | no Evaluation Count:0 |
evaluated: ch <= '9' yes Evaluation Count:16537 | yes Evaluation Count:3598 |
partially evaluated: ch >= 'A' yes Evaluation Count:3598 | no Evaluation Count:0 |
partially evaluated: ch <= 'F' no Evaluation Count:0 | yes Evaluation Count:3598 |
partially evaluated: ch >= 'a' yes Evaluation Count:3598 | no Evaluation Count:0 |
partially evaluated: ch <= 'f' yes Evaluation Count:3598 | no Evaluation Count:0 |
| 0-20135 |
678 | goto StHexEscape; executed: goto StHexEscape; Execution Count:20135 | 20135 |
679 | } else if (ch >= '0' && ch <= '7') { partially evaluated: ch >= '0' yes Evaluation Count:71484 | no Evaluation Count:0 |
partially evaluated: ch <= '7' yes Evaluation Count:71484 | no Evaluation Count:0 |
| 0-71484 |
680 | escapeVal = ch - '0'; | - |
681 | goto StOctEscape; executed: goto StOctEscape; Execution Count:71484 | 71484 |
682 | } else if (ch == '\n' || ch == '\r') { never evaluated: ch == '\n' never evaluated: ch == '\r' | 0 |
683 | if (i < to) { | 0 |
684 | char ch2 = str.at(i); | - |
685 | | - |
686 | if ((ch2 == '\n' || ch2 == '\r') && ch2 != ch) never evaluated: ch2 == '\n' never evaluated: ch2 == '\r' never evaluated: ch2 != ch | 0 |
687 | ++i; | 0 |
688 | } | 0 |
689 | } else { | 0 |
690 | | - |
691 | } | 0 |
692 | break; | 0 |
693 | case '"': | - |
694 | ++i; | - |
695 | currentValueIsQuoted = true; | - |
696 | inQuotedString = !inQuotedString; | - |
697 | if (!inQuotedString) evaluated: !inQuotedString yes Evaluation Count:276 | yes Evaluation Count:276 |
| 276 |
698 | goto StSkipSpaces; executed: goto StSkipSpaces; Execution Count:276 | 276 |
699 | break; executed: break; Execution Count:276 | 276 |
700 | case ',': | - |
701 | if (!inQuotedString) { partially evaluated: !inQuotedString yes Evaluation Count:233 | no Evaluation Count:0 |
| 0-233 |
702 | if (!currentValueIsQuoted) partially evaluated: !currentValueIsQuoted yes Evaluation Count:233 | no Evaluation Count:0 |
| 0-233 |
703 | iniChopTrailingSpaces(stringResult); executed: iniChopTrailingSpaces(stringResult); Execution Count:233 | 233 |
704 | if (!isStringList) { evaluated: !isStringList yes Evaluation Count:21 | yes Evaluation Count:212 |
| 21-212 |
705 | isStringList = true; | - |
706 | stringListResult.clear(); | - |
707 | stringResult.squeeze(); | - |
708 | } executed: } Execution Count:21 | 21 |
709 | stringListResult.append(stringResult); | - |
710 | stringResult.clear(); | - |
711 | currentValueIsQuoted = false; | - |
712 | ++i; | - |
713 | goto StSkipSpaces; executed: goto StSkipSpaces; Execution Count:233 | 233 |
714 | } | - |
715 | | - |
716 | default: { code before this statement never executed: default: | 0 |
717 | int j = i + 1; | - |
718 | while (j < to) { evaluated: j < to yes Evaluation Count:89384 | yes Evaluation Count:6719 |
| 6719-89384 |
719 | ch = str.at(j); | - |
720 | if (ch == '\\' || ch == '"' || ch == ',') evaluated: ch == '\\' yes Evaluation Count:23084 | yes Evaluation Count:66300 |
evaluated: ch == '"' yes Evaluation Count:276 | yes Evaluation Count:66024 |
evaluated: ch == ',' yes Evaluation Count:229 | yes Evaluation Count:65795 |
| 229-66300 |
721 | break; executed: break; Execution Count:23589 | 23589 |
722 | ++j; | - |
723 | } executed: } Execution Count:65795 | 65795 |
724 | | - |
725 | | - |
726 | if (codec) { partially evaluated: codec no Evaluation Count:0 | yes Evaluation Count:30308 |
| 0-30308 |
727 | stringResult += codec->toUnicode(str.constData() + i, j - i); | - |
728 | } else | 0 |
729 | | - |
730 | { | - |
731 | int n = stringResult.size(); | - |
732 | stringResult.resize(n + (j - i)); | - |
733 | QChar *resultData = stringResult.data() + n; | - |
734 | for (int k = i; k < j; ++k) evaluated: k < j yes Evaluation Count:96103 | yes Evaluation Count:30308 |
| 30308-96103 |
735 | *resultData++ = QLatin1Char(str.at(k)); executed: *resultData++ = QLatin1Char(str.at(k)); Execution Count:96103 | 96103 |
736 | } executed: } Execution Count:30308 | 30308 |
737 | i = j; | - |
738 | } | - |
739 | } executed: } Execution Count:30308 | 30308 |
740 | } executed: } Execution Count:30584 | 30584 |
741 | goto end; executed: goto end; Execution Count:7005 | 7005 |
742 | | - |
743 | StHexEscape: | - |
744 | if (i >= to) { partially evaluated: i >= to no Evaluation Count:0 | yes Evaluation Count:54021 |
| 0-54021 |
745 | stringResult += QChar(escapeVal); | - |
746 | goto end; never executed: goto end; | 0 |
747 | } | - |
748 | | - |
749 | ch = str.at(i); | - |
750 | if (ch >= 'a') evaluated: ch >= 'a' yes Evaluation Count:7776 | yes Evaluation Count:46245 |
| 7776-46245 |
751 | ch -= 'a' - 'A'; executed: ch -= 'a' - 'A'; Execution Count:7776 | 7776 |
752 | if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F')) { evaluated: ch >= '0' yes Evaluation Count:53747 | yes Evaluation Count:274 |
evaluated: ch <= '9' yes Evaluation Count:26662 | yes Evaluation Count:27085 |
evaluated: ch >= 'A' yes Evaluation Count:27085 | yes Evaluation Count:274 |
evaluated: ch <= 'F' yes Evaluation Count:7224 | yes Evaluation Count:19861 |
| 274-53747 |
753 | escapeVal <<= 4; | - |
754 | escapeVal += strchr(hexDigits, ch) - hexDigits; | - |
755 | ++i; | - |
756 | goto StHexEscape; executed: goto StHexEscape; Execution Count:33886 | 33886 |
757 | } else { | - |
758 | stringResult += QChar(escapeVal); | - |
759 | goto StNormal; executed: goto StNormal; Execution Count:20135 | 20135 |
760 | } | - |
761 | | - |
762 | StOctEscape: | - |
763 | if (i >= to) { partially evaluated: i >= to no Evaluation Count:0 | yes Evaluation Count:71484 |
| 0-71484 |
764 | stringResult += QChar(escapeVal); | - |
765 | goto end; never executed: goto end; | 0 |
766 | } | - |
767 | | - |
768 | ch = str.at(i); | - |
769 | if (ch >= '0' && ch <= '7') { evaluated: ch >= '0' yes Evaluation Count:67573 | yes Evaluation Count:3911 |
partially evaluated: ch <= '7' no Evaluation Count:0 | yes Evaluation Count:67573 |
| 0-67573 |
770 | escapeVal <<= 3; | - |
771 | escapeVal += ch - '0'; | - |
772 | ++i; | - |
773 | goto StOctEscape; never executed: goto StOctEscape; | 0 |
774 | } else { | - |
775 | stringResult += QChar(escapeVal); | - |
776 | goto StNormal; executed: goto StNormal; Execution Count:71484 | 71484 |
777 | } | - |
778 | | - |
779 | end: | - |
780 | if (!currentValueIsQuoted) evaluated: !currentValueIsQuoted yes Evaluation Count:6729 | yes Evaluation Count:276 |
| 276-6729 |
781 | iniChopTrailingSpaces(stringResult); executed: iniChopTrailingSpaces(stringResult); Execution Count:6729 | 6729 |
782 | if (isStringList) evaluated: isStringList yes Evaluation Count:21 | yes Evaluation Count:6984 |
| 21-6984 |
783 | stringListResult.append(stringResult); executed: stringListResult.append(stringResult); Execution Count:21 | 21 |
784 | return isStringList; executed: return isStringList; Execution Count:7005 | 7005 |
785 | } | - |
786 | | - |
787 | QStringList QSettingsPrivate::splitArgs(const QString &s, int idx) | - |
788 | { | - |
789 | int l = s.length(); | - |
790 | qt_noop(); | - |
791 | qt_noop(); | - |
792 | qt_noop(); | - |
793 | | - |
794 | QStringList result; | - |
795 | QString item; | - |
796 | | - |
797 | for (++idx; idx < l; ++idx) { | 0 |
798 | QChar c = s.at(idx); | - |
799 | if (c == QLatin1Char(')')) { never evaluated: c == QLatin1Char(')') | 0 |
800 | qt_noop(); | - |
801 | result.append(item); | - |
802 | } else if (c == QLatin1Char(' ')) { never evaluated: c == QLatin1Char(' ') | 0 |
803 | result.append(item); | - |
804 | item.clear(); | - |
805 | } else { | 0 |
806 | item.append(c); | - |
807 | } | 0 |
808 | } | - |
809 | | - |
810 | return result; never executed: return result; | 0 |
811 | } | - |
812 | | - |
813 | | - |
814 | | - |
815 | | - |
816 | void QConfFileSettingsPrivate::initFormat() | - |
817 | { | - |
818 | extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"); evaluated: (format == QSettings::NativeFormat) yes Evaluation Count:642 | yes Evaluation Count:160 |
| 160-642 |
819 | readFunc = 0; | - |
820 | writeFunc = 0; | - |
821 | | - |
822 | | - |
823 | | - |
824 | caseSensitivity = IniCaseSensitivity; | - |
825 | | - |
826 | | - |
827 | if (format > QSettings::IniFormat) { evaluated: format > QSettings::IniFormat yes Evaluation Count:90 | yes Evaluation Count:712 |
| 90-712 |
828 | QMutexLocker locker(&settingsGlobalMutex); | - |
829 | const CustomFormatVector *customFormatVector = customFormatVectorFunc(); | - |
830 | | - |
831 | int i = (int)format - (int)QSettings::CustomFormat1; | - |
832 | if (i >= 0 && i < customFormatVector->size()) { partially evaluated: i >= 0 yes Evaluation Count:90 | no Evaluation Count:0 |
evaluated: i < customFormatVector->size() yes Evaluation Count:89 | yes Evaluation Count:1 |
| 0-90 |
833 | QConfFileCustomFormat info = customFormatVector->at(i); | - |
834 | extension = info.extension; | - |
835 | readFunc = info.readFunc; | - |
836 | writeFunc = info.writeFunc; | - |
837 | caseSensitivity = info.caseSensitivity; | - |
838 | } executed: } Execution Count:89 | 89 |
839 | } executed: } Execution Count:90 | 90 |
840 | } executed: } Execution Count:802 | 802 |
841 | | - |
842 | void QConfFileSettingsPrivate::initAccess() | - |
843 | { | - |
844 | if (confFiles[spec]) { partially evaluated: confFiles[spec] yes Evaluation Count:802 | no Evaluation Count:0 |
| 0-802 |
845 | if (format > QSettings::IniFormat) { evaluated: format > QSettings::IniFormat yes Evaluation Count:90 | yes Evaluation Count:712 |
| 90-712 |
846 | if (!readFunc) evaluated: !readFunc yes Evaluation Count:1 | yes Evaluation Count:89 |
| 1-89 |
847 | setStatus(QSettings::AccessError); executed: setStatus(QSettings::AccessError); Execution Count:1 | 1 |
848 | } executed: } Execution Count:90 | 90 |
849 | } executed: } Execution Count:802 | 802 |
850 | | - |
851 | sync(); | - |
852 | } executed: } Execution Count:802 | 802 |
853 | static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) | - |
854 | { | - |
855 | return int((uint(format) << 1) | uint(scope == QSettings::SystemScope)); executed: return int((uint(format) << 1) | uint(scope == QSettings::SystemScope)); Execution Count:2081 | 2081 |
856 | } | - |
857 | | - |
858 | static void initDefaultPaths(QMutexLocker *locker) | - |
859 | { | - |
860 | PathHash *pathHash = pathHashFunc(); | - |
861 | QString homePath = QDir::homePath(); | - |
862 | QString systemPath; | - |
863 | | - |
864 | locker->unlock(); | - |
865 | | - |
866 | | - |
867 | | - |
868 | | - |
869 | | - |
870 | | - |
871 | systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); | - |
872 | systemPath += QLatin1Char('/'); | - |
873 | | - |
874 | locker->relock(); | - |
875 | if (pathHash->isEmpty()) { partially evaluated: pathHash->isEmpty() yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
876 | QString userPath; | - |
877 | char *env = getenv("XDG_CONFIG_HOME"); | - |
878 | if (env == 0) { partially evaluated: env == 0 yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
879 | userPath = homePath; | - |
880 | userPath += QLatin1Char('/'); | - |
881 | userPath += QLatin1String(".config"); | - |
882 | } else if (*env == '/') { executed: } Execution Count:5 never evaluated: *env == '/' | 0-5 |
883 | userPath = QFile::decodeName(env); | - |
884 | } else { | 0 |
885 | userPath = homePath; | - |
886 | userPath += QLatin1Char('/'); | - |
887 | userPath += QFile::decodeName(env); | - |
888 | } | 0 |
889 | userPath += QLatin1Char('/'); | - |
890 | | - |
891 | pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath); | - |
892 | pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), systemPath); | - |
893 | | - |
894 | pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::UserScope), userPath); | - |
895 | pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::SystemScope), systemPath); | - |
896 | | - |
897 | | - |
898 | } executed: } Execution Count:5 | 5 |
899 | } executed: } Execution Count:5 | 5 |
900 | | - |
901 | static QString getPath(QSettings::Format format, QSettings::Scope scope) | - |
902 | { | - |
903 | qt_noop(); | - |
904 | qt_noop(); | - |
905 | | - |
906 | QMutexLocker locker(&settingsGlobalMutex); | - |
907 | PathHash *pathHash = pathHashFunc(); | - |
908 | if (pathHash->isEmpty()) evaluated: pathHash->isEmpty() yes Evaluation Count:4 | yes Evaluation Count:1453 |
| 4-1453 |
909 | initDefaultPaths(&locker); executed: initDefaultPaths(&locker); Execution Count:4 | 4 |
910 | | - |
911 | QString result = pathHash->value(pathHashKey(format, scope)); | - |
912 | if (!result.isEmpty()) evaluated: !result.isEmpty() yes Evaluation Count:1349 | yes Evaluation Count:108 |
| 108-1349 |
913 | return result; executed: return result; Execution Count:1349 | 1349 |
914 | | - |
915 | | - |
916 | return pathHash->value(pathHashKey(QSettings::IniFormat, scope)); executed: return pathHash->value(pathHashKey(QSettings::IniFormat, scope)); Execution Count:108 | 108 |
917 | } | - |
918 | | - |
919 | QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format, | - |
920 | QSettings::Scope scope, | - |
921 | const QString &organization, | - |
922 | const QString &application) | - |
923 | : QSettingsPrivate(format, scope, organization, application), | - |
924 | nextPosition(0x40000000) | - |
925 | { | - |
926 | int i; | - |
927 | initFormat(); | - |
928 | | - |
929 | QString org = organization; | - |
930 | if (org.isEmpty()) { evaluated: org.isEmpty() yes Evaluation Count:7 | yes Evaluation Count:751 |
| 7-751 |
931 | setStatus(QSettings::AccessError); | - |
932 | org = QLatin1String("Unknown Organization"); | - |
933 | } executed: } Execution Count:7 | 7 |
934 | | - |
935 | | - |
936 | QString appFile = org + QDir::separator() + application + extension; | - |
937 | QString orgFile = org + extension; | - |
938 | | - |
939 | if (scope == QSettings::UserScope) { evaluated: scope == QSettings::UserScope yes Evaluation Count:699 | yes Evaluation Count:59 |
| 59-699 |
940 | QString userPath = getPath(format, QSettings::UserScope); | - |
941 | if (!application.isEmpty()) evaluated: !application.isEmpty() yes Evaluation Count:114 | yes Evaluation Count:585 |
| 114-585 |
942 | confFiles[F_User | F_Application].reset(QConfFile::fromName(userPath + appFile, true)); executed: confFiles[F_User | F_Application].reset(QConfFile::fromName(userPath + appFile, true)); Execution Count:114 | 114 |
943 | confFiles[F_User | F_Organization].reset(QConfFile::fromName(userPath + orgFile, true)); | - |
944 | } executed: } Execution Count:699 | 699 |
945 | | - |
946 | QString systemPath = getPath(format, QSettings::SystemScope); | - |
947 | if (!application.isEmpty()) evaluated: !application.isEmpty() yes Evaluation Count:156 | yes Evaluation Count:602 |
| 156-602 |
948 | confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false)); executed: confFiles[F_System | F_Application].reset(QConfFile::fromName(systemPath + appFile, false)); Execution Count:156 | 156 |
949 | confFiles[F_System | F_Organization].reset(QConfFile::fromName(systemPath + orgFile, false)); | - |
950 | for (i = 0; i < NumConfFiles; ++i) { partially evaluated: i < NumConfFiles yes Evaluation Count:1478 | no Evaluation Count:0 |
| 0-1478 |
951 | if (confFiles[i]) { evaluated: confFiles[i] yes Evaluation Count:758 | yes Evaluation Count:720 |
| 720-758 |
952 | spec = i; | - |
953 | break; executed: break; Execution Count:758 | 758 |
954 | } | - |
955 | } executed: } Execution Count:720 | 720 |
956 | | - |
957 | initAccess(); | - |
958 | } executed: } Execution Count:758 | 758 |
959 | | - |
960 | QConfFileSettingsPrivate::QConfFileSettingsPrivate(const QString &fileName, | - |
961 | QSettings::Format format) | - |
962 | : QSettingsPrivate(format), | - |
963 | nextPosition(0x40000000) | - |
964 | { | - |
965 | initFormat(); | - |
966 | | - |
967 | confFiles[0].reset(QConfFile::fromName(fileName, true)); | - |
968 | | - |
969 | initAccess(); | - |
970 | } executed: } Execution Count:44 | 44 |
971 | | - |
972 | QConfFileSettingsPrivate::~QConfFileSettingsPrivate() | - |
973 | { | - |
974 | QMutexLocker locker(&settingsGlobalMutex); | - |
975 | ConfFileHash *usedHash = usedHashFunc(); | - |
976 | ConfFileCache *unusedCache = unusedCacheFunc(); | - |
977 | | - |
978 | for (int i = 0; i < NumConfFiles; ++i) { evaluated: i < NumConfFiles yes Evaluation Count:3208 | yes Evaluation Count:802 |
| 802-3208 |
979 | if (confFiles[i] && !confFiles[i]->ref.deref()) { evaluated: confFiles[i] yes Evaluation Count:1771 | yes Evaluation Count:1437 |
evaluated: !confFiles[i]->ref.deref() yes Evaluation Count:1220 | yes Evaluation Count:551 |
| 551-1771 |
980 | if (confFiles[i]->size == 0) { evaluated: confFiles[i]->size == 0 yes Evaluation Count:910 | yes Evaluation Count:310 |
| 310-910 |
981 | delete confFiles[i].take(); | - |
982 | } else { executed: } Execution Count:910 | 910 |
983 | if (usedHash) partially evaluated: usedHash yes Evaluation Count:310 | no Evaluation Count:0 |
| 0-310 |
984 | usedHash->remove(confFiles[i]->name); executed: usedHash->remove(confFiles[i]->name); Execution Count:310 | 310 |
985 | if (unusedCache) { partially evaluated: unusedCache yes Evaluation Count:310 | no Evaluation Count:0 |
| 0-310 |
986 | try { | - |
987 | | - |
988 | unusedCache->insert(confFiles[i]->name, confFiles[i].data(), | - |
989 | 10 + (confFiles[i]->originalKeys.size() / 4)); | - |
990 | confFiles[i].take(); | - |
991 | } catch (...) { executed: } Execution Count:310 | 310 |
992 | | - |
993 | delete confFiles[i].take(); | - |
994 | } | 0 |
995 | } else { executed: } Execution Count:310 | 310 |
996 | | - |
997 | delete confFiles[i].take(); | - |
998 | } | 0 |
999 | } | - |
1000 | } | - |
1001 | | - |
1002 | confFiles[i].take(); | - |
1003 | } executed: } Execution Count:3208 | 3208 |
1004 | } executed: } Execution Count:802 | 802 |
1005 | | - |
1006 | void QConfFileSettingsPrivate::remove(const QString &key) | - |
1007 | { | - |
1008 | QConfFile *confFile = confFiles[spec].data(); | - |
1009 | if (!confFile) partially evaluated: !confFile no Evaluation Count:0 | yes Evaluation Count:125 |
| 0-125 |
1010 | return; | 0 |
1011 | | - |
1012 | QSettingsKey theKey(key, caseSensitivity); | - |
1013 | QSettingsKey prefix(key + QLatin1Char('/'), caseSensitivity); | - |
1014 | QMutexLocker locker(&confFile->mutex); | - |
1015 | | - |
1016 | ensureSectionParsed(confFile, theKey); | - |
1017 | ensureSectionParsed(confFile, prefix); | - |
1018 | | - |
1019 | ParsedSettingsMap::iterator i = confFile->addedKeys.lowerBound(prefix); | - |
1020 | while (i != confFile->addedKeys.end() && i.key().startsWith(prefix)) evaluated: i != confFile->addedKeys.end() yes Evaluation Count:25 | yes Evaluation Count:112 |
evaluated: i.key().startsWith(prefix) yes Evaluation Count:12 | yes Evaluation Count:13 |
| 12-112 |
1021 | i = confFile->addedKeys.erase(i); executed: i = confFile->addedKeys.erase(i); Execution Count:12 | 12 |
1022 | confFile->addedKeys.remove(theKey); | - |
1023 | | - |
1024 | ParsedSettingsMap::const_iterator j = const_cast<const ParsedSettingsMap *>(&confFile->originalKeys)->lowerBound(prefix); | - |
1025 | while (j != confFile->originalKeys.constEnd() && j.key().startsWith(prefix)) { evaluated: j != confFile->originalKeys.constEnd() yes Evaluation Count:18 | yes Evaluation Count:109 |
evaluated: j.key().startsWith(prefix) yes Evaluation Count:2 | yes Evaluation Count:16 |
| 2-109 |
1026 | confFile->removedKeys.insert(j.key(), QVariant()); | - |
1027 | ++j; | - |
1028 | } executed: } Execution Count:2 | 2 |
1029 | if (confFile->originalKeys.contains(theKey)) evaluated: confFile->originalKeys.contains(theKey) yes Evaluation Count:89 | yes Evaluation Count:36 |
| 36-89 |
1030 | confFile->removedKeys.insert(theKey, QVariant()); executed: confFile->removedKeys.insert(theKey, QVariant()); Execution Count:89 | 89 |
1031 | } executed: } Execution Count:125 | 125 |
1032 | | - |
1033 | void QConfFileSettingsPrivate::set(const QString &key, const QVariant &value) | - |
1034 | { | - |
1035 | QConfFile *confFile = confFiles[spec].data(); | - |
1036 | if (!confFile) partially evaluated: !confFile no Evaluation Count:0 | yes Evaluation Count:834 |
| 0-834 |
1037 | return; | 0 |
1038 | | - |
1039 | QSettingsKey theKey(key, caseSensitivity, nextPosition++); | - |
1040 | QMutexLocker locker(&confFile->mutex); | - |
1041 | confFile->removedKeys.remove(theKey); | - |
1042 | confFile->addedKeys.insert(theKey, value); | - |
1043 | } executed: } Execution Count:834 | 834 |
1044 | | - |
1045 | bool QConfFileSettingsPrivate::get(const QString &key, QVariant *value) const | - |
1046 | { | - |
1047 | QSettingsKey theKey(key, caseSensitivity); | - |
1048 | ParsedSettingsMap::const_iterator j; | - |
1049 | bool found = false; | - |
1050 | | - |
1051 | for (int i = 0; i < NumConfFiles; ++i) { evaluated: i < NumConfFiles yes Evaluation Count:6307 | yes Evaluation Count:939 |
| 939-6307 |
1052 | if (QConfFile *confFile = confFiles[i].data()) { evaluated: QConfFile *confFile = confFiles[i].data() yes Evaluation Count:3145 | yes Evaluation Count:3162 |
| 3145-3162 |
1053 | QMutexLocker locker(&confFile->mutex); | - |
1054 | | - |
1055 | if (!confFile->addedKeys.isEmpty()) { evaluated: !confFile->addedKeys.isEmpty() yes Evaluation Count:699 | yes Evaluation Count:2446 |
| 699-2446 |
1056 | j = confFile->addedKeys.constFind(theKey); | - |
1057 | found = (j != confFile->addedKeys.constEnd()); | - |
1058 | } executed: } Execution Count:699 | 699 |
1059 | if (!found) { evaluated: !found yes Evaluation Count:2568 | yes Evaluation Count:577 |
| 577-2568 |
1060 | ensureSectionParsed(confFile, theKey); | - |
1061 | j = confFile->originalKeys.constFind(theKey); | - |
1062 | found = (j != confFile->originalKeys.constEnd() evaluated: j != confFile->originalKeys.constEnd() yes Evaluation Count:1197 | yes Evaluation Count:1371 |
| 1197-1371 |
1063 | && !confFile->removedKeys.contains(theKey)); evaluated: !confFile->removedKeys.contains(theKey) yes Evaluation Count:1192 | yes Evaluation Count:5 |
| 5-1192 |
1064 | } executed: } Execution Count:2568 | 2568 |
1065 | | - |
1066 | if (found && value) evaluated: found yes Evaluation Count:1769 | yes Evaluation Count:1376 |
evaluated: value yes Evaluation Count:1662 | yes Evaluation Count:107 |
| 107-1769 |
1067 | *value = *j; executed: *value = *j; Execution Count:1662 | 1662 |
1068 | | - |
1069 | if (found) evaluated: found yes Evaluation Count:1769 | yes Evaluation Count:1376 |
| 1376-1769 |
1070 | return true; executed: return true; Execution Count:1769 | 1769 |
1071 | if (!fallbacks) evaluated: !fallbacks yes Evaluation Count:24 | yes Evaluation Count:1352 |
| 24-1352 |
1072 | break; executed: break; Execution Count:24 | 24 |
1073 | } executed: } Execution Count:1352 | 1352 |
1074 | } executed: } Execution Count:4514 | 4514 |
1075 | return false; executed: return false; Execution Count:963 | 963 |
1076 | } | - |
1077 | | - |
1078 | QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec spec) const | - |
1079 | { | - |
1080 | QMap<QString, QString> result; | - |
1081 | ParsedSettingsMap::const_iterator j; | - |
1082 | | - |
1083 | QSettingsKey thePrefix(prefix, caseSensitivity); | - |
1084 | int startPos = prefix.size(); | - |
1085 | | - |
1086 | for (int i = 0; i < NumConfFiles; ++i) { evaluated: i < NumConfFiles yes Evaluation Count:544 | yes Evaluation Count:116 |
| 116-544 |
1087 | if (QConfFile *confFile = confFiles[i].data()) { evaluated: QConfFile *confFile = confFiles[i].data() yes Evaluation Count:421 | yes Evaluation Count:123 |
| 123-421 |
1088 | QMutexLocker locker(&confFile->mutex); | - |
1089 | | - |
1090 | if (thePrefix.isEmpty()) { evaluated: thePrefix.isEmpty() yes Evaluation Count:117 | yes Evaluation Count:304 |
| 117-304 |
1091 | ensureAllSectionsParsed(confFile); | - |
1092 | } else { executed: } Execution Count:117 | 117 |
1093 | ensureSectionParsed(confFile, thePrefix); | - |
1094 | } executed: } Execution Count:304 | 304 |
1095 | | - |
1096 | j = const_cast<const ParsedSettingsMap *>( | - |
1097 | &confFile->originalKeys)->lowerBound( thePrefix); | - |
1098 | while (j != confFile->originalKeys.constEnd() && j.key().startsWith(thePrefix)) { evaluated: j != confFile->originalKeys.constEnd() yes Evaluation Count:1208 | yes Evaluation Count:409 |
evaluated: j.key().startsWith(thePrefix) yes Evaluation Count:1196 | yes Evaluation Count:12 |
| 12-1208 |
1099 | if (!confFile->removedKeys.contains(j.key())) evaluated: !confFile->removedKeys.contains(j.key()) yes Evaluation Count:1190 | yes Evaluation Count:6 |
| 6-1190 |
1100 | processChild(j.key().originalCaseKey().mid(startPos), spec, result); executed: processChild(j.key().originalCaseKey().mid(startPos), spec, result); Execution Count:1190 | 1190 |
1101 | ++j; | - |
1102 | } executed: } Execution Count:1196 | 1196 |
1103 | | - |
1104 | j = const_cast<const ParsedSettingsMap *>( | - |
1105 | &confFile->addedKeys)->lowerBound(thePrefix); | - |
1106 | while (j != confFile->addedKeys.constEnd() && j.key().startsWith(thePrefix)) { evaluated: j != confFile->addedKeys.constEnd() yes Evaluation Count:404 | yes Evaluation Count:384 |
evaluated: j.key().startsWith(thePrefix) yes Evaluation Count:367 | yes Evaluation Count:37 |
| 37-404 |
1107 | processChild(j.key().originalCaseKey().mid(startPos), spec, result); | - |
1108 | ++j; | - |
1109 | } executed: } Execution Count:367 | 367 |
1110 | | - |
1111 | if (!fallbacks) evaluated: !fallbacks yes Evaluation Count:40 | yes Evaluation Count:381 |
| 40-381 |
1112 | break; executed: break; Execution Count:40 | 40 |
1113 | } executed: } Execution Count:381 | 381 |
1114 | } executed: } Execution Count:504 | 504 |
1115 | return result.keys(); executed: return result.keys(); Execution Count:156 | 156 |
1116 | } | - |
1117 | | - |
1118 | void QConfFileSettingsPrivate::clear() | - |
1119 | { | - |
1120 | QConfFile *confFile = confFiles[spec].data(); | - |
1121 | if (!confFile) partially evaluated: !confFile no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
1122 | return; | 0 |
1123 | | - |
1124 | QMutexLocker locker(&confFile->mutex); | - |
1125 | ensureAllSectionsParsed(confFile); | - |
1126 | confFile->addedKeys.clear(); | - |
1127 | confFile->removedKeys = confFile->originalKeys; | - |
1128 | } executed: } Execution Count:15 | 15 |
1129 | | - |
1130 | void QConfFileSettingsPrivate::sync() | - |
1131 | { | - |
1132 | | - |
1133 | | - |
1134 | | - |
1135 | for (int i = 0; i < NumConfFiles; ++i) { evaluated: i < NumConfFiles yes Evaluation Count:5435 | yes Evaluation Count:1359 |
| 1359-5435 |
1136 | QConfFile *confFile = confFiles[i].data(); | - |
1137 | if (confFile) { evaluated: confFile yes Evaluation Count:3037 | yes Evaluation Count:2398 |
| 2398-3037 |
1138 | QMutexLocker locker(&confFile->mutex); | - |
1139 | syncConfFile(i); | - |
1140 | } executed: } Execution Count:3038 | 3038 |
1141 | } executed: } Execution Count:5436 | 5436 |
1142 | } executed: } Execution Count:1359 | 1359 |
1143 | | - |
1144 | void QConfFileSettingsPrivate::flush() | - |
1145 | { | - |
1146 | sync(); | - |
1147 | } executed: } Execution Count:495 | 495 |
1148 | | - |
1149 | QString QConfFileSettingsPrivate::fileName() const | - |
1150 | { | - |
1151 | QConfFile *confFile = confFiles[spec].data(); | - |
1152 | if (!confFile) partially evaluated: !confFile no Evaluation Count:0 | yes Evaluation Count:25 |
| 0-25 |
1153 | return QString(); never executed: return QString(); | 0 |
1154 | return confFile->name; executed: return confFile->name; Execution Count:25 | 25 |
1155 | } | - |
1156 | | - |
1157 | bool QConfFileSettingsPrivate::isWritable() const | - |
1158 | { | - |
1159 | if (format > QSettings::IniFormat && !writeFunc) evaluated: format > QSettings::IniFormat yes Evaluation Count:12 | yes Evaluation Count:9 |
evaluated: !writeFunc yes Evaluation Count:1 | yes Evaluation Count:11 |
| 1-12 |
1160 | return false; executed: return false; Execution Count:1 | 1 |
1161 | | - |
1162 | QConfFile *confFile = confFiles[spec].data(); | - |
1163 | if (!confFile) partially evaluated: !confFile no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1164 | return false; never executed: return false; | 0 |
1165 | | - |
1166 | return confFile->isWritable(); executed: return confFile->isWritable(); Execution Count:20 | 20 |
1167 | } | - |
1168 | | - |
1169 | void QConfFileSettingsPrivate::syncConfFile(int confFileNo) | - |
1170 | { | - |
1171 | QConfFile *confFile = confFiles[confFileNo].data(); | - |
1172 | bool readOnly = confFile->addedKeys.isEmpty() && confFile->removedKeys.isEmpty(); evaluated: confFile->addedKeys.isEmpty() yes Evaluation Count:2629 | yes Evaluation Count:408 |
evaluated: confFile->removedKeys.isEmpty() yes Evaluation Count:2542 | yes Evaluation Count:87 |
| 87-2629 |
1173 | bool ok; | - |
1174 | | - |
1175 | | - |
1176 | | - |
1177 | | - |
1178 | | - |
1179 | if (readOnly && confFile->size > 0) { evaluated: readOnly yes Evaluation Count:2542 | yes Evaluation Count:495 |
evaluated: confFile->size > 0 yes Evaluation Count:356 | yes Evaluation Count:2186 |
| 356-2542 |
1180 | QFileInfo fileInfo(confFile->name); | - |
1181 | if (confFile->size == fileInfo.size() && confFile->timeStamp == fileInfo.lastModified()) evaluated: confFile->size == fileInfo.size() yes Evaluation Count:324 | yes Evaluation Count:32 |
partially evaluated: confFile->timeStamp == fileInfo.lastModified() yes Evaluation Count:324 | no Evaluation Count:0 |
| 0-324 |
1182 | return; executed: return; Execution Count:324 | 324 |
1183 | } executed: } Execution Count:32 | 32 |
1184 | QFile file(confFile->name); | - |
1185 | bool createFile = !file.exists(); | - |
1186 | if (!readOnly && confFile->isWritable()) evaluated: !readOnly yes Evaluation Count:495 | yes Evaluation Count:2219 |
evaluated: confFile->isWritable() yes Evaluation Count:493 | yes Evaluation Count:2 |
| 2-2219 |
1187 | file.open(QFile::ReadWrite); executed: file.open(QFile::ReadWrite); Execution Count:493 | 493 |
1188 | if (!file.isOpen()) evaluated: !file.isOpen() yes Evaluation Count:2221 | yes Evaluation Count:493 |
| 493-2221 |
1189 | file.open(QFile::ReadOnly); executed: file.open(QFile::ReadOnly); Execution Count:2221 | 2221 |
1190 | | - |
1191 | if (!createFile && !file.isOpen()) evaluated: !createFile yes Evaluation Count:859 | yes Evaluation Count:1855 |
partially evaluated: !file.isOpen() no Evaluation Count:0 | yes Evaluation Count:859 |
| 0-1855 |
1192 | setStatus(QSettings::AccessError); never executed: setStatus(QSettings::AccessError); | 0 |
1193 | if (file.isOpen()) evaluated: file.isOpen() yes Evaluation Count:949 | yes Evaluation Count:1765 |
| 949-1765 |
1194 | unixLock(file.handle(), readOnly ? 0 : 1); executed: unixLock(file.handle(), readOnly ? 0 : 1); Execution Count:949 | 949 |
1195 | | - |
1196 | | - |
1197 | | - |
1198 | if (file.isOpen()) { evaluated: file.isOpen() yes Evaluation Count:949 | yes Evaluation Count:1765 |
| 949-1765 |
1199 | if (createFile) { evaluated: createFile yes Evaluation Count:90 | yes Evaluation Count:859 |
| 90-859 |
1200 | QFile::Permissions perms = file.permissions() | QFile::ReadOwner | QFile::WriteOwner; | - |
1201 | if (!confFile->userPerms) evaluated: !confFile->userPerms yes Evaluation Count:20 | yes Evaluation Count:70 |
| 20-70 |
1202 | perms |= QFile::ReadGroup | QFile::ReadOther; executed: perms |= QFile::ReadGroup | QFile::ReadOther; Execution Count:20 | 20 |
1203 | file.setPermissions(perms); | - |
1204 | } executed: } Execution Count:90 | 90 |
1205 | } executed: } Execution Count:949 | 949 |
1206 | | - |
1207 | | - |
1208 | | - |
1209 | | - |
1210 | | - |
1211 | QFileInfo fileInfo(confFile->name); | - |
1212 | bool mustReadFile = true; | - |
1213 | | - |
1214 | if (!readOnly) evaluated: !readOnly yes Evaluation Count:495 | yes Evaluation Count:2219 |
| 495-2219 |
1215 | mustReadFile = (confFile->size != fileInfo.size() evaluated: confFile->size != fileInfo.size() yes Evaluation Count:14 | yes Evaluation Count:481 |
| 14-495 |
1216 | || (confFile->size != 0 && confFile->timeStamp != fileInfo.lastModified())); executed: mustReadFile = (confFile->size != fileInfo.size() || (confFile->size != 0 && confFile->timeStamp != fileInfo.lastModified())); Execution Count:495 evaluated: confFile->size != 0 yes Evaluation Count:390 | yes Evaluation Count:91 |
partially evaluated: confFile->timeStamp != fileInfo.lastModified() no Evaluation Count:0 | yes Evaluation Count:390 |
| 0-495 |
1217 | | - |
1218 | if (mustReadFile) { evaluated: mustReadFile yes Evaluation Count:2233 | yes Evaluation Count:481 |
| 481-2233 |
1219 | confFile->unparsedIniSections.clear(); | - |
1220 | confFile->originalKeys.clear(); | - |
1221 | | - |
1222 | | - |
1223 | | - |
1224 | | - |
1225 | | - |
1226 | if (file.isReadable() && fileInfo.size() != 0) { evaluated: file.isReadable() yes Evaluation Count:468 | yes Evaluation Count:1765 |
evaluated: fileInfo.size() != 0 yes Evaluation Count:466 | yes Evaluation Count:2 |
| 2-1765 |
1227 | | - |
1228 | | - |
1229 | | - |
1230 | | - |
1231 | | - |
1232 | { | - |
1233 | if (format <= QSettings::IniFormat) { evaluated: format <= QSettings::IniFormat yes Evaluation Count:431 | yes Evaluation Count:35 |
| 35-431 |
1234 | QByteArray data = file.readAll(); | - |
1235 | ok = readIniFile(data, &confFile->unparsedIniSections); | - |
1236 | } else { executed: } Execution Count:431 | 431 |
1237 | if (readFunc) { partially evaluated: readFunc yes Evaluation Count:35 | no Evaluation Count:0 |
| 0-35 |
1238 | QSettings::SettingsMap tempNewKeys; | - |
1239 | ok = readFunc(file, tempNewKeys); | - |
1240 | | - |
1241 | if (ok) { evaluated: ok yes Evaluation Count:34 | yes Evaluation Count:1 |
| 1-34 |
1242 | QSettings::SettingsMap::const_iterator i = tempNewKeys.constBegin(); | - |
1243 | while (i != tempNewKeys.constEnd()) { evaluated: i != tempNewKeys.constEnd() yes Evaluation Count:118 | yes Evaluation Count:34 |
| 34-118 |
1244 | confFile->originalKeys.insert(QSettingsKey(i.key(), | - |
1245 | caseSensitivity), | - |
1246 | i.value()); | - |
1247 | ++i; | - |
1248 | } executed: } Execution Count:118 | 118 |
1249 | } executed: } Execution Count:34 | 34 |
1250 | } else { executed: } Execution Count:35 | 35 |
1251 | ok = false; | - |
1252 | } | 0 |
1253 | } | - |
1254 | } | - |
1255 | | - |
1256 | if (!ok) evaluated: !ok yes Evaluation Count:1 | yes Evaluation Count:465 |
| 1-465 |
1257 | setStatus(QSettings::FormatError); executed: setStatus(QSettings::FormatError); Execution Count:1 | 1 |
1258 | } executed: } Execution Count:466 | 466 |
1259 | | - |
1260 | confFile->size = fileInfo.size(); | - |
1261 | confFile->timeStamp = fileInfo.lastModified(); | - |
1262 | } executed: } Execution Count:2233 | 2233 |
1263 | | - |
1264 | | - |
1265 | | - |
1266 | | - |
1267 | | - |
1268 | if (!readOnly) { evaluated: !readOnly yes Evaluation Count:495 | yes Evaluation Count:2219 |
| 495-2219 |
1269 | ensureAllSectionsParsed(confFile); | - |
1270 | ParsedSettingsMap mergedKeys = confFile->mergedKeyMap(); | - |
1271 | | - |
1272 | if (file.isWritable()) { evaluated: file.isWritable() yes Evaluation Count:493 | yes Evaluation Count:2 |
| 2-493 |
1273 | | - |
1274 | | - |
1275 | | - |
1276 | | - |
1277 | | - |
1278 | { | - |
1279 | file.seek(0); | - |
1280 | file.resize(0); | - |
1281 | | - |
1282 | if (format <= QSettings::IniFormat) { evaluated: format <= QSettings::IniFormat yes Evaluation Count:450 | yes Evaluation Count:43 |
| 43-450 |
1283 | ok = writeIniFile(file, mergedKeys); | - |
1284 | if (!ok) { partially evaluated: !ok no Evaluation Count:0 | yes Evaluation Count:450 |
| 0-450 |
1285 | | - |
1286 | | - |
1287 | file.seek(0); | - |
1288 | file.resize(0); | - |
1289 | writeIniFile(file, confFile->originalKeys); | - |
1290 | } | 0 |
1291 | } else { executed: } Execution Count:450 | 450 |
1292 | if (writeFunc) { partially evaluated: writeFunc yes Evaluation Count:43 | no Evaluation Count:0 |
| 0-43 |
1293 | QSettings::SettingsMap tempOriginalKeys; | - |
1294 | | - |
1295 | ParsedSettingsMap::const_iterator i = mergedKeys.constBegin(); | - |
1296 | while (i != mergedKeys.constEnd()) { evaluated: i != mergedKeys.constEnd() yes Evaluation Count:155 | yes Evaluation Count:43 |
| 43-155 |
1297 | tempOriginalKeys.insert(i.key(), i.value()); | - |
1298 | ++i; | - |
1299 | } executed: } Execution Count:155 | 155 |
1300 | ok = writeFunc(file, tempOriginalKeys); | - |
1301 | } else { executed: } Execution Count:43 | 43 |
1302 | ok = false; | - |
1303 | } | 0 |
1304 | } | - |
1305 | } | - |
1306 | } else { | - |
1307 | ok = false; | - |
1308 | } executed: } Execution Count:2 | 2 |
1309 | | - |
1310 | if (ok) { evaluated: ok yes Evaluation Count:491 | yes Evaluation Count:4 |
| 4-491 |
1311 | confFile->unparsedIniSections.clear(); | - |
1312 | confFile->originalKeys = mergedKeys; | - |
1313 | confFile->addedKeys.clear(); | - |
1314 | confFile->removedKeys.clear(); | - |
1315 | | - |
1316 | QFileInfo fileInfo(confFile->name); | - |
1317 | confFile->size = fileInfo.size(); | - |
1318 | confFile->timeStamp = fileInfo.lastModified(); | - |
1319 | } else { executed: } Execution Count:491 | 491 |
1320 | setStatus(QSettings::AccessError); | - |
1321 | } executed: } Execution Count:4 | 4 |
1322 | } | - |
1323 | } executed: } Execution Count:2714 | 2714 |
1324 | | - |
1325 | enum { Space = 0x1, Special = 0x2 }; | - |
1326 | | - |
1327 | static const char charTraits[256] = | - |
1328 | { | - |
1329 | | - |
1330 | | - |
1331 | | - |
1332 | 0, 0, 0, 0, 0, 0, 0, 0, 0, Space, Space | Special, 0, 0, Space | Special, 0, 0, | - |
1333 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1334 | Space, 0, Special, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1335 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Special, 0, Special, 0, 0, | - |
1336 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1337 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Special, 0, 0, 0, | - |
1338 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1339 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1340 | | - |
1341 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1342 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1343 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1344 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1345 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1346 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1347 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - |
1348 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | - |
1349 | }; | - |
1350 | | - |
1351 | bool QConfFileSettingsPrivate::readIniLine(const QByteArray &data, int &dataPos, | - |
1352 | int &lineStart, int &lineLen, int &equalsPos) | - |
1353 | { | - |
1354 | int dataLen = data.length(); | - |
1355 | bool inQuotes = false; | - |
1356 | | - |
1357 | equalsPos = -1; | - |
1358 | | - |
1359 | lineStart = dataPos; | - |
1360 | while (lineStart < dataLen && (charTraits[uint(uchar(data.at(lineStart)))] & Space)) evaluated: lineStart < dataLen yes Evaluation Count:30389 | yes Evaluation Count:1425 |
evaluated: (charTraits[uint(uchar(data.at(lineStart)))] & Space) yes Evaluation Count:15701 | yes Evaluation Count:14688 |
| 1425-30389 |
1361 | ++lineStart; executed: ++lineStart; Execution Count:15701 | 15701 |
1362 | | - |
1363 | int i = lineStart; | - |
1364 | while (i < dataLen) { evaluated: i < dataLen yes Evaluation Count:226138 | yes Evaluation Count:1425 |
| 1425-226138 |
1365 | while (!(charTraits[uint(uchar(data.at(i)))] & Special)) { evaluated: !(charTraits[uint(uchar(data.at(i)))] & Special) yes Evaluation Count:423578 | yes Evaluation Count:226138 |
| 226138-423578 |
1366 | if (++i == dataLen) partially evaluated: ++i == dataLen no Evaluation Count:0 | yes Evaluation Count:423578 |
| 0-423578 |
1367 | goto break_out_of_outer_loop; never executed: goto break_out_of_outer_loop; | 0 |
1368 | } executed: } Execution Count:423578 | 423578 |
1369 | | - |
1370 | char ch = data.at(i++); | - |
1371 | if (ch == '=') { evaluated: ch == '=' yes Evaluation Count:15025 | yes Evaluation Count:211113 |
| 15025-211113 |
1372 | if (!inQuotes && equalsPos == -1) evaluated: !inQuotes yes Evaluation Count:14053 | yes Evaluation Count:972 |
partially evaluated: equalsPos == -1 yes Evaluation Count:14053 | no Evaluation Count:0 |
| 0-14053 |
1373 | equalsPos = i - 1; executed: equalsPos = i - 1; Execution Count:14053 | 14053 |
1374 | } else if (ch == '\n' || ch == '\r') { executed: } Execution Count:15025 evaluated: ch == '\n' yes Evaluation Count:14688 | yes Evaluation Count:196425 |
partially evaluated: ch == '\r' no Evaluation Count:0 | yes Evaluation Count:196425 |
| 0-196425 |
1375 | if (i == lineStart + 1) { partially evaluated: i == lineStart + 1 no Evaluation Count:0 | yes Evaluation Count:14688 |
| 0-14688 |
1376 | ++lineStart; | - |
1377 | } else if (!inQuotes) { partially evaluated: !inQuotes yes Evaluation Count:14688 | no Evaluation Count:0 |
| 0-14688 |
1378 | --i; | - |
1379 | goto break_out_of_outer_loop; executed: goto break_out_of_outer_loop; Execution Count:14688 | 14688 |
1380 | } | - |
1381 | } else if (ch == '\\') { evaluated: ch == '\\' yes Evaluation Count:195321 | yes Evaluation Count:1104 |
| 1104-195321 |
1382 | if (i < dataLen) { partially evaluated: i < dataLen yes Evaluation Count:195321 | no Evaluation Count:0 |
| 0-195321 |
1383 | char ch = data.at(i++); | - |
1384 | if (i < dataLen) { partially evaluated: i < dataLen yes Evaluation Count:195321 | no Evaluation Count:0 |
| 0-195321 |
1385 | char ch2 = data.at(i); | - |
1386 | | - |
1387 | if ((ch == '\n' && ch2 == '\r') || (ch == '\r' && ch2 == '\n')) partially evaluated: ch == '\n' no Evaluation Count:0 | yes Evaluation Count:195321 |
never evaluated: ch2 == '\r' partially evaluated: ch == '\r' no Evaluation Count:0 | yes Evaluation Count:195321 |
never evaluated: ch2 == '\n' | 0-195321 |
1388 | ++i; | 0 |
1389 | } executed: } Execution Count:195321 | 195321 |
1390 | } executed: } Execution Count:195321 | 195321 |
1391 | } else if (ch == '"') { executed: } Execution Count:195321 partially evaluated: ch == '"' yes Evaluation Count:1104 | no Evaluation Count:0 |
| 0-195321 |
1392 | inQuotes = !inQuotes; | - |
1393 | } else { executed: } Execution Count:1104 | 1104 |
1394 | qt_noop(); | - |
1395 | | - |
1396 | if (i == lineStart + 1) { never evaluated: i == lineStart + 1 | 0 |
1397 | char ch; | - |
1398 | while (i < dataLen && ((ch = data.at(i) != '\n') && ch != '\r')) never evaluated: i < dataLen never evaluated: (ch = data.at(i) != '\n') never evaluated: ch != '\r' | 0 |
1399 | ++i; | 0 |
1400 | lineStart = i; | - |
1401 | } else if (!inQuotes) { never evaluated: !inQuotes | 0 |
1402 | --i; | - |
1403 | goto break_out_of_outer_loop; never executed: goto break_out_of_outer_loop; | 0 |
1404 | } | - |
1405 | } | - |
1406 | } | - |
1407 | | - |
1408 | break_out_of_outer_loop: code before this statement executed: break_out_of_outer_loop: Execution Count:1425 | 1425 |
1409 | dataPos = i; | - |
1410 | lineLen = i - lineStart; | - |
1411 | return lineLen > 0; executed: return lineLen > 0; Execution Count:16113 | 16113 |
1412 | } | - |
1413 | | - |
1414 | | - |
1415 | | - |
1416 | | - |
1417 | | - |
1418 | | - |
1419 | bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, | - |
1420 | UnparsedSettingsMap *unparsedIniSections) | - |
1421 | { | - |
1422 | QString currentSection; | - |
1423 | int currentSectionStart = 0; | - |
1424 | int dataPos = 0; | - |
1425 | int lineStart; | - |
1426 | int lineLen; | - |
1427 | int equalsPos; | - |
1428 | int position = 0; | - |
1429 | int sectionPosition = 0; | - |
1430 | bool ok = true; | - |
1431 | | - |
1432 | while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) { evaluated: readIniLine(data, dataPos, lineStart, lineLen, equalsPos) yes Evaluation Count:7679 | yes Evaluation Count:431 |
| 431-7679 |
1433 | char ch = data.at(lineStart); | - |
1434 | if (ch == '[') { evaluated: ch == '[' yes Evaluation Count:627 | yes Evaluation Count:7052 |
| 627-7052 |
1435 | { QByteArray §ionData = (*unparsedIniSections)[QSettingsKey(currentSection, IniCaseSensitivity, sectionPosition)]; if (!sectionData.isEmpty()) sectionData.append('\n'); sectionData += data.mid(currentSectionStart, lineStart - currentSectionStart); sectionPosition = ++position; }; never executed: sectionData.append('\n'); partially evaluated: !sectionData.isEmpty() no Evaluation Count:0 | yes Evaluation Count:627 |
| 0-627 |
1436 | | - |
1437 | | - |
1438 | QByteArray iniSection; | - |
1439 | int idx = data.indexOf(']', lineStart); | - |
1440 | if (idx == -1 || idx >= lineStart + lineLen) { partially evaluated: idx == -1 no Evaluation Count:0 | yes Evaluation Count:627 |
partially evaluated: idx >= lineStart + lineLen no Evaluation Count:0 | yes Evaluation Count:627 |
| 0-627 |
1441 | ok = false; | - |
1442 | iniSection = data.mid(lineStart + 1, lineLen - 1); | - |
1443 | } else { | 0 |
1444 | iniSection = data.mid(lineStart + 1, idx - lineStart - 1); | - |
1445 | } executed: } Execution Count:627 | 627 |
1446 | | - |
1447 | iniSection = iniSection.trimmed(); | - |
1448 | | - |
1449 | if (qstricmp(iniSection.constData(), "general") == 0) { evaluated: qstricmp(iniSection.constData(), "general") == 0 yes Evaluation Count:48 | yes Evaluation Count:579 |
| 48-579 |
1450 | currentSection.clear(); | - |
1451 | } else { executed: } Execution Count:48 | 48 |
1452 | if (qstricmp(iniSection.constData(), "%general") == 0) { evaluated: qstricmp(iniSection.constData(), "%general") == 0 yes Evaluation Count:2 | yes Evaluation Count:577 |
| 2-577 |
1453 | currentSection = QLatin1String(iniSection.constData() + 1); | - |
1454 | } else { executed: } Execution Count:2 | 2 |
1455 | currentSection.clear(); | - |
1456 | iniUnescapedKey(iniSection, 0, iniSection.size(), currentSection); | - |
1457 | } executed: } Execution Count:577 | 577 |
1458 | currentSection += QLatin1Char('/'); | - |
1459 | } executed: } Execution Count:579 | 579 |
1460 | currentSectionStart = dataPos; | - |
1461 | } executed: } Execution Count:627 | 627 |
1462 | ++position; | - |
1463 | } executed: } Execution Count:7679 | 7679 |
1464 | | - |
1465 | qt_noop(); | - |
1466 | { QByteArray §ionData = (*unparsedIniSections)[QSettingsKey(currentSection, IniCaseSensitivity, sectionPosition)]; if (!sectionData.isEmpty()) sectionData.append('\n'); sectionData += data.mid(currentSectionStart, lineStart - currentSectionStart); sectionPosition = ++position; }; never executed: sectionData.append('\n'); partially evaluated: !sectionData.isEmpty() no Evaluation Count:0 | yes Evaluation Count:431 |
| 0-431 |
1467 | | - |
1468 | return ok; executed: return ok; Execution Count:431 | 431 |
1469 | | - |
1470 | | - |
1471 | } | - |
1472 | | - |
1473 | bool QConfFileSettingsPrivate::readIniSection(const QSettingsKey §ion, const QByteArray &data, | - |
1474 | ParsedSettingsMap *settingsMap, QTextCodec *codec) | - |
1475 | { | - |
1476 | QStringList strListValue; | - |
1477 | bool sectionIsLowercase = (section == section.originalCaseKey()); | - |
1478 | int equalsPos; | - |
1479 | | - |
1480 | bool ok = true; | - |
1481 | int dataPos = 0; | - |
1482 | int lineStart; | - |
1483 | int lineLen; | - |
1484 | int position = section.originalKeyPosition(); | - |
1485 | | - |
1486 | while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) { evaluated: readIniLine(data, dataPos, lineStart, lineLen, equalsPos) yes Evaluation Count:7009 | yes Evaluation Count:994 |
| 994-7009 |
1487 | char ch = data.at(lineStart); | - |
1488 | qt_noop(); | - |
1489 | | - |
1490 | if (equalsPos == -1) { evaluated: equalsPos == -1 yes Evaluation Count:4 | yes Evaluation Count:7005 |
| 4-7005 |
1491 | if (ch != ';') partially evaluated: ch != ';' yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1492 | ok = false; executed: ok = false; Execution Count:4 | 4 |
1493 | continue; executed: continue; Execution Count:4 | 4 |
1494 | } | - |
1495 | | - |
1496 | int keyEnd = equalsPos; | - |
1497 | while (keyEnd > lineStart && ((ch = data.at(keyEnd - 1)) == ' ' || ch == '\t')) partially evaluated: keyEnd > lineStart yes Evaluation Count:7005 | no Evaluation Count:0 |
partially evaluated: (ch = data.at(keyEnd - 1)) == ' ' no Evaluation Count:0 | yes Evaluation Count:7005 |
partially evaluated: ch == '\t' no Evaluation Count:0 | yes Evaluation Count:7005 |
| 0-7005 |
1498 | --keyEnd; never executed: --keyEnd; | 0 |
1499 | int valueStart = equalsPos + 1; | - |
1500 | | - |
1501 | QString key = section.originalCaseKey(); | - |
1502 | bool keyIsLowercase = (iniUnescapedKey(data, lineStart, keyEnd, key) && sectionIsLowercase); evaluated: iniUnescapedKey(data, lineStart, keyEnd, key) yes Evaluation Count:559 | yes Evaluation Count:6446 |
partially evaluated: sectionIsLowercase yes Evaluation Count:559 | no Evaluation Count:0 |
| 0-6446 |
1503 | | - |
1504 | QString strValue; | - |
1505 | strValue.reserve(lineLen - (valueStart - lineStart)); | - |
1506 | bool isStringList = iniUnescapedStringList(data, valueStart, lineStart + lineLen, | - |
1507 | strValue, strListValue, codec); | - |
1508 | QVariant variant; | - |
1509 | if (isStringList) { evaluated: isStringList yes Evaluation Count:21 | yes Evaluation Count:6984 |
| 21-6984 |
1510 | variant = stringListToVariantList(strListValue); | - |
1511 | } else { executed: } Execution Count:21 | 21 |
1512 | variant = stringToVariant(strValue); | - |
1513 | } executed: } Execution Count:6984 | 6984 |
1514 | | - |
1515 | | - |
1516 | | - |
1517 | | - |
1518 | | - |
1519 | | - |
1520 | settingsMap->insert(QSettingsKey(key, keyIsLowercase ? Qt::CaseSensitive | - |
1521 | : IniCaseSensitivity, | - |
1522 | position), | - |
1523 | variant); | - |
1524 | ++position; | - |
1525 | } executed: } Execution Count:7005 | 7005 |
1526 | | - |
1527 | return ok; executed: return ok; Execution Count:994 | 994 |
1528 | } | - |
1529 | | - |
1530 | class QSettingsIniKey : public QString | - |
1531 | { | - |
1532 | public: | - |
1533 | inline QSettingsIniKey() : position(-1) {} | 0 |
1534 | inline QSettingsIniKey(const QString &str, int pos = -1) : QString(str), position(pos) {} executed: } Execution Count:6972 | 6972 |
1535 | | - |
1536 | int position; | - |
1537 | }; | - |
1538 | | - |
1539 | static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2) | - |
1540 | { | - |
1541 | if (k1.position != k2.position) partially evaluated: k1.position != k2.position no Evaluation Count:0 | yes Evaluation Count:47855 |
| 0-47855 |
1542 | return k1.position < k2.position; never executed: return k1.position < k2.position; | 0 |
1543 | return static_cast<const QString &>(k1) < static_cast<const QString &>(k2); executed: return static_cast<const QString &>(k1) < static_cast<const QString &>(k2); Execution Count:47855 | 47855 |
1544 | } | - |
1545 | | - |
1546 | typedef QMap<QSettingsIniKey, QVariant> IniKeyMap; | - |
1547 | | - |
1548 | struct QSettingsIniSection | - |
1549 | { | - |
1550 | int position; | - |
1551 | IniKeyMap keyMap; | - |
1552 | | - |
1553 | inline QSettingsIniSection() : position(-1) {} executed: } Execution Count:463 | 463 |
1554 | }; | - |
1555 | | - |
1556 | typedef QMap<QString, QSettingsIniSection> IniMap; | - |
1557 | | - |
1558 | | - |
1559 | | - |
1560 | | - |
1561 | | - |
1562 | bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSettingsMap &map) | - |
1563 | { | - |
1564 | IniMap iniMap; | - |
1565 | IniMap::const_iterator i; | - |
1566 | | - |
1567 | | - |
1568 | | - |
1569 | | - |
1570 | const char eol = '\n'; | - |
1571 | | - |
1572 | | - |
1573 | for (ParsedSettingsMap::const_iterator j = map.constBegin(); j != map.constEnd(); ++j) { evaluated: j != map.constEnd() yes Evaluation Count:6509 | yes Evaluation Count:450 |
| 450-6509 |
1574 | QString section; | - |
1575 | QSettingsIniKey key(j.key().originalCaseKey(), j.key().originalKeyPosition()); | - |
1576 | int slashPos; | - |
1577 | | - |
1578 | if ((slashPos = key.indexOf(QLatin1Char('/'))) != -1) { evaluated: (slashPos = key.indexOf(QLatin1Char('/'))) != -1 yes Evaluation Count:6261 | yes Evaluation Count:248 |
| 248-6261 |
1579 | section = key.left(slashPos); | - |
1580 | key.remove(0, slashPos + 1); | - |
1581 | } executed: } Execution Count:6261 | 6261 |
1582 | | - |
1583 | QSettingsIniSection &iniSection = iniMap[section]; | - |
1584 | | - |
1585 | | - |
1586 | if (uint(key.position) < uint(iniSection.position)) partially evaluated: uint(key.position) < uint(iniSection.position) no Evaluation Count:0 | yes Evaluation Count:6509 |
| 0-6509 |
1587 | iniSection.position = key.position; never executed: iniSection.position = key.position; | 0 |
1588 | iniSection.keyMap[key] = j.value(); | - |
1589 | } executed: } Execution Count:6509 | 6509 |
1590 | | - |
1591 | const int sectionCount = iniMap.size(); | - |
1592 | QVector<QSettingsIniKey> sections; | - |
1593 | sections.reserve(sectionCount); | - |
1594 | for (i = iniMap.constBegin(); i != iniMap.constEnd(); ++i) evaluated: i != iniMap.constEnd() yes Evaluation Count:463 | yes Evaluation Count:450 |
| 450-463 |
1595 | sections.append(QSettingsIniKey(i.key(), i.value().position)); executed: sections.append(QSettingsIniKey(i.key(), i.value().position)); Execution Count:463 | 463 |
1596 | qSort(sections); | - |
1597 | | - |
1598 | bool writeError = false; | - |
1599 | for (int j = 0; !writeError && j < sectionCount; ++j) { partially evaluated: !writeError yes Evaluation Count:913 | no Evaluation Count:0 |
evaluated: j < sectionCount yes Evaluation Count:463 | yes Evaluation Count:450 |
| 0-913 |
1600 | i = iniMap.constFind(sections.at(j)); | - |
1601 | qt_noop(); | - |
1602 | | - |
1603 | QByteArray realSection; | - |
1604 | | - |
1605 | iniEscapedKey(i.key(), realSection); | - |
1606 | | - |
1607 | if (realSection.isEmpty()) { evaluated: realSection.isEmpty() yes Evaluation Count:51 | yes Evaluation Count:412 |
| 51-412 |
1608 | realSection = "[General]"; | - |
1609 | } else if (qstricmp(realSection.constData(), "general") == 0) { executed: } Execution Count:51 evaluated: qstricmp(realSection.constData(), "general") == 0 yes Evaluation Count:3 | yes Evaluation Count:409 |
| 3-409 |
1610 | realSection = "[%General]"; | - |
1611 | } else { executed: } Execution Count:3 | 3 |
1612 | realSection.prepend('['); | - |
1613 | realSection.append(']'); | - |
1614 | } executed: } Execution Count:409 | 409 |
1615 | | - |
1616 | if (j != 0) evaluated: j != 0 yes Evaluation Count:15 | yes Evaluation Count:448 |
| 15-448 |
1617 | realSection.prepend(eol); executed: realSection.prepend(eol); Execution Count:15 | 15 |
1618 | realSection += eol; | - |
1619 | | - |
1620 | device.write(realSection); | - |
1621 | | - |
1622 | const IniKeyMap &ents = i.value().keyMap; | - |
1623 | for (IniKeyMap::const_iterator j = ents.constBegin(); j != ents.constEnd(); ++j) { evaluated: j != ents.constEnd() yes Evaluation Count:6509 | yes Evaluation Count:463 |
| 463-6509 |
1624 | QByteArray block; | - |
1625 | iniEscapedKey(j.key(), block); | - |
1626 | block += '='; | - |
1627 | | - |
1628 | const QVariant &value = j.value(); | - |
1629 | | - |
1630 | | - |
1631 | | - |
1632 | | - |
1633 | | - |
1634 | | - |
1635 | if (value.type() == QVariant::StringList evaluated: value.type() == QVariant::StringList yes Evaluation Count:11 | yes Evaluation Count:6498 |
| 11-6498 |
1636 | || (value.type() == QVariant::List && value.toList().size() != 1)) { evaluated: value.type() == QVariant::List yes Evaluation Count:9 | yes Evaluation Count:6489 |
evaluated: value.toList().size() != 1 yes Evaluation Count:5 | yes Evaluation Count:4 |
| 4-6489 |
1637 | iniEscapedStringList(variantListToStringList(value.toList()), block, iniCodec); | - |
1638 | } else { executed: } Execution Count:16 | 16 |
1639 | iniEscapedString(variantToString(value), block, iniCodec); | - |
1640 | } executed: } Execution Count:6493 | 6493 |
1641 | block += eol; | - |
1642 | if (device.write(block) == -1) { partially evaluated: device.write(block) == -1 no Evaluation Count:0 | yes Evaluation Count:6509 |
| 0-6509 |
1643 | writeError = true; | - |
1644 | break; | 0 |
1645 | } | - |
1646 | } executed: } Execution Count:6509 | 6509 |
1647 | } executed: } Execution Count:463 | 463 |
1648 | return !writeError; executed: return !writeError; Execution Count:450 | 450 |
1649 | } | - |
1650 | | - |
1651 | void QConfFileSettingsPrivate::ensureAllSectionsParsed(QConfFile *confFile) const | - |
1652 | { | - |
1653 | UnparsedSettingsMap::const_iterator i = confFile->unparsedIniSections.constBegin(); | - |
1654 | const UnparsedSettingsMap::const_iterator end = confFile->unparsedIniSections.constEnd(); | - |
1655 | | - |
1656 | for (; i != end; ++i) { evaluated: i != end yes Evaluation Count:779 | yes Evaluation Count:627 |
| 627-779 |
1657 | if (!QConfFileSettingsPrivate::readIniSection(i.key(), i.value(), &confFile->originalKeys, iniCodec)) evaluated: !QConfFileSettingsPrivate::readIniSection(i.key(), i.value(), &confFile->originalKeys, iniCodec) yes Evaluation Count:2 | yes Evaluation Count:777 |
| 2-777 |
1658 | setStatus(QSettings::FormatError); executed: setStatus(QSettings::FormatError); Execution Count:2 | 2 |
1659 | } executed: } Execution Count:779 | 779 |
1660 | confFile->unparsedIniSections.clear(); | - |
1661 | } executed: } Execution Count:627 | 627 |
1662 | | - |
1663 | void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, | - |
1664 | const QSettingsKey &key) const | - |
1665 | { | - |
1666 | if (confFile->unparsedIniSections.isEmpty()) evaluated: confFile->unparsedIniSections.isEmpty() yes Evaluation Count:2615 | yes Evaluation Count:507 |
| 507-2615 |
1667 | return; executed: return; Execution Count:2615 | 2615 |
1668 | | - |
1669 | UnparsedSettingsMap::iterator i; | - |
1670 | | - |
1671 | int indexOfSlash = key.indexOf(QLatin1Char('/')); | - |
1672 | if (indexOfSlash != -1) { evaluated: indexOfSlash != -1 yes Evaluation Count:477 | yes Evaluation Count:30 |
| 30-477 |
1673 | i = confFile->unparsedIniSections.upperBound(key); | - |
1674 | if (i == confFile->unparsedIniSections.begin()) partially evaluated: i == confFile->unparsedIniSections.begin() no Evaluation Count:0 | yes Evaluation Count:477 |
| 0-477 |
1675 | return; | 0 |
1676 | --i; | - |
1677 | if (i.key().isEmpty() || !key.startsWith(i.key())) evaluated: i.key().isEmpty() yes Evaluation Count:284 | yes Evaluation Count:193 |
partially evaluated: !key.startsWith(i.key()) no Evaluation Count:0 | yes Evaluation Count:193 |
| 0-284 |
1678 | return; executed: return; Execution Count:284 | 284 |
1679 | } else { executed: } Execution Count:193 | 193 |
1680 | i = confFile->unparsedIniSections.begin(); | - |
1681 | if (i == confFile->unparsedIniSections.end() || !i.key().isEmpty()) partially evaluated: i == confFile->unparsedIniSections.end() no Evaluation Count:0 | yes Evaluation Count:30 |
evaluated: !i.key().isEmpty() yes Evaluation Count:8 | yes Evaluation Count:22 |
| 0-30 |
1682 | return; executed: return; Execution Count:8 | 8 |
1683 | } executed: } Execution Count:22 | 22 |
1684 | | - |
1685 | if (!QConfFileSettingsPrivate::readIniSection(i.key(), i.value(), &confFile->originalKeys, iniCodec)) partially evaluated: !QConfFileSettingsPrivate::readIniSection(i.key(), i.value(), &confFile->originalKeys, iniCodec) no Evaluation Count:0 | yes Evaluation Count:215 |
| 0-215 |
1686 | setStatus(QSettings::FormatError); never executed: setStatus(QSettings::FormatError); | 0 |
1687 | confFile->unparsedIniSections.erase(i); | - |
1688 | } executed: } Execution Count:215 | 215 |
1689 | QSettings::QSettings(const QString &organization, const QString &application, QObject *parent) | - |
1690 | : QObject(*QSettingsPrivate::create(NativeFormat, UserScope, organization, application), | - |
1691 | parent) | - |
1692 | { | - |
1693 | } executed: } Execution Count:36 | 36 |
1694 | QSettings::QSettings(Scope scope, const QString &organization, const QString &application, | - |
1695 | QObject *parent) | - |
1696 | : QObject(*QSettingsPrivate::create(NativeFormat, scope, organization, application), parent) | - |
1697 | { | - |
1698 | } executed: } Execution Count:561 | 561 |
1699 | QSettings::QSettings(Format format, Scope scope, const QString &organization, | - |
1700 | const QString &application, QObject *parent) | - |
1701 | : QObject(*QSettingsPrivate::create(format, scope, organization, application), parent) | - |
1702 | { | - |
1703 | } executed: } Execution Count:157 | 157 |
1704 | QSettings::QSettings(const QString &fileName, Format format, QObject *parent) | - |
1705 | : QObject(*QSettingsPrivate::create(fileName, format), parent) | - |
1706 | { | - |
1707 | } executed: } Execution Count:44 | 44 |
1708 | QSettings::QSettings(QObject *parent) | - |
1709 | : QObject(*QSettingsPrivate::create(globalDefaultFormat, UserScope, | - |
1710 | | - |
1711 | | - |
1712 | | - |
1713 | | - |
1714 | | - |
1715 | QCoreApplication::organizationName().isEmpty() | - |
1716 | ? QCoreApplication::organizationDomain() | - |
1717 | : QCoreApplication::organizationName() | - |
1718 | | - |
1719 | , QCoreApplication::applicationName()), | - |
1720 | parent) | - |
1721 | { | - |
1722 | } executed: } Execution Count:4 | 4 |
1723 | QSettings::~QSettings() | - |
1724 | { | - |
1725 | QSettingsPrivate * const d = d_func(); | - |
1726 | if (d->pendingChanges) { evaluated: d->pendingChanges yes Evaluation Count:491 | yes Evaluation Count:311 |
| 311-491 |
1727 | try { | - |
1728 | d->flush(); | - |
1729 | } catch (...) { executed: } Execution Count:491 | 491 |
1730 | ; | - |
1731 | } | 0 |
1732 | } executed: } Execution Count:491 | 491 |
1733 | } executed: } Execution Count:802 | 802 |
1734 | void QSettings::clear() | - |
1735 | { | - |
1736 | QSettingsPrivate * const d = d_func(); | - |
1737 | d->clear(); | - |
1738 | d->requestUpdate(); | - |
1739 | } executed: } Execution Count:14 | 14 |
1740 | void QSettings::sync() | - |
1741 | { | - |
1742 | QSettingsPrivate * const d = d_func(); | - |
1743 | d->sync(); | - |
1744 | } executed: } Execution Count:62 | 62 |
1745 | QString QSettings::fileName() const | - |
1746 | { | - |
1747 | const QSettingsPrivate * const d = d_func(); | - |
1748 | return d->fileName(); executed: return d->fileName(); Execution Count:25 | 25 |
1749 | } | - |
1750 | QSettings::Format QSettings::format() const | - |
1751 | { | - |
1752 | const QSettingsPrivate * const d = d_func(); | - |
1753 | return d->format; executed: return d->format; Execution Count:30 | 30 |
1754 | } | - |
1755 | QSettings::Scope QSettings::scope() const | - |
1756 | { | - |
1757 | const QSettingsPrivate * const d = d_func(); | - |
1758 | return d->scope; executed: return d->scope; Execution Count:28 | 28 |
1759 | } | - |
1760 | QString QSettings::organizationName() const | - |
1761 | { | - |
1762 | const QSettingsPrivate * const d = d_func(); | - |
1763 | return d->organizationName; executed: return d->organizationName; Execution Count:32 | 32 |
1764 | } | - |
1765 | QString QSettings::applicationName() const | - |
1766 | { | - |
1767 | const QSettingsPrivate * const d = d_func(); | - |
1768 | return d->applicationName; executed: return d->applicationName; Execution Count:24 | 24 |
1769 | } | - |
1770 | void QSettings::setIniCodec(QTextCodec *codec) | - |
1771 | { | - |
1772 | QSettingsPrivate * const d = d_func(); | - |
1773 | d->iniCodec = codec; | - |
1774 | } | 0 |
1775 | void QSettings::setIniCodec(const char *codecName) | - |
1776 | { | - |
1777 | QSettingsPrivate * const d = d_func(); | - |
1778 | if (QTextCodec *codec = QTextCodec::codecForName(codecName)) never evaluated: QTextCodec *codec = QTextCodec::codecForName(codecName) | 0 |
1779 | d->iniCodec = codec; never executed: d->iniCodec = codec; | 0 |
1780 | } | 0 |
1781 | QTextCodec *QSettings::iniCodec() const | - |
1782 | { | - |
1783 | const QSettingsPrivate * const d = d_func(); | - |
1784 | return d->iniCodec; never executed: return d->iniCodec; | 0 |
1785 | } | - |
1786 | QSettings::Status QSettings::status() const | - |
1787 | { | - |
1788 | const QSettingsPrivate * const d = d_func(); | - |
1789 | return d->status; executed: return d->status; Execution Count:43 | 43 |
1790 | } | - |
1791 | void QSettings::beginGroup(const QString &prefix) | - |
1792 | { | - |
1793 | QSettingsPrivate * const d = d_func(); | - |
1794 | d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix))); | - |
1795 | } executed: } Execution Count:624 | 624 |
1796 | void QSettings::endGroup() | - |
1797 | { | - |
1798 | QSettingsPrivate * const d = d_func(); | - |
1799 | if (d->groupStack.isEmpty()) { evaluated: d->groupStack.isEmpty() yes Evaluation Count:14 | yes Evaluation Count:64 |
| 14-64 |
1800 | QMessageLogger("io/qsettings.cpp", 2981, __PRETTY_FUNCTION__).warning("QSettings::endGroup: No matching beginGroup()"); | - |
1801 | return; executed: return; Execution Count:14 | 14 |
1802 | } | - |
1803 | | - |
1804 | QSettingsGroup group = d->groupStack.pop(); | - |
1805 | int len = group.toString().size(); | - |
1806 | if (len > 0) evaluated: len > 0 yes Evaluation Count:57 | yes Evaluation Count:7 |
| 7-57 |
1807 | d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1)); executed: d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1)); Execution Count:57 | 57 |
1808 | | - |
1809 | if (group.isArray()) evaluated: group.isArray() yes Evaluation Count:4 | yes Evaluation Count:60 |
| 4-60 |
1810 | QMessageLogger("io/qsettings.cpp", 2991, __PRETTY_FUNCTION__).warning("QSettings::endGroup: Expected endArray() instead"); executed: QMessageLogger("io/qsettings.cpp", 2991, __PRETTY_FUNCTION__).warning("QSettings::endGroup: Expected endArray() instead"); Execution Count:4 | 4 |
1811 | } executed: } Execution Count:64 | 64 |
1812 | | - |
1813 | | - |
1814 | | - |
1815 | | - |
1816 | | - |
1817 | | - |
1818 | QString QSettings::group() const | - |
1819 | { | - |
1820 | const QSettingsPrivate * const d = d_func(); | - |
1821 | return d->groupPrefix.left(d->groupPrefix.size() - 1); executed: return d->groupPrefix.left(d->groupPrefix.size() - 1); Execution Count:118 | 118 |
1822 | } | - |
1823 | int QSettings::beginReadArray(const QString &prefix) | - |
1824 | { | - |
1825 | QSettingsPrivate * const d = d_func(); | - |
1826 | d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), false)); | - |
1827 | return value(QLatin1String("size")).toInt(); executed: return value(QLatin1String("size")).toInt(); Execution Count:20 | 20 |
1828 | } | - |
1829 | void QSettings::beginWriteArray(const QString &prefix, int size) | - |
1830 | { | - |
1831 | QSettingsPrivate * const d = d_func(); | - |
1832 | d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), size < 0)); | - |
1833 | | - |
1834 | if (size < 0) evaluated: size < 0 yes Evaluation Count:12 | yes Evaluation Count:8 |
| 8-12 |
1835 | remove(QLatin1String("size")); executed: remove(QLatin1String("size")); Execution Count:12 | 12 |
1836 | else | - |
1837 | setValue(QLatin1String("size"), size); executed: setValue(QLatin1String("size"), size); Execution Count:8 | 8 |
1838 | } | - |
1839 | | - |
1840 | | - |
1841 | | - |
1842 | | - |
1843 | | - |
1844 | | - |
1845 | | - |
1846 | void QSettings::endArray() | - |
1847 | { | - |
1848 | QSettingsPrivate * const d = d_func(); | - |
1849 | if (d->groupStack.isEmpty()) { partially evaluated: d->groupStack.isEmpty() no Evaluation Count:0 | yes Evaluation Count:44 |
| 0-44 |
1850 | QMessageLogger("io/qsettings.cpp", 3074, __PRETTY_FUNCTION__).warning("QSettings::endArray: No matching beginArray()"); | - |
1851 | return; | 0 |
1852 | } | - |
1853 | | - |
1854 | QSettingsGroup group = d->groupStack.top(); | - |
1855 | int len = group.toString().size(); | - |
1856 | d->groupStack.pop(); | - |
1857 | if (len > 0) partially evaluated: len > 0 yes Evaluation Count:44 | no Evaluation Count:0 |
| 0-44 |
1858 | d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1)); executed: d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1)); Execution Count:44 | 44 |
1859 | | - |
1860 | if (group.arraySizeGuess() != -1) evaluated: group.arraySizeGuess() != -1 yes Evaluation Count:12 | yes Evaluation Count:32 |
| 12-32 |
1861 | setValue(group.name() + QLatin1String("/size"), group.arraySizeGuess()); executed: setValue(group.name() + QLatin1String("/size"), group.arraySizeGuess()); Execution Count:12 | 12 |
1862 | | - |
1863 | if (!group.isArray()) evaluated: !group.isArray() yes Evaluation Count:8 | yes Evaluation Count:36 |
| 8-36 |
1864 | QMessageLogger("io/qsettings.cpp", 3088, __PRETTY_FUNCTION__).warning("QSettings::endArray: Expected endGroup() instead"); executed: QMessageLogger("io/qsettings.cpp", 3088, __PRETTY_FUNCTION__).warning("QSettings::endArray: Expected endGroup() instead"); Execution Count:8 | 8 |
1865 | } executed: } Execution Count:44 | 44 |
1866 | void QSettings::setArrayIndex(int i) | - |
1867 | { | - |
1868 | QSettingsPrivate * const d = d_func(); | - |
1869 | if (d->groupStack.isEmpty() || !d->groupStack.top().isArray()) { partially evaluated: d->groupStack.isEmpty() no Evaluation Count:0 | yes Evaluation Count:148 |
evaluated: !d->groupStack.top().isArray() yes Evaluation Count:20 | yes Evaluation Count:128 |
| 0-148 |
1870 | QMessageLogger("io/qsettings.cpp", 3103, __PRETTY_FUNCTION__).warning("QSettings::setArrayIndex: Missing beginArray()"); | - |
1871 | return; executed: return; Execution Count:20 | 20 |
1872 | } | - |
1873 | | - |
1874 | QSettingsGroup &top = d->groupStack.top(); | - |
1875 | int len = top.toString().size(); | - |
1876 | top.setArrayIndex(qMax(i, 0)); | - |
1877 | d->groupPrefix.replace(d->groupPrefix.size() - len - 1, len, top.toString()); | - |
1878 | } executed: } Execution Count:128 | 128 |
1879 | QStringList QSettings::allKeys() const | - |
1880 | { | - |
1881 | const QSettingsPrivate * const d = d_func(); | - |
1882 | return d->children(d->groupPrefix, QSettingsPrivate::AllKeys); executed: return d->children(d->groupPrefix, QSettingsPrivate::AllKeys); Execution Count:112 | 112 |
1883 | } | - |
1884 | QStringList QSettings::childKeys() const | - |
1885 | { | - |
1886 | const QSettingsPrivate * const d = d_func(); | - |
1887 | return d->children(d->groupPrefix, QSettingsPrivate::ChildKeys); executed: return d->children(d->groupPrefix, QSettingsPrivate::ChildKeys); Execution Count:20 | 20 |
1888 | } | - |
1889 | QStringList QSettings::childGroups() const | - |
1890 | { | - |
1891 | const QSettingsPrivate * const d = d_func(); | - |
1892 | return d->children(d->groupPrefix, QSettingsPrivate::ChildGroups); executed: return d->children(d->groupPrefix, QSettingsPrivate::ChildGroups); Execution Count:24 | 24 |
1893 | } | - |
1894 | bool QSettings::isWritable() const | - |
1895 | { | - |
1896 | const QSettingsPrivate * const d = d_func(); | - |
1897 | return d->isWritable(); executed: return d->isWritable(); Execution Count:21 | 21 |
1898 | } | - |
1899 | void QSettings::setValue(const QString &key, const QVariant &value) | - |
1900 | { | - |
1901 | QSettingsPrivate * const d = d_func(); | - |
1902 | QString k = d->actualKey(key); | - |
1903 | d->set(k, value); | - |
1904 | d->requestUpdate(); | - |
1905 | } executed: } Execution Count:834 | 834 |
1906 | void QSettings::remove(const QString &key) | - |
1907 | { | - |
1908 | QSettingsPrivate * const d = d_func(); | - |
1909 | | - |
1910 | | - |
1911 | | - |
1912 | | - |
1913 | QString theKey = d->normalizedKey(key); | - |
1914 | if (theKey.isEmpty()) evaluated: theKey.isEmpty() yes Evaluation Count:3 | yes Evaluation Count:123 |
| 3-123 |
1915 | theKey = group(); executed: theKey = group(); Execution Count:3 | 3 |
1916 | else | - |
1917 | theKey.prepend(d->groupPrefix); executed: theKey.prepend(d->groupPrefix); Execution Count:123 | 123 |
1918 | | - |
1919 | if (theKey.isEmpty()) { evaluated: theKey.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:125 |
| 1-125 |
1920 | d->clear(); | - |
1921 | } else { executed: } Execution Count:1 | 1 |
1922 | d->remove(theKey); | - |
1923 | } executed: } Execution Count:125 | 125 |
1924 | d->requestUpdate(); | - |
1925 | } executed: } Execution Count:126 | 126 |
1926 | bool QSettings::contains(const QString &key) const | - |
1927 | { | - |
1928 | const QSettingsPrivate * const d = d_func(); | - |
1929 | QString k = d->actualKey(key); | - |
1930 | return d->get(k, 0); executed: return d->get(k, 0); Execution Count:198 | 198 |
1931 | } | - |
1932 | void QSettings::setFallbacksEnabled(bool b) | - |
1933 | { | - |
1934 | QSettingsPrivate * const d = d_func(); | - |
1935 | d->fallbacks = !!b; | - |
1936 | } executed: } Execution Count:22 | 22 |
1937 | bool QSettings::fallbacksEnabled() const | - |
1938 | { | - |
1939 | const QSettingsPrivate * const d = d_func(); | - |
1940 | return d->fallbacks; executed: return d->fallbacks; Execution Count:34 | 34 |
1941 | } | - |
1942 | | - |
1943 | | - |
1944 | | - |
1945 | | - |
1946 | | - |
1947 | bool QSettings::event(QEvent *event) | - |
1948 | { | - |
1949 | QSettingsPrivate * const d = d_func(); | - |
1950 | if (event->type() == QEvent::UpdateRequest) { partially evaluated: event->type() == QEvent::UpdateRequest yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
1951 | d->update(); | - |
1952 | return true; executed: return true; Execution Count:4 | 4 |
1953 | } | - |
1954 | return QObject::event(event); never executed: return QObject::event(event); | 0 |
1955 | } | - |
1956 | QVariant QSettings::value(const QString &key, const QVariant &defaultValue) const | - |
1957 | { | - |
1958 | const QSettingsPrivate * const d = d_func(); | - |
1959 | QVariant result = defaultValue; | - |
1960 | QString k = d->actualKey(key); | - |
1961 | d->get(k, &result); | - |
1962 | return result; executed: return result; Execution Count:2534 | 2534 |
1963 | } | - |
1964 | void QSettings::setDefaultFormat(Format format) | - |
1965 | { | - |
1966 | globalDefaultFormat = format; | - |
1967 | } executed: } Execution Count:2 | 2 |
1968 | QSettings::Format QSettings::defaultFormat() | - |
1969 | { | - |
1970 | return globalDefaultFormat; executed: return globalDefaultFormat; Execution Count:2 | 2 |
1971 | } | - |
1972 | void QSettings::setSystemIniPath(const QString &dir) | - |
1973 | { | - |
1974 | setPath(IniFormat, SystemScope, dir); | - |
1975 | | - |
1976 | setPath(NativeFormat, SystemScope, dir); | - |
1977 | | - |
1978 | } executed: } Execution Count:122 | 122 |
1979 | | - |
1980 | | - |
1981 | | - |
1982 | | - |
1983 | | - |
1984 | | - |
1985 | | - |
1986 | void QSettings::setUserIniPath(const QString &dir) | - |
1987 | { | - |
1988 | setPath(IniFormat, UserScope, dir); | - |
1989 | | - |
1990 | setPath(NativeFormat, UserScope, dir); | - |
1991 | | - |
1992 | } executed: } Execution Count:122 | 122 |
1993 | void QSettings::setPath(Format format, Scope scope, const QString &path) | - |
1994 | { | - |
1995 | QMutexLocker locker(&settingsGlobalMutex); | - |
1996 | PathHash *pathHash = pathHashFunc(); | - |
1997 | if (pathHash->isEmpty()) evaluated: pathHash->isEmpty() yes Evaluation Count:1 | yes Evaluation Count:495 |
| 1-495 |
1998 | initDefaultPaths(&locker); executed: initDefaultPaths(&locker); Execution Count:1 | 1 |
1999 | pathHash->insert(pathHashKey(format, scope), path + QDir::separator()); | - |
2000 | } executed: } Execution Count:496 | 496 |
2001 | QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc readFunc, | - |
2002 | WriteFunc writeFunc, | - |
2003 | Qt::CaseSensitivity caseSensitivity) | - |
2004 | { | - |
2005 | | - |
2006 | qt_noop(); | - |
2007 | | - |
2008 | | - |
2009 | QMutexLocker locker(&settingsGlobalMutex); | - |
2010 | CustomFormatVector *customFormatVector = customFormatVectorFunc(); | - |
2011 | int index = customFormatVector->size(); | - |
2012 | if (index == 16) partially evaluated: index == 16 no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2013 | return QSettings::InvalidFormat; never executed: return QSettings::InvalidFormat; | 0 |
2014 | | - |
2015 | QConfFileCustomFormat info; | - |
2016 | info.extension = QLatin1Char('.'); | - |
2017 | info.extension += extension; | - |
2018 | info.readFunc = readFunc; | - |
2019 | info.writeFunc = writeFunc; | - |
2020 | info.caseSensitivity = caseSensitivity; | - |
2021 | customFormatVector->append(info); | - |
2022 | | - |
2023 | return QSettings::Format((int)QSettings::CustomFormat1 + index); executed: return QSettings::Format((int)QSettings::CustomFormat1 + index); Execution Count:3 | 3 |
2024 | } | - |
2025 | | - |
2026 | | - |
2027 | | - |
| | |