tools/qregexp.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6int qFindString(const QChar *haystack, int haystackLen, int from, -
7 const QChar *needle, int needleLen, Qt::CaseSensitivity cs); -
8const int NumBadChars = 64; -
9 -
10 -
11const int NoOccurrence = 2147483647; -
12const int EmptyCapture = 2147483647; -
13const int InftyLen = 2147483647; -
14const int InftyRep = 1025; -
15const int EOS = -1; -
16 -
17static bool isWord(QChar ch) -
18{ -
19 return ch.isLetterOrNumber() || ch.isMark() || ch == QLatin1Char('_');
executed: return ch.isLetterOrNumber() || ch.isMark() || ch == QLatin1Char('_');
Execution Count:172
172
20} -
21 -
22 -
23 -
24 -
25 -
26static void mergeInto(QVector<int> *a, const QVector<int> &b) -
27{ -
28 int asize = a->size(); -
29 int bsize = b.size(); -
30 if (asize == 0) {
evaluated: asize == 0
TRUEFALSE
yes
Evaluation Count:30995
yes
Evaluation Count:10513
10513-30995
31 *a = b; -
32 -
33 } else if (bsize == 1 && a->at(asize - 1) < b.at(0)) {
executed: }
Execution Count:30997
evaluated: bsize == 1
TRUEFALSE
yes
Evaluation Count:7669
yes
Evaluation Count:2844
evaluated: a->at(asize - 1) < b.at(0)
TRUEFALSE
yes
Evaluation Count:5929
yes
Evaluation Count:1740
1740-30997
34 a->resize(asize + 1); -
35 (*a)[asize] = b.at(0); -
36 -
37 } else if (bsize >= 1) {
executed: }
Execution Count:5930
evaluated: bsize >= 1
TRUEFALSE
yes
Evaluation Count:3648
yes
Evaluation Count:936
936-5930
38 int csize = asize + bsize; -
39 QVector<int> c(csize); -
40 int i = 0, j = 0, k = 0; -
41 while (i < asize) {
evaluated: i < asize
TRUEFALSE
yes
Evaluation Count:8167
yes
Evaluation Count:1484
1484-8167
42 if (j < bsize) {
evaluated: j < bsize
TRUEFALSE
yes
Evaluation Count:6003
yes
Evaluation Count:2164
2164-6003
43 if (a->at(i) == b.at(j)) {
evaluated: a->at(i) == b.at(j)
TRUEFALSE
yes
Evaluation Count:172
yes
Evaluation Count:5831
172-5831
44 ++i; -
45 --csize; -
46 } else if (a->at(i) < b.at(j)) {
executed: }
Execution Count:172
evaluated: a->at(i) < b.at(j)
TRUEFALSE
yes
Evaluation Count:2983
yes
Evaluation Count:2848
172-2983
47 c[k++] = a->at(i++); -
48 } else {
executed: }
Execution Count:2983
2983
49 c[k++] = b.at(j++); -
50 }
executed: }
Execution Count:2848
2848
51 } else { -
52 memcpy(c.data() + k, a->constData() + i, (asize - i) * sizeof(int)); -
53 break;
executed: break;
Execution Count:2164
2164
54 } -
55 } -
56 c.resize(csize); -
57 if (j < bsize)
evaluated: j < bsize
TRUEFALSE
yes
Evaluation Count:1484
yes
Evaluation Count:2164
1484-2164
58 memcpy(c.data() + k, b.constData() + j, (bsize - j) * sizeof(int));
executed: memcpy(c.data() + k, b.constData() + j, (bsize - j) * sizeof(int));
Execution Count:1484
1484
59 *a = c; -
60 }
executed: }
Execution Count:3648
3648
61} -
62static QString wc2rx(const QString &wc_str, const bool enableEscaping) -
63{ -
64 const int wclen = wc_str.length(); -
65 QString rx; -
66 int i = 0; -
67 bool isEscaping = false; -
68 const QChar *wc = wc_str.unicode(); -
69 -
70 while (i < wclen) {
evaluated: i < wclen
TRUEFALSE
yes
Evaluation Count:1008
yes
Evaluation Count:186
186-1008
71 const QChar c = wc[i++]; -
72 switch (c.unicode()) { -
73 case '\\': -
74 if (enableEscaping) {
partially evaluated: enableEscaping
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
75 if (isEscaping) {
evaluated: isEscaping
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:10
2-10
76 rx += QLatin1String("\\\\"); -
77 }
executed: }
Execution Count:2
2
78 if (i == wclen) {
evaluated: i == wclen
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:11
1-11
79 rx += QLatin1String("\\\\"); -
80 }
executed: }
Execution Count:1
1
81 } else {
executed: }
Execution Count:12
12
82 rx += QLatin1String("\\\\"); -
83 }
never executed: }
0
84 isEscaping = true; -
85 break;
executed: break;
Execution Count:12
12
86 case '*': -
87 if (isEscaping) {
partially evaluated: isEscaping
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:119
0-119
88 rx += QLatin1String("\\*"); -
89 isEscaping = false; -
90 } else {
never executed: }
0
91 rx += QLatin1String(".*"); -
92 }
executed: }
Execution Count:119
119
93 break;
executed: break;
Execution Count:119
119
94 case '?': -
95 if (isEscaping) {
evaluated: isEscaping
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
96 rx += QLatin1String("\\?"); -
97 isEscaping = false; -
98 } else {
executed: }
Execution Count:1
1
99 rx += QLatin1Char('.'); -
100 }
executed: }
Execution Count:7
7
101 -
102 break;
executed: break;
Execution Count:8
8
103 case '$': -
104 case '(': -
105 case ')': -
106 case '+': -
107 case '.': -
108 case '^': -
109 case '{': -
110 case '|': -
111 case '}': -
112 if (isEscaping) {
partially evaluated: isEscaping
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
113 isEscaping = false; -
114 rx += QLatin1String("\\\\"); -
115 }
never executed: }
0
116 rx += QLatin1Char('\\'); -
117 rx += c; -
118 break;
executed: break;
Execution Count:61
61
119 case '[': -
120 if (isEscaping) {
evaluated: isEscaping
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:95
3-95
121 isEscaping = false; -
122 rx += QLatin1String("\\["); -
123 } else {
executed: }
Execution Count:3
3
124 rx += c; -
125 if (wc[i] == QLatin1Char('^'))
evaluated: wc[i] == QLatin1Char('^')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:93
2-93
126 rx += wc[i++];
executed: rx += wc[i++];
Execution Count:2
2
127 if (i < wclen) {
evaluated: i < wclen
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:4
4-91
128 if (rx[i] == QLatin1Char(']'))
partially evaluated: rx[i] == QLatin1Char(']')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:91
0-91
129 rx += wc[i++];
never executed: rx += wc[i++];
0
130 while (i < wclen && wc[i] != QLatin1Char(']')) {
evaluated: i < wclen
TRUEFALSE
yes
Evaluation Count:541
yes
Evaluation Count:4
evaluated: wc[i] != QLatin1Char(']')
TRUEFALSE
yes
Evaluation Count:454
yes
Evaluation Count:87
4-541
131 if (wc[i] == QLatin1Char('\\'))
evaluated: wc[i] == QLatin1Char('\\')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:453
1-453
132 rx += QLatin1Char('\\');
executed: rx += QLatin1Char('\\');
Execution Count:1
1
133 rx += wc[i++]; -
134 }
executed: }
Execution Count:454
454
135 }
executed: }
Execution Count:91
91
136 }
executed: }
Execution Count:95
95
137 break;
executed: break;
Execution Count:98
98
138 -
139 case ']': -
140 if(isEscaping){
evaluated: isEscaping
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:93
2-93
141 isEscaping = false; -
142 rx += QLatin1String("\\"); -
143 }
executed: }
Execution Count:2
2
144 rx += c; -
145 break;
executed: break;
Execution Count:95
95
146 -
147 default: -
148 if(isEscaping){
evaluated: isEscaping
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:612
3-612
149 isEscaping = false; -
150 rx += QLatin1String("\\\\"); -
151 }
executed: }
Execution Count:3
3
152 rx += c; -
153 }
executed: }
Execution Count:615
615
154 }
executed: }
Execution Count:1008
1008
155 return rx;
executed: return rx;
Execution Count:186
186
156} -
157 -
158 -
159static int caretIndex(int offset, QRegExp::CaretMode caretMode) -
160{ -
161 if (caretMode == QRegExp::CaretAtZero) {
evaluated: caretMode == QRegExp::CaretAtZero
TRUEFALSE
yes
Evaluation Count:394473
yes
Evaluation Count:22
22-394473
162 return 0;
executed: return 0;
Execution Count:394582
394582
163 } else if (caretMode == QRegExp::CaretAtOffset) {
partially evaluated: caretMode == QRegExp::CaretAtOffset
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-22
164 return offset;
never executed: return offset;
0
165 } else { -
166 return -1;
executed: return -1;
Execution Count:22
22
167 } -
168} -
169 -
170 -
171 -
172 -
173struct QRegExpEngineKey -
174{ -
175 QString pattern; -
176 QRegExp::PatternSyntax patternSyntax; -
177 Qt::CaseSensitivity cs; -
178 -
179 inline QRegExpEngineKey(const QString &pattern, QRegExp::PatternSyntax patternSyntax, -
180 Qt::CaseSensitivity cs) -
181 : pattern(pattern), patternSyntax(patternSyntax), cs(cs) {}
executed: }
Execution Count:526094
526094
182 -
183 inline void clear() { -
184 pattern.clear(); -
185 patternSyntax = QRegExp::RegExp; -
186 cs = Qt::CaseSensitive; -
187 }
never executed: }
0
188}; -
189 -
190static bool operator==(const QRegExpEngineKey &key1, const QRegExpEngineKey &key2) -
191{ -
192 return key1.pattern == key2.pattern && key1.patternSyntax == key2.patternSyntax 295155
193 && key1.cs == key2.cs;
executed: return key1.pattern == key2.pattern && key1.patternSyntax == key2.patternSyntax && key1.cs == key2.cs;
Execution Count:295155
295155
194} -
195 -
196class QRegExpEngine; -
197 -
198 -
199 -
200 -
201 -
202 -
203struct QRegExpMatchState -
204{ -
205 const QChar *in; -
206 int pos; -
207 int caretPos; -
208 int len; -
209 bool minimal; -
210 int *bigArray; -
211 int *inNextStack; -
212 int *curStack; -
213 int *nextStack; -
214 int *curCapBegin; -
215 int *nextCapBegin; -
216 int *curCapEnd; -
217 int *nextCapEnd; -
218 int *tempCapBegin; -
219 int *tempCapEnd; -
220 int *capBegin; -
221 int *capEnd; -
222 int *slideTab; -
223 int *captured; -
224 int slideTabSize; -
225 int capturedSize; -
226 -
227 QList<QVector<int> > sleeping; -
228 -
229 int matchLen; -
230 int oneTestMatchedLen; -
231 -
232 const QRegExpEngine *eng; -
233 -
234 inline QRegExpMatchState() : bigArray(0), captured(0) {}
executed: }
Execution Count:1326702
1326702
235 inline ~QRegExpMatchState() { free(bigArray); }
executed: }
Execution Count:1326700
1326700
236 -
237 void drain() { free(bigArray); bigArray = 0; captured = 0; }
executed: }
Execution Count:526736
526736
238 void prepareForMatch(QRegExpEngine *eng); -
239 void match(const QChar *str, int len, int pos, bool minimal, -
240 bool oneTest, int caretIndex); -
241 bool matchHere(); -
242 bool testAnchor(int i, int a, const int *capBegin); -
243}; -
244 -
245 -
246 -
247 -
248 -
249 -
250 -
251struct QRegExpAutomatonState -
252{ -
253 -
254 int atom; -
255 -
256 int match; -
257 QVector<int> outs; -
258 QMap<int, int> reenter; -
259 QMap<int, int> anchors; -
260 -
261 inline QRegExpAutomatonState() { } -
262 -
263 inline QRegExpAutomatonState(int a, int m) -
264 : atom(a), match(m) { }
executed: }
Execution Count:27689
27689
265 -
266 -
267 -
268 -
269}; -
270 -
271template<> class QTypeInfo<QRegExpAutomatonState > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isLarge = (sizeof(QRegExpAutomatonState)>sizeof(void*)), isPointer = false, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QRegExpAutomatonState) }; static inline const char *name() { return "QRegExpAutomatonState"; } }; -
272 -
273 -
274 -
275 -
276 -
277struct QRegExpCharClassRange -
278{ -
279 ushort from; -
280 ushort len; -
281}; -
282 -
283template<> class QTypeInfo<QRegExpCharClassRange > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isLarge = (sizeof(QRegExpCharClassRange)>sizeof(void*)), isPointer = false, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QRegExpCharClassRange) }; static inline const char *name() { return "QRegExpCharClassRange"; } }; -
284 -
285 -
286 -
287 -
288 -
289 -
290struct QRegExpAtom -
291{ -
292 enum { NoCapture = -1, OfficialCapture = -2, UnofficialCapture = -3 }; -
293 -
294 int parent; -
295 int capture; -
296}; -
297 -
298template<> class QTypeInfo<QRegExpAtom > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isLarge = (sizeof(QRegExpAtom)>sizeof(void*)), isPointer = false, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QRegExpAtom) }; static inline const char *name() { return "QRegExpAtom"; } }; -
299 -
300 -
301struct QRegExpLookahead; -
302 -
303 -
304 -
305 -
306 -
307 -
308struct QRegExpAnchorAlternation -
309{ -
310 int a; -
311 int b; -
312}; -
313 -
314template<> class QTypeInfo<QRegExpAnchorAlternation > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isLarge = (sizeof(QRegExpAnchorAlternation)>sizeof(void*)), isPointer = false, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QRegExpAnchorAlternation) }; static inline const char *name() { return "QRegExpAnchorAlternation"; } }; -
315class QRegExpCharClass -
316{ -
317public: -
318 QRegExpCharClass(); -
319 inline QRegExpCharClass(const QRegExpCharClass &cc) { operator=(cc); }
executed: }
Execution Count:16011
16011
320 -
321 QRegExpCharClass &operator=(const QRegExpCharClass &cc); -
322 -
323 void clear(); -
324 bool negative() const { return n; }
executed: return n;
Execution Count:440662
440662
325 void setNegative(bool negative); -
326 void addCategories(uint cats); -
327 void addRange(ushort from, ushort to); -
328 void addSingleton(ushort ch) { addRange(ch, ch); }
executed: }
Execution Count:6024
6024
329 -
330 bool in(QChar ch) const; -
331 -
332 const QVector<int> &firstOccurrence() const { return occ1; }
executed: return occ1;
Execution Count:5337
5337
333 -
334 -
335 -
336 -
337 -
338 -
339private: -
340 uint c; -
341 QVector<QRegExpCharClassRange> r; -
342 bool n; -
343 -
344 QVector<int> occ1; -
345 -
346}; -
347template<> class QTypeInfo<QRegExpCharClass > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isLarge = (sizeof(QRegExpCharClass)>sizeof(void*)), isPointer = false, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QRegExpCharClass) }; static inline const char *name() { return "QRegExpCharClass"; } }; -
348 -
349 -
350 -
351 -
352 -
353class QRegExpEngine -
354{ -
355public: -
356 QRegExpEngine(Qt::CaseSensitivity cs, bool greedyQuantifiers) -
357 : cs(cs), greedyQuantifiers(greedyQuantifiers) { setup(); }
executed: }
Execution Count:126
126
358 -
359 QRegExpEngine(const QRegExpEngineKey &key); -
360 ~QRegExpEngine(); -
361 -
362 bool isValid() const { return valid; }
executed: return valid;
Execution Count:1755
1755
363 const QString &errorString() const { return yyError; }
never executed: return yyError;
0
364 int captureCount() const { return officialncap; }
executed: return officialncap;
Execution Count:2294535
2294535
365 -
366 int createState(QChar ch); -
367 int createState(const QRegExpCharClass &cc); -
368 -
369 int createState(int bref); -
370 -
371 -
372 void addCatTransitions(const QVector<int> &from, const QVector<int> &to); -
373 -
374 void addPlusTransitions(const QVector<int> &from, const QVector<int> &to, int atom); -
375 -
376 -
377 -
378 int anchorAlternation(int a, int b); -
379 int anchorConcatenation(int a, int b); -
380 -
381 -
382 -
383 -
384 void addAnchors(int from, int to, int a); -
385 -
386 -
387 void heuristicallyChooseHeuristic(); -
388 -
389 -
390 -
391 -
392 -
393 -
394 QAtomicInt ref; -
395 -
396private: -
397 enum { CharClassBit = 0x10000, BackRefBit = 0x20000 }; -
398 enum { InitialState = 0, FinalState = 1 }; -
399 -
400 void setup(); -
401 int setupState(int match); -
402 -
403 -
404 -
405 -
406 -
407 enum { MaxLookaheads = 13, MaxBackRefs = 14 }; -
408 enum { Anchor_Dollar = 0x00000001, Anchor_Caret = 0x00000002, Anchor_Word = 0x00000004, -
409 Anchor_NonWord = 0x00000008, Anchor_FirstLookahead = 0x00000010, -
410 Anchor_BackRef1Empty = Anchor_FirstLookahead << MaxLookaheads, -
411 Anchor_BackRef0Empty = Anchor_BackRef1Empty >> 1, -
412 Anchor_Alternation = unsigned(Anchor_BackRef1Empty) << MaxBackRefs, -
413 -
414 Anchor_LookaheadMask = (Anchor_FirstLookahead - 1) ^ -
415 ((Anchor_FirstLookahead << MaxLookaheads) - 1) }; -
416 -
417 int startAtom(bool officialCapture); -
418 void finishAtom(int atom, bool needCapture); -
419 -
420 -
421 -
422 int addLookahead(QRegExpEngine *eng, bool negative); -
423 -
424 -
425 -
426 bool goodStringMatch(QRegExpMatchState &matchState) const; -
427 bool badCharMatch(QRegExpMatchState &matchState) const; -
428 -
429 -
430 -
431 -
432 QVector<QRegExpAutomatonState> s; -
433 -
434 QVector<QRegExpAtom> f; -
435 int nf; -
436 int cf; -
437 QVector<int> captureForOfficialCapture; -
438 -
439 int officialncap; -
440 int ncap; -
441 -
442 QVector<QRegExpCharClass> cl; -
443 -
444 -
445 QVector<QRegExpLookahead *> ahead; -
446 -
447 -
448 QVector<QRegExpAnchorAlternation> aa; -
449 -
450 -
451 bool caretAnchored; -
452 bool trivial; -
453 -
454 bool valid; -
455 Qt::CaseSensitivity cs; -
456 bool greedyQuantifiers; -
457 bool xmlSchemaExtensions; -
458 -
459 int nbrefs; -
460 -
461 -
462 -
463 bool useGoodStringHeuristic; -
464 -
465 int goodEarlyStart; -
466 int goodLateStart; -
467 QString goodStr; -
468 -
469 int minl; -
470 QVector<int> occ1; -
471 class Box -
472 { -
473 public: -
474 Box(QRegExpEngine *engine); -
475 Box(const Box &b) { operator=(b); }
never executed: }
0
476 -
477 Box &operator=(const Box &b); -
478 -
479 void clear() { operator=(Box(eng)); }
executed: }
Execution Count:22
22
480 void set(QChar ch); -
481 void set(const QRegExpCharClass &cc); -
482 -
483 void set(int bref); -
484 -
485 -
486 void cat(const Box &b); -
487 void orx(const Box &b); -
488 void plus(int atom); -
489 void opt(); -
490 void catAnchor(int a); -
491 -
492 void setupHeuristics(); -
493 -
494 -
495 -
496 -
497 -
498 -
499 private: -
500 void addAnchorsToEngine(const Box &to) const; -
501 -
502 QRegExpEngine *eng; -
503 QVector<int> ls; -
504 QVector<int> rs; -
505 QMap<int, int> lanchors; -
506 QMap<int, int> ranchors; -
507 int skipanchors; -
508 -
509 -
510 int earlyStart; -
511 int lateStart; -
512 QString str; -
513 QString leftStr; -
514 QString rightStr; -
515 int maxl; -
516 -
517 -
518 int minl; -
519 -
520 QVector<int> occ1; -
521 -
522 }; -
523 -
524 friend class Box; -
525 -
526 -
527 -
528 -
529 enum { Tok_Eos, Tok_Dollar, Tok_LeftParen, Tok_MagicLeftParen, Tok_PosLookahead, -
530 Tok_NegLookahead, Tok_RightParen, Tok_CharClass, Tok_Caret, Tok_Quantifier, Tok_Bar, -
531 Tok_Word, Tok_NonWord, Tok_Char = 0x10000, Tok_BackRef = 0x20000 }; -
532 int getChar(); -
533 int getEscape(); -
534 -
535 int getRep(int def); -
536 -
537 -
538 void skipChars(int n); -
539 -
540 void error(const char *msg); -
541 void startTokenizer(const QChar *rx, int len); -
542 int getToken(); -
543 -
544 const QChar *yyIn; -
545 int yyPos0; -
546 int yyPos; -
547 int yyLen; -
548 int yyCh; -
549 QScopedPointer<QRegExpCharClass> yyCharClass; -
550 int yyMinRep; -
551 int yyMaxRep; -
552 QString yyError; -
553 -
554 -
555 -
556 -
557 int parse(const QChar *rx, int len); -
558 void parseAtom(Box *box); -
559 void parseFactor(Box *box); -
560 void parseTerm(Box *box); -
561 void parseExpression(Box *box); -
562 -
563 int yyTok; -
564 bool yyMayCapture; -
565 -
566 friend struct QRegExpMatchState; -
567}; -
568 -
569 -
570 -
571 -
572 -
573 -
574struct QRegExpLookahead -
575{ -
576 QRegExpEngine *eng; -
577 bool neg; -
578 -
579 inline QRegExpLookahead(QRegExpEngine *eng0, bool neg0) -
580 : eng(eng0), neg(neg0) { }
executed: }
Execution Count:126
126
581 inline ~QRegExpLookahead() { delete eng; }
executed: }
Execution Count:126
126
582}; -
583__attribute__((visibility("default"))) QString qt_regexp_toCanonical(const QString &pattern, QRegExp::PatternSyntax patternSyntax) -
584{ -
585 switch (patternSyntax) { -
586 -
587 case QRegExp::Wildcard: -
588 return wc2rx(pattern, false);
executed: return wc2rx(pattern, false);
Execution Count:154
154
589 case QRegExp::WildcardUnix: -
590 return wc2rx(pattern, true);
executed: return wc2rx(pattern, true);
Execution Count:32
32
591 -
592 case QRegExp::FixedString: -
593 return QRegExp::escape(pattern);
executed: return QRegExp::escape(pattern);
Execution Count:92
92
594 case QRegExp::W3CXmlSchema11: -
595 default: -
596 return pattern;
executed: return pattern;
Execution Count:1019
1019
597 } -
598}
never executed: }
0
599 -
600QRegExpEngine::QRegExpEngine(const QRegExpEngineKey &key) -
601 : cs(key.cs), greedyQuantifiers(key.patternSyntax == QRegExp::RegExp2), -
602 xmlSchemaExtensions(key.patternSyntax == QRegExp::W3CXmlSchema11) -
603{ -
604 setup(); -
605 -
606 QString rx = qt_regexp_toCanonical(key.pattern, key.patternSyntax); -
607 -
608 valid = (parse(rx.unicode(), rx.length()) == rx.length()); -
609 if (!valid) {
evaluated: !valid
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:1245
52-1245
610 -
611 trivial = false; -
612 -
613 error("missing left delim"); -
614 }
executed: }
Execution Count:52
52
615}
executed: }
Execution Count:1297
1297
616 -
617QRegExpEngine::~QRegExpEngine() -
618{ -
619 -
620 qDeleteAll(ahead); -
621 -
622}
executed: }
Execution Count:1612
1612
623 -
624void QRegExpMatchState::prepareForMatch(QRegExpEngine *eng) -
625{ -
626 -
627 -
628 -
629 -
630 int ns = eng->s.size(); -
631 int ncap = eng->ncap; -
632 -
633 int newSlideTabSize = qMax(eng->minl + 1, 16); -
634 -
635 -
636 -
637 int numCaptures = eng->captureCount(); -
638 int newCapturedSize = 2 + 2 * numCaptures; -
639 bigArray = q_check_ptr((int *)realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + newSlideTabSize + newCapturedSize)*sizeof(int))); -
640 -
641 -
642 -
643 -
644 slideTabSize = newSlideTabSize; -
645 capturedSize = newCapturedSize; -
646 inNextStack = bigArray; -
647 memset(inNextStack, -1, ns * sizeof(int)); -
648 curStack = inNextStack + ns; -
649 nextStack = inNextStack + 2 * ns; -
650 -
651 curCapBegin = inNextStack + 3 * ns; -
652 nextCapBegin = curCapBegin + ncap * ns; -
653 curCapEnd = curCapBegin + 2 * ncap * ns; -
654 nextCapEnd = curCapBegin + 3 * ncap * ns; -
655 -
656 tempCapBegin = curCapBegin + 4 * ncap * ns; -
657 tempCapEnd = tempCapBegin + ncap; -
658 capBegin = tempCapBegin + 2 * ncap; -
659 capEnd = tempCapBegin + 3 * ncap; -
660 -
661 slideTab = tempCapBegin + 4 * ncap; -
662 captured = slideTab + slideTabSize; -
663 memset(captured, -1, capturedSize*sizeof(int)); -
664 this->eng = eng; -
665}
executed: }
Execution Count:2211391
2211391
666 -
667 -
668 -
669 -
670 -
671void QRegExpMatchState::match(const QChar *str0, int len0, int pos0, -
672 bool minimal0, bool oneTest, int caretIndex) -
673{ -
674 bool matched = false; -
675 QChar char_null; -
676 -
677 -
678 if (eng->trivial && !oneTest) {
evaluated: eng->trivial
TRUEFALSE
yes
Evaluation Count:121213
yes
Evaluation Count:1594239
evaluated: !oneTest
TRUEFALSE
yes
Evaluation Count:120152
yes
Evaluation Count:1061
1061-1594239
679 pos = qFindString(str0, len0, pos0, eng->goodStr.unicode(), eng->goodStr.length(), eng->cs); -
680 matchLen = eng->goodStr.length(); -
681 matched = (pos != -1); -
682 } else
executed: }
Execution Count:120152
120152
683 -
684 { -
685 in = str0; -
686 if (in == 0)
partially evaluated: in == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1595296
0-1595296
687 in = &char_null;
never executed: in = &char_null;
0
688 pos = pos0; -
689 caretPos = caretIndex; -
690 len = len0; -
691 minimal = minimal0; -
692 matchLen = 0; -
693 oneTestMatchedLen = 0; -
694 -
695 if (eng->valid && pos >= 0 && pos <= len) {
evaluated: eng->valid
TRUEFALSE
yes
Evaluation Count:1568393
yes
Evaluation Count:26980
partially evaluated: pos >= 0
TRUEFALSE
yes
Evaluation Count:1568398
no
Evaluation Count:0
evaluated: pos <= len
TRUEFALSE
yes
Evaluation Count:1568470
yes
Evaluation Count:7
0-1568470
696 -
697 if (oneTest) {
evaluated: oneTest
TRUEFALSE
yes
Evaluation Count:1352877
yes
Evaluation Count:215578
215578-1352877
698 matched = matchHere(); -
699 } else {
executed: }
Execution Count:1352877
1352877
700 if (pos <= len - eng->minl) {
evaluated: pos <= len - eng->minl
TRUEFALSE
yes
Evaluation Count:215163
yes
Evaluation Count:384
384-215163
701 if (eng->caretAnchored) {
evaluated: eng->caretAnchored
TRUEFALSE
yes
Evaluation Count:1170
yes
Evaluation Count:214058
1170-214058
702 matched = matchHere(); -
703 } else if (eng->useGoodStringHeuristic) {
executed: }
Execution Count:1170
evaluated: eng->useGoodStringHeuristic
TRUEFALSE
yes
Evaluation Count:200949
yes
Evaluation Count:13112
1170-200949
704 matched = eng->goodStringMatch(*this); -
705 } else {
executed: }
Execution Count:200765
200765
706 matched = eng->badCharMatch(*this); -
707 }
executed: }
Execution Count:13112
13112
708 } -
709 }
executed: }
Execution Count:215505
215505
710 -
711 -
712 -
713 } -
714 }
executed: }
Execution Count:1595427
1595427
715 -
716 if (matched) {
evaluated: matched
TRUEFALSE
yes
Evaluation Count:440312
yes
Evaluation Count:1274938
440312-1274938
717 int *c = captured; -
718 *c++ = pos; -
719 *c++ = matchLen; -
720 -
721 int numCaptures = (capturedSize - 2) >> 1; -
722 -
723 for (int i = 0; i < numCaptures; ++i) {
evaluated: i < numCaptures
TRUEFALSE
yes
Evaluation Count:214058
yes
Evaluation Count:440590
214058-440590
724 int j = eng->captureForOfficialCapture.at(i); -
725 if (capBegin[j] != EmptyCapture) {
evaluated: capBegin[j] != EmptyCapture
TRUEFALSE
yes
Evaluation Count:205434
yes
Evaluation Count:8627
8627-205434
726 int len = capEnd[j] - capBegin[j]; -
727 *c++ = (len > 0) ? pos + capBegin[j] : 0;
partially evaluated: (len > 0)
TRUEFALSE
yes
Evaluation Count:205393
no
Evaluation Count:0
0-205393
728 *c++ = len; -
729 } else {
executed: }
Execution Count:205411
205411
730 *c++ = -1; -
731 *c++ = -1; -
732 }
executed: }
Execution Count:8627
8627
733 } -
734 -
735 } else {
executed: }
Execution Count:440619
440619
736 -
737 memset(captured, -1, capturedSize * sizeof(int)); -
738 }
executed: }
Execution Count:1274938
1274938
739} -
740 -
741 -
742 -
743 -
744 -
745 -
746int QRegExpEngine::createState(QChar ch) -
747{ -
748 return setupState(ch.unicode());
executed: return setupState(ch.unicode());
Execution Count:22163
22163
749} -
750 -
751int QRegExpEngine::createState(const QRegExpCharClass &cc) -
752{ -
753 -
754 int n = cl.size(); -
755 cl += QRegExpCharClass(cc); -
756 return setupState(CharClassBit | n);
executed: return setupState(CharClassBit | n);
Execution Count:5337
5337
757 -
758 -
759 -
760 -
761} -
762 -
763 -
764int QRegExpEngine::createState(int bref) -
765{ -
766 if (bref > nbrefs) {
evaluated: bref > nbrefs
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:118
72-118
767 nbrefs = bref; -
768 if (nbrefs > MaxBackRefs) {
partially evaluated: nbrefs > MaxBackRefs
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:72
0-72
769 error("met internal limit"); -
770 return 0;
never executed: return 0;
0
771 } -
772 }
executed: }
Execution Count:72
72
773 return setupState(BackRefBit | bref);
executed: return setupState(BackRefBit | bref);
Execution Count:190
190
774} -
775void QRegExpEngine::addCatTransitions(const QVector<int> &from, const QVector<int> &to) -
776{ -
777 for (int i = 0; i < from.size(); i++)
evaluated: i < from.size()
TRUEFALSE
yes
Evaluation Count:30549
yes
Evaluation Count:28648
28648-30549
778 mergeInto(&s[from.at(i)].outs, to);
executed: mergeInto(&s[from.at(i)].outs, to);
Execution Count:30549
30549
779}
executed: }
Execution Count:28648
28648
780 -
781 -
782void QRegExpEngine::addPlusTransitions(const QVector<int> &from, const QVector<int> &to, int atom) -
783{ -
784 for (int i = 0; i < from.size(); i++) {
evaluated: i < from.size()
TRUEFALSE
yes
Evaluation Count:2863
yes
Evaluation Count:2011
2011-2863
785 QRegExpAutomatonState &st = s[from.at(i)]; -
786 const QVector<int> oldOuts = st.outs; -
787 mergeInto(&st.outs, to); -
788 if (f.at(atom).capture != QRegExpAtom::NoCapture) {
evaluated: f.at(atom).capture != QRegExpAtom::NoCapture
TRUEFALSE
yes
Evaluation Count:626
yes
Evaluation Count:2237
626-2237
789 for (int j = 0; j < to.size(); j++) {
evaluated: j < to.size()
TRUEFALSE
yes
Evaluation Count:1032
yes
Evaluation Count:626
626-1032
790 -
791 if (!st.reenter.contains(to.at(j)) &&
evaluated: !st.reenter.contains(to.at(j))
TRUEFALSE
yes
Evaluation Count:1024
yes
Evaluation Count:8
8-1024
792 qBinaryFind(oldOuts.constBegin(), oldOuts.constEnd(), to.at(j)) == oldOuts.end())
evaluated: qBinaryFind(oldOuts.constBegin(), oldOuts.constEnd(), to.at(j)) == oldOuts.end()
TRUEFALSE
yes
Evaluation Count:934
yes
Evaluation Count:90
90-934
793 st.reenter.insert(to.at(j), atom);
executed: st.reenter.insert(to.at(j), atom);
Execution Count:934
934
794 }
executed: }
Execution Count:1032
1032
795 }
executed: }
Execution Count:626
626
796 }
executed: }
Execution Count:2863
2863
797}
executed: }
Execution Count:2011
2011
798 -
799 -
800 -
801 -
802 -
803 -
804int QRegExpEngine::anchorAlternation(int a, int b) -
805{ -
806 if (((a & b) == a || (a & b) == b) && ((a | b) & Anchor_Alternation) == 0)
evaluated: (a & b) == a
TRUEFALSE
yes
Evaluation Count:290
yes
Evaluation Count:422
evaluated: (a & b) == b
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:410
evaluated: ((a | b) & Anchor_Alternation) == 0
TRUEFALSE
yes
Evaluation Count:270
yes
Evaluation Count:32
12-422
807 return a & b;
executed: return a & b;
Execution Count:270
270
808 -
809 int n = aa.size(); -
810 -
811 if (n > 0 && aa.at(n - 1).a == a && aa.at(n - 1).b == b)
evaluated: n > 0
TRUEFALSE
yes
Evaluation Count:420
yes
Evaluation Count:22
evaluated: aa.at(n - 1).a == a
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:336
evaluated: aa.at(n - 1).b == b
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:44
22-420
812 return Anchor_Alternation | (n - 1);
executed: return Anchor_Alternation | (n - 1);
Execution Count:40
40
813 -
814 -
815 QRegExpAnchorAlternation element = {a, b}; -
816 aa.append(element); -
817 return Anchor_Alternation | n;
executed: return Anchor_Alternation | n;
Execution Count:402
402
818} -
819 -
820 -
821 -
822 -
823int QRegExpEngine::anchorConcatenation(int a, int b) -
824{ -
825 if (((a | b) & Anchor_Alternation) == 0)
evaluated: ((a | b) & Anchor_Alternation) == 0
TRUEFALSE
yes
Evaluation Count:39408
yes
Evaluation Count:500
500-39408
826 return a | b;
executed: return a | b;
Execution Count:39409
39409
827 if ((b & Anchor_Alternation) != 0)
evaluated: (b & Anchor_Alternation) != 0
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:330
170-330
828 qSwap(a, b);
executed: qSwap(a, b);
Execution Count:170
170
829 -
830 int aprime = anchorConcatenation(aa.at(a ^ Anchor_Alternation).a, b); -
831 int bprime = anchorConcatenation(aa.at(a ^ Anchor_Alternation).b, b); -
832 return anchorAlternation(aprime, bprime);
executed: return anchorAlternation(aprime, bprime);
Execution Count:500
500
833} -
834 -
835 -
836 -
837 -
838 -
839 -
840void QRegExpEngine::addAnchors(int from, int to, int a) -
841{ -
842 QRegExpAutomatonState &st = s[from]; -
843 if (st.anchors.contains(to))
evaluated: st.anchors.contains(to)
TRUEFALSE
yes
Evaluation Count:172
yes
Evaluation Count:34821
172-34821
844 a = anchorAlternation(st.anchors.value(to), a);
executed: a = anchorAlternation(st.anchors.value(to), a);
Execution Count:172
172
845 st.anchors.insert(to, a); -
846}
executed: }
Execution Count:34991
34991
847void QRegExpEngine::heuristicallyChooseHeuristic() -
848{ -
849 if (minl == 0) {
evaluated: minl == 0
TRUEFALSE
yes
Evaluation Count:371
yes
Evaluation Count:1052
371-1052
850 useGoodStringHeuristic = false; -
851 } else if (trivial) {
evaluated: trivial
TRUEFALSE
yes
Evaluation Count:473
yes
Evaluation Count:579
executed: }
Execution Count:371
371-579
852 useGoodStringHeuristic = true; -
853 } else {
executed: }
Execution Count:473
473
854 -
855 -
856 -
857 -
858 -
859 int goodStringScore = (64 * goodStr.length() / minl) - -
860 (goodLateStart - goodEarlyStart); -
861 -
862 -
863 -
864 -
865 int badCharScore = 0; -
866 int step = qMax(1, NumBadChars / 32); -
867 for (int i = 1; i < NumBadChars; i += step) {
evaluated: i < NumBadChars
TRUEFALSE
yes
Evaluation Count:18528
yes
Evaluation Count:579
579-18528
868 if (occ1.at(i) == NoOccurrence)
evaluated: occ1.at(i) == NoOccurrence
TRUEFALSE
yes
Evaluation Count:8298
yes
Evaluation Count:10230
8298-10230
869 badCharScore += minl;
executed: badCharScore += minl;
Execution Count:8298
8298
870 else -
871 badCharScore += occ1.at(i);
executed: badCharScore += occ1.at(i);
Execution Count:10230
10230
872 } -
873 badCharScore /= minl; -
874 useGoodStringHeuristic = (goodStringScore > badCharScore); -
875 }
executed: }
Execution Count:579
579
876} -
877void QRegExpEngine::setup() -
878{ -
879 ref.store(1); -
880 -
881 f.resize(32); -
882 nf = 0; -
883 cf = -1; -
884 -
885 officialncap = 0; -
886 ncap = 0; -
887 -
888 caretAnchored = true; -
889 trivial = true; -
890 -
891 valid = false; -
892 -
893 nbrefs = 0; -
894 -
895 -
896 useGoodStringHeuristic = true; -
897 minl = 0; -
898 occ1.fill(0, NumBadChars); -
899 -
900}
executed: }
Execution Count:1423
1423
901 -
902int QRegExpEngine::setupState(int match) -
903{ -
904 -
905 s += QRegExpAutomatonState(cf, match); -
906 -
907 -
908 -
909 return s.size() - 1;
executed: return s.size() - 1;
Execution Count:27688
27688
910} -
911 -
912 -
913 -
914 -
915 -
916 -
917 -
918int QRegExpEngine::startAtom(bool officialCapture) -
919{ -
920 if ((nf & (nf + 1)) == 0 && nf + 1 >= f.size())
evaluated: (nf & (nf + 1)) == 0
TRUEFALSE
yes
Evaluation Count:3990
yes
Evaluation Count:26163
evaluated: nf + 1 >= f.size()
TRUEFALSE
yes
Evaluation Count:233
yes
Evaluation Count:3757
233-26163
921 f.resize((nf + 1) << 1);
executed: f.resize((nf + 1) << 1);
Execution Count:233
233
922 f[nf].parent = cf; -
923 cf = nf++; -
924 f[cf].capture = officialCapture ? QRegExpAtom::OfficialCapture : QRegExpAtom::NoCapture;
evaluated: officialCapture
TRUEFALSE
yes
Evaluation Count:559
yes
Evaluation Count:29594
559-29594
925 return cf;
executed: return cf;
Execution Count:30153
30153
926} -
927 -
928void QRegExpEngine::finishAtom(int atom, bool needCapture) -
929{ -
930 if (greedyQuantifiers && needCapture && f[atom].capture == QRegExpAtom::NoCapture)
evaluated: greedyQuantifiers
TRUEFALSE
yes
Evaluation Count:5188
yes
Evaluation Count:24965
evaluated: needCapture
TRUEFALSE
yes
Evaluation Count:1136
yes
Evaluation Count:4052
partially evaluated: f[atom].capture == QRegExpAtom::NoCapture
TRUEFALSE
yes
Evaluation Count:1136
no
Evaluation Count:0
0-24965
931 f[atom].capture = QRegExpAtom::UnofficialCapture;
executed: f[atom].capture = QRegExpAtom::UnofficialCapture;
Execution Count:1136
1136
932 cf = f.at(atom).parent; -
933}
executed: }
Execution Count:30153
30153
934 -
935 -
936 -
937 -
938 -
939 -
940int QRegExpEngine::addLookahead(QRegExpEngine *eng, bool negative) -
941{ -
942 int n = ahead.size(); -
943 if (n == MaxLookaheads) {
partially evaluated: n == MaxLookaheads
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:126
0-126
944 error("met internal limit"); -
945 return 0;
never executed: return 0;
0
946 } -
947 ahead += new QRegExpLookahead(eng, negative); -
948 return Anchor_FirstLookahead << n;
executed: return Anchor_FirstLookahead << n;
Execution Count:126
126
949} -
950 -
951 -
952 -
953 -
954 -
955 -
956static bool isBetterCapture(int ncap, const int *begin1, const int *end1, const int *begin2, -
957 const int *end2) -
958{ -
959 for (int i = 0; i < ncap; i++) {
evaluated: i < ncap
TRUEFALSE
yes
Evaluation Count:156
yes
Evaluation Count:5
5-156
960 int delta = begin2[i] - begin1[i]; -
961 if (delta == 0)
evaluated: delta == 0
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:45
45-111
962 delta = end1[i] - end2[i];
executed: delta = end1[i] - end2[i];
Execution Count:111
111
963 -
964 if (delta != 0)
evaluated: delta != 0
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:62
62-94
965 return delta > 0;
executed: return delta > 0;
Execution Count:94
94
966 }
executed: }
Execution Count:62
62
967 return false;
executed: return false;
Execution Count:5
5
968} -
969 -
970 -
971 -
972 -
973 -
974 -
975bool QRegExpMatchState::testAnchor(int i, int a, const int *capBegin) -
976{ -
977 int j; -
978 -
979 -
980 if ((a & QRegExpEngine::Anchor_Alternation) != 0)
evaluated: (a & QRegExpEngine::Anchor_Alternation) != 0
TRUEFALSE
yes
Evaluation Count:336
yes
Evaluation Count:1537783
336-1537783
981 return testAnchor(i, eng->aa.at(a ^ QRegExpEngine::Anchor_Alternation).a, capBegin) 336
982 || testAnchor(i, eng->aa.at(a ^ QRegExpEngine::Anchor_Alternation).b, capBegin);
executed: return testAnchor(i, eng->aa.at(a ^ QRegExpEngine::Anchor_Alternation).a, capBegin) || testAnchor(i, eng->aa.at(a ^ QRegExpEngine::Anchor_Alternation).b, capBegin);
Execution Count:336
336
983 -
984 -
985 if ((a & QRegExpEngine::Anchor_Caret) != 0) {
evaluated: (a & QRegExpEngine::Anchor_Caret) != 0
TRUEFALSE
yes
Evaluation Count:705367
yes
Evaluation Count:832416
705367-832416
986 if (pos + i != caretPos)
evaluated: pos + i != caretPos
TRUEFALSE
yes
Evaluation Count:90706
yes
Evaluation Count:614661
90706-614661
987 return false;
executed: return false;
Execution Count:90706
90706
988 }
executed: }
Execution Count:614661
614661
989 if ((a & QRegExpEngine::Anchor_Dollar) != 0) {
evaluated: (a & QRegExpEngine::Anchor_Dollar) != 0
TRUEFALSE
yes
Evaluation Count:18251
yes
Evaluation Count:1428826
18251-1428826
990 if (pos + i != len)
evaluated: pos + i != len
TRUEFALSE
yes
Evaluation Count:10871
yes
Evaluation Count:7380
7380-10871
991 return false;
executed: return false;
Execution Count:10871
10871
992 }
executed: }
Execution Count:7380
7380
993 -
994 if ((a & (QRegExpEngine::Anchor_Word | QRegExpEngine::Anchor_NonWord)) != 0) {
evaluated: (a & (QRegExpEngine::Anchor_Word | QRegExpEngine::Anchor_NonWord)) != 0
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:1436117
89-1436117
995 bool before = false; -
996 bool after = false; -
997 if (pos + i != 0)
evaluated: pos + i != 0
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:3
3-86
998 before = isWord(in[pos + i - 1]);
executed: before = isWord(in[pos + i - 1]);
Execution Count:86
86
999 if (pos + i != len)
evaluated: pos + i != len
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:3
3-86
1000 after = isWord(in[pos + i]);
executed: after = isWord(in[pos + i]);
Execution Count:86
86
1001 if ((a & QRegExpEngine::Anchor_Word) != 0 && (before == after))
partially evaluated: (a & QRegExpEngine::Anchor_Word) != 0
TRUEFALSE
yes
Evaluation Count:89
no
Evaluation Count:0
evaluated: (before == after)
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:30
0-89
1002 return false;
executed: return false;
Execution Count:59
59
1003 if ((a & QRegExpEngine::Anchor_NonWord) != 0 && (before != after))
partially evaluated: (a & QRegExpEngine::Anchor_NonWord) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
never evaluated: (before != after)
0-30
1004 return false;
never executed: return false;
0
1005 }
executed: }
Execution Count:30
30
1006 -
1007 -
1008 if ((a & QRegExpEngine::Anchor_LookaheadMask) != 0) {
evaluated: (a & QRegExpEngine::Anchor_LookaheadMask) != 0
TRUEFALSE
yes
Evaluation Count:800608
yes
Evaluation Count:635539
635539-800608
1009 const QVector<QRegExpLookahead *> &ahead = eng->ahead; -
1010 for (j = 0; j < ahead.size(); j++) {
evaluated: j < ahead.size()
TRUEFALSE
yes
Evaluation Count:10402080
yes
Evaluation Count:800113
800113-10402080
1011 if ((a & (QRegExpEngine::Anchor_FirstLookahead << j)) != 0) {
evaluated: (a & (QRegExpEngine::Anchor_FirstLookahead << j)) != 0
TRUEFALSE
yes
Evaluation Count:800608
yes
Evaluation Count:9601472
800608-9601472
1012 QRegExpMatchState matchState; -
1013 matchState.prepareForMatch(ahead[j]->eng); -
1014 matchState.match(in + pos + i, len - pos - i, 0, -
1015 true, true, caretPos - pos - i); -
1016 if ((matchState.captured[0] == 0) == ahead[j]->neg)
evaluated: (matchState.captured[0] == 0) == ahead[j]->neg
TRUEFALSE
yes
Evaluation Count:495
yes
Evaluation Count:800113
495-800113
1017 return false;
executed: return false;
Execution Count:495
495
1018 }
executed: }
Execution Count:800113
800113
1019 }
executed: }
Execution Count:10401585
10401585
1020 }
executed: }
Execution Count:800113
800113
1021 -
1022 -
1023 -
1024 for (j = 0; j < eng->nbrefs; j++) {
evaluated: j < eng->nbrefs
TRUEFALSE
yes
Evaluation Count:42778
yes
Evaluation Count:1412788
42778-1412788
1025 if ((a & (QRegExpEngine::Anchor_BackRef1Empty << j)) != 0) {
evaluated: (a & (QRegExpEngine::Anchor_BackRef1Empty << j)) != 0
TRUEFALSE
yes
Evaluation Count:26367
yes
Evaluation Count:16411
16411-26367
1026 int i = eng->captureForOfficialCapture.at(j); -
1027 if (capBegin[i] != EmptyCapture)
evaluated: capBegin[i] != EmptyCapture
TRUEFALSE
yes
Evaluation Count:22864
yes
Evaluation Count:3503
3503-22864
1028 return false;
executed: return false;
Execution Count:22864
22864
1029 }
executed: }
Execution Count:3503
3503
1030 }
executed: }
Execution Count:19914
19914
1031 -
1032 -
1033 return true;
executed: return true;
Execution Count:1412788
1412788
1034} -
1035bool QRegExpEngine::goodStringMatch(QRegExpMatchState &matchState) const -
1036{ -
1037 int k = matchState.pos + goodEarlyStart; -
1038 QStringMatcher matcher(goodStr.unicode(), goodStr.length(), cs); -
1039 while ((k = matcher.indexIn(matchState.in, matchState.len, k)) != -1) {
evaluated: (k = matcher.indexIn(matchState.in, matchState.len, k)) != -1
TRUEFALSE
yes
Evaluation Count:195709
yes
Evaluation Count:535
535-195709
1040 int from = k - goodLateStart; -
1041 int to = k - goodEarlyStart; -
1042 if (from > matchState.pos)
evaluated: from > matchState.pos
TRUEFALSE
yes
Evaluation Count:195305
yes
Evaluation Count:311
311-195305
1043 matchState.pos = from;
executed: matchState.pos = from;
Execution Count:195637
195637
1044 -
1045 while (matchState.pos <= to) {
evaluated: matchState.pos <= to
TRUEFALSE
yes
Evaluation Count:196607
yes
Evaluation Count:18
18-196607
1046 if (matchState.matchHere())
evaluated: matchState.matchHere()
TRUEFALSE
yes
Evaluation Count:200290
yes
Evaluation Count:18
18-200290
1047 return true;
executed: return true;
Execution Count:200354
200354
1048 ++matchState.pos; -
1049 }
executed: }
Execution Count:18
18
1050 ++k; -
1051 }
executed: }
Execution Count:18
18
1052 return false;
executed: return false;
Execution Count:535
535
1053} -
1054 -
1055bool QRegExpEngine::badCharMatch(QRegExpMatchState &matchState) const -
1056{ -
1057 int slideHead = 0; -
1058 int slideNext = 0; -
1059 int i; -
1060 int lastPos = matchState.len - minl; -
1061 memset(matchState.slideTab, 0, matchState.slideTabSize * sizeof(int)); -
1062 -
1063 -
1064 -
1065 -
1066 -
1067 for (i = 0; i < minl; i++) {
evaluated: i < minl
TRUEFALSE
yes
Evaluation Count:3916
yes
Evaluation Count:13112
3916-13112
1068 int sk = occ1[((matchState.in[matchState.pos + i]).unicode() % NumBadChars)]; -
1069 if (sk == NoOccurrence)
evaluated: sk == NoOccurrence
TRUEFALSE
yes
Evaluation Count:2265
yes
Evaluation Count:1651
1651-2265
1070 sk = i + 1;
executed: sk = i + 1;
Execution Count:2265
2265
1071 if (sk > 0) {
evaluated: sk > 0
TRUEFALSE
yes
Evaluation Count:2551
yes
Evaluation Count:1365
1365-2551
1072 int k = i + 1 - sk; -
1073 if (k < 0) {
evaluated: k < 0
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:2533
18-2533
1074 sk = i + 1; -
1075 k = 0; -
1076 }
executed: }
Execution Count:18
18
1077 if (sk > matchState.slideTab[k])
partially evaluated: sk > matchState.slideTab[k]
TRUEFALSE
yes
Evaluation Count:2551
no
Evaluation Count:0
0-2551
1078 matchState.slideTab[k] = sk;
executed: matchState.slideTab[k] = sk;
Execution Count:2551
2551
1079 }
executed: }
Execution Count:2551
2551
1080 }
executed: }
Execution Count:3916
3916
1081 -
1082 if (matchState.pos > lastPos)
partially evaluated: matchState.pos > lastPos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13112
0-13112
1083 return false;
never executed: return false;
0
1084 -
1085 for (;;) { -
1086 if (++slideNext >= matchState.slideTabSize)
evaluated: ++slideNext >= matchState.slideTabSize
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:26051
124-26051
1087 slideNext = 0;
executed: slideNext = 0;
Execution Count:124
124
1088 if (matchState.slideTab[slideHead] > 0) {
evaluated: matchState.slideTab[slideHead] > 0
TRUEFALSE
yes
Evaluation Count:10933
yes
Evaluation Count:15242
10933-15242
1089 if (matchState.slideTab[slideHead] - 1 > matchState.slideTab[slideNext])
evaluated: matchState.slideTab[slideHead] - 1 > matchState.slideTab[slideNext]
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:10804
129-10804
1090 matchState.slideTab[slideNext] = matchState.slideTab[slideHead] - 1;
executed: matchState.slideTab[slideNext] = matchState.slideTab[slideHead] - 1;
Execution Count:129
129
1091 matchState.slideTab[slideHead] = 0; -
1092 } else {
executed: }
Execution Count:10933
10933
1093 if (matchState.matchHere())
evaluated: matchState.matchHere()
TRUEFALSE
yes
Evaluation Count:12734
yes
Evaluation Count:2508
2508-12734
1094 return true;
executed: return true;
Execution Count:12734
12734
1095 }
executed: }
Execution Count:2508
2508
1096 -
1097 if (matchState.pos == lastPos)
evaluated: matchState.pos == lastPos
TRUEFALSE
yes
Evaluation Count:378
yes
Evaluation Count:13063
378-13063
1098 break;
executed: break;
Execution Count:378
378
1099 -
1100 -
1101 -
1102 -
1103 -
1104 int sk = occ1[((matchState.in[matchState.pos + minl]).unicode() % NumBadChars)]; -
1105 if (sk == NoOccurrence) {
evaluated: sk == NoOccurrence
TRUEFALSE
yes
Evaluation Count:8603
yes
Evaluation Count:4460
4460-8603
1106 matchState.slideTab[slideNext] = minl; -
1107 } else if (sk > 0) {
executed: }
Execution Count:8603
evaluated: sk > 0
TRUEFALSE
yes
Evaluation Count:143
yes
Evaluation Count:4317
143-8603
1108 int k = slideNext + minl - sk; -
1109 if (k >= matchState.slideTabSize)
evaluated: k >= matchState.slideTabSize
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:132
11-132
1110 k -= matchState.slideTabSize;
executed: k -= matchState.slideTabSize;
Execution Count:11
11
1111 if (sk > matchState.slideTab[k])
partially evaluated: sk > matchState.slideTab[k]
TRUEFALSE
yes
Evaluation Count:143
no
Evaluation Count:0
0-143
1112 matchState.slideTab[k] = sk;
executed: matchState.slideTab[k] = sk;
Execution Count:143
143
1113 }
executed: }
Execution Count:143
143
1114 slideHead = slideNext; -
1115 ++matchState.pos; -
1116 }
executed: }
Execution Count:13063
13063
1117 return false;
executed: return false;
Execution Count:378
378
1118} -
1119bool QRegExpMatchState::matchHere() -
1120{ -
1121 int ncur = 1, nnext = 0; -
1122 int i = 0, j, k, m; -
1123 bool stop = false; -
1124 -
1125 matchLen = -1; -
1126 oneTestMatchedLen = -1; -
1127 curStack[0] = QRegExpEngine::InitialState; -
1128 -
1129 int ncap = eng->ncap; -
1130 -
1131 if (ncap > 0) {
evaluated: ncap > 0
TRUEFALSE
yes
Evaluation Count:242488
yes
Evaluation Count:1326594
242488-1326594
1132 for (j = 0; j < ncap; j++) {
evaluated: j < ncap
TRUEFALSE
yes
Evaluation Count:294026
yes
Evaluation Count:242831
242831-294026
1133 curCapBegin[j] = EmptyCapture; -
1134 curCapEnd[j] = EmptyCapture; -
1135 }
executed: }
Execution Count:294204
294204
1136 }
executed: }
Execution Count:242894
242894
1137 -
1138 -
1139 -
1140 while ((ncur > 0 || !sleeping.isEmpty()) && i <= len - pos && !stop)
evaluated: ncur > 0
TRUEFALSE
yes
Evaluation Count:4495540
yes
Evaluation Count:1163885
evaluated: !sleeping.isEmpty()
TRUEFALSE
yes
Evaluation Count:30940
yes
Evaluation Count:1132945
evaluated: i <= len - pos
TRUEFALSE
yes
Evaluation Count:4296601
yes
Evaluation Count:233342
evaluated: !stop
TRUEFALSE
yes
Evaluation Count:4095683
yes
Evaluation Count:203381
30940-4495540
1141 -
1142 -
1143 -
1144 { -
1145 int ch = (i < len - pos) ? in[pos + i].unicode() : 0;
evaluated: (i < len - pos)
TRUEFALSE
yes
Evaluation Count:2961823
yes
Evaluation Count:1134554
1134554-2961823
1146 for (j = 0; j < ncur; j++) {
evaluated: j < ncur
TRUEFALSE
yes
Evaluation Count:4681597
yes
Evaluation Count:4092388
4092388-4681597
1147 int cur = curStack[j]; -
1148 const QRegExpAutomatonState &scur = eng->s.at(cur); -
1149 const QVector<int> &outs = scur.outs; -
1150 for (k = 0; k < outs.size(); k++) {
evaluated: k < outs.size()
TRUEFALSE
yes
Evaluation Count:9138752
yes
Evaluation Count:4672732
4672732-9138752
1151 int next = outs.at(k); -
1152 const QRegExpAutomatonState &snext = eng->s.at(next); -
1153 bool inside = true; -
1154 -
1155 int needSomeSleep = 0; -
1156 -
1157 -
1158 -
1159 -
1160 -
1161 int a = scur.anchors.value(next); -
1162 if (a != 0 && !testAnchor(i, a, curCapBegin + j * ncap))
evaluated: a != 0
TRUEFALSE
yes
Evaluation Count:1537525
yes
Evaluation Count:7596796
evaluated: !testAnchor(i, a, curCapBegin + j * ncap)
TRUEFALSE
yes
Evaluation Count:124737
yes
Evaluation Count:1412788
124737-7596796
1163 inside = false;
executed: inside = false;
Execution Count:124737
124737
1164 -
1165 -
1166 -
1167 -
1168 -
1169 if (inside) {
evaluated: inside
TRUEFALSE
yes
Evaluation Count:9012962
yes
Evaluation Count:124737
124737-9012962
1170 m = snext.match; -
1171 if ((m & (QRegExpEngine::CharClassBit | QRegExpEngine::BackRefBit)) == 0) {
evaluated: (m & (QRegExpEngine::CharClassBit | QRegExpEngine::BackRefBit)) == 0
TRUEFALSE
yes
Evaluation Count:4794551
yes
Evaluation Count:4230979
4230979-4794551
1172 if (eng->cs)
evaluated: eng->cs
TRUEFALSE
yes
Evaluation Count:4744995
yes
Evaluation Count:52647
52647-4744995
1173 inside = (m == ch);
executed: inside = (m == ch);
Execution Count:4742588
4742588
1174 else -
1175 inside = (QChar(m).toLower() == QChar(ch).toLower());
executed: inside = (QChar(m).toLower() == QChar(ch).toLower());
Execution Count:52647
52647
1176 } else if (next == QRegExpEngine::FinalState) {
evaluated: next == QRegExpEngine::FinalState
TRUEFALSE
yes
Evaluation Count:921994
yes
Evaluation Count:3310055
921994-3310055
1177 matchLen = i; -
1178 stop = minimal; -
1179 inside = true; -
1180 } else if ((m & QRegExpEngine::CharClassBit) != 0) {
executed: }
Execution Count:921990
evaluated: (m & QRegExpEngine::CharClassBit) != 0
TRUEFALSE
yes
Evaluation Count:3291138
yes
Evaluation Count:18978
18978-3291138
1181 -
1182 const QRegExpCharClass &cc = eng->cl.at(m ^ QRegExpEngine::CharClassBit); -
1183 if (eng->cs)
evaluated: eng->cs
TRUEFALSE
yes
Evaluation Count:2850559
yes
Evaluation Count:440662
440662-2850559
1184 inside = cc.in(ch);
executed: inside = cc.in(ch);
Execution Count:2850689
2850689
1185 else if (cc.negative())
evaluated: cc.negative()
TRUEFALSE
yes
Evaluation Count:440574
yes
Evaluation Count:88
88-440574
1186 inside = cc.in(QChar(ch).toLower()) &&
partially evaluated: cc.in(QChar(ch).toLower())
TRUEFALSE
yes
Evaluation Count:440574
no
Evaluation Count:0
0-440574
1187 cc.in(QChar(ch).toUpper());
executed: inside = cc.in(QChar(ch).toLower()) && cc.in(QChar(ch).toUpper());
Execution Count:440574
partially evaluated: cc.in(QChar(ch).toUpper())
TRUEFALSE
yes
Evaluation Count:440574
no
Evaluation Count:0
0-440574
1188 else -
1189 inside = cc.in(QChar(ch).toLower()) ||
evaluated: cc.in(QChar(ch).toLower())
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:16
16-88
1190 cc.in(QChar(ch).toUpper());
executed: inside = cc.in(QChar(ch).toLower()) || cc.in(QChar(ch).toUpper());
Execution Count:88
partially evaluated: cc.in(QChar(ch).toUpper())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-88
1191 -
1192 -
1193 } else { -
1194 int bref = m ^ QRegExpEngine::BackRefBit; -
1195 int ell = j * ncap + eng->captureForOfficialCapture.at(bref - 1); -
1196 -
1197 inside = bref <= ncap && curCapBegin[ell] != EmptyCapture;
partially evaluated: bref <= ncap
TRUEFALSE
yes
Evaluation Count:18978
no
Evaluation Count:0
evaluated: curCapBegin[ell] != EmptyCapture
TRUEFALSE
yes
Evaluation Count:16330
yes
Evaluation Count:2648
0-18978
1198 if (inside) {
evaluated: inside
TRUEFALSE
yes
Evaluation Count:16330
yes
Evaluation Count:2648
2648-16330
1199 if (eng->cs)
partially evaluated: eng->cs
TRUEFALSE
yes
Evaluation Count:16330
no
Evaluation Count:0
0-16330
1200 inside = (in[pos + curCapBegin[ell]] == QChar(ch));
executed: inside = (in[pos + curCapBegin[ell]] == QChar(ch));
Execution Count:16330
16330
1201 else -
1202 inside = (in[pos + curCapBegin[ell]].toLower() 0
1203 == QChar(ch).toLower());
never executed: inside = (in[pos + curCapBegin[ell]].toLower() == QChar(ch).toLower());
0
1204 } -
1205 -
1206 if (inside) {
evaluated: inside
TRUEFALSE
yes
Evaluation Count:16014
yes
Evaluation Count:2964
2964-16014
1207 int delta; -
1208 if (curCapEnd[ell] == EmptyCapture)
evaluated: curCapEnd[ell] == EmptyCapture
TRUEFALSE
yes
Evaluation Count:11606
yes
Evaluation Count:4408
4408-11606
1209 delta = i - curCapBegin[ell];
executed: delta = i - curCapBegin[ell];
Execution Count:11606
11606
1210 else -
1211 delta = curCapEnd[ell] - curCapBegin[ell];
executed: delta = curCapEnd[ell] - curCapBegin[ell];
Execution Count:4408
4408
1212 -
1213 inside = (delta <= len - (pos + i)); -
1214 if (inside && delta > 1) {
evaluated: inside
TRUEFALSE
yes
Evaluation Count:13894
yes
Evaluation Count:2120
evaluated: delta > 1
TRUEFALSE
yes
Evaluation Count:11762
yes
Evaluation Count:2132
2120-13894
1215 int n = 1; -
1216 if (eng->cs) {
partially evaluated: eng->cs
TRUEFALSE
yes
Evaluation Count:11762
no
Evaluation Count:0
0-11762
1217 while (n < delta) {
evaluated: n < delta
TRUEFALSE
yes
Evaluation Count:64066
yes
Evaluation Count:11762
11762-64066
1218 if (in[pos + curCapBegin[ell] + n] 0-64066
1219 != in[pos + i + n])
partially evaluated: in[pos + curCapBegin[ell] + n] != in[pos + i + n]
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:64066
0-64066
1220 break;
never executed: break;
0
1221 ++n; -
1222 }
executed: }
Execution Count:64066
64066
1223 } else {
executed: }
Execution Count:11762
11762
1224 while (n < delta) {
never evaluated: n < delta
0
1225 QChar a = in[pos + curCapBegin[ell] + n]; -
1226 QChar b = in[pos + i + n]; -
1227 if (a.toLower() != b.toLower())
never evaluated: a.toLower() != b.toLower()
0
1228 break;
never executed: break;
0
1229 ++n; -
1230 }
never executed: }
0
1231 }
never executed: }
0
1232 inside = (n == delta); -
1233 if (inside)
partially evaluated: inside
TRUEFALSE
yes
Evaluation Count:11762
no
Evaluation Count:0
0-11762
1234 needSomeSleep = delta - 1;
executed: needSomeSleep = delta - 1;
Execution Count:11762
11762
1235 }
executed: }
Execution Count:11762
11762
1236 }
executed: }
Execution Count:16014
16014
1237 -
1238 }
executed: }
Execution Count:18978
18978
1239 } -
1240 -
1241 -
1242 -
1243 -
1244 if (inside) {
evaluated: inside
TRUEFALSE
yes
Evaluation Count:3572321
yes
Evaluation Count:5586523
3572321-5586523
1245 -
1246 int *capBegin, *capEnd; -
1247 -
1248 -
1249 -
1250 -
1251 -
1252 if ((m = inNextStack[next]) == -1) {
evaluated: (m = inNextStack[next]) == -1
TRUEFALSE
yes
Evaluation Count:3571801
yes
Evaluation Count:96
96-3571801
1253 m = nnext++; -
1254 nextStack[m] = next; -
1255 inNextStack[next] = m; -
1256 -
1257 capBegin = nextCapBegin + m * ncap; -
1258 capEnd = nextCapEnd + m * ncap; -
1259 -
1260 -
1261 -
1262 -
1263 -
1264 -
1265 -
1266 } else {
executed: }
Execution Count:3571666
3571666
1267 capBegin = tempCapBegin; -
1268 capEnd = tempCapEnd; -
1269 -
1270 }
executed: }
Execution Count:96
96
1271 -
1272 -
1273 -
1274 -
1275 -
1276 if (ncap > 0) {
evaluated: ncap > 0
TRUEFALSE
yes
Evaluation Count:2068707
yes
Evaluation Count:1502196
1502196-2068707
1277 memcpy(capBegin, curCapBegin + j * ncap, ncap * sizeof(int)); -
1278 memcpy(capEnd, curCapEnd + j * ncap, ncap * sizeof(int)); -
1279 int c = scur.atom, n = snext.atom; -
1280 int p = -1, q = -1; -
1281 int cap; -
1282 if ((q = scur.reenter.value(next)) != 0) {
evaluated: (q = scur.reenter.value(next)) != 0
TRUEFALSE
yes
Evaluation Count:6244
yes
Evaluation Count:2061938
6244-2061938
1283 QBitArray b(eng->nf, false); -
1284 b.setBit(q, true); -
1285 for (int ell = q + 1; ell < eng->nf; ell++) {
evaluated: ell < eng->nf
TRUEFALSE
yes
Evaluation Count:55417
yes
Evaluation Count:6244
6244-55417
1286 if (b.testBit(eng->f.at(ell).parent)) {
evaluated: b.testBit(eng->f.at(ell).parent)
TRUEFALSE
yes
Evaluation Count:31969
yes
Evaluation Count:23448
23448-31969
1287 b.setBit(ell, true); -
1288 cap = eng->f.at(ell).capture; -
1289 if (cap >= 0) {
evaluated: cap >= 0
TRUEFALSE
yes
Evaluation Count:3250
yes
Evaluation Count:28719
3250-28719
1290 capBegin[cap] = EmptyCapture; -
1291 capEnd[cap] = EmptyCapture; -
1292 }
executed: }
Execution Count:3250
3250
1293 }
executed: }
Execution Count:31969
31969
1294 }
executed: }
Execution Count:55417
55417
1295 p = eng->f.at(q).parent; -
1296 } else {
executed: }
Execution Count:6244
6244
1297 p = c; -
1298 q = n; -
1299 while (p != q) {
evaluated: p != q
TRUEFALSE
yes
Evaluation Count:3121959
yes
Evaluation Count:2060584
2060584-3121959
1300 if (p > q) {
evaluated: p > q
TRUEFALSE
yes
Evaluation Count:1669920
yes
Evaluation Count:1456666
1456666-1669920
1301 cap = eng->f.at(p).capture; -
1302 if (cap >= 0) {
evaluated: cap >= 0
TRUEFALSE
yes
Evaluation Count:321262
yes
Evaluation Count:1349581
321262-1349581
1303 if (capBegin[cap] == i) {
partially evaluated: capBegin[cap] == i
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:321258
0-321258
1304 capBegin[cap] = EmptyCapture; -
1305 capEnd[cap] = EmptyCapture; -
1306 } else {
never executed: }
0
1307 capEnd[cap] = i; -
1308 }
executed: }
Execution Count:321270
321270
1309 } -
1310 p = eng->f.at(p).parent; -
1311 } else {
executed: }
Execution Count:1670003
1670003
1312 q = eng->f.at(q).parent; -
1313 }
executed: }
Execution Count:1456952
1456952
1314 } -
1315 }
executed: }
Execution Count:2060977
2060977
1316 -
1317 -
1318 -
1319 -
1320 -
1321 -
1322 -
1323 while (n > p) {
evaluated: n > p
TRUEFALSE
yes
Evaluation Count:1474286
yes
Evaluation Count:2066755
1474286-2066755
1324 cap = eng->f.at(n).capture; -
1325 if (cap >= 0) {
evaluated: cap >= 0
TRUEFALSE
yes
Evaluation Count:219909
yes
Evaluation Count:1255364
219909-1255364
1326 capBegin[cap] = i; -
1327 capEnd[cap] = EmptyCapture; -
1328 }
executed: }
Execution Count:219910
219910
1329 n = eng->f.at(n).parent; -
1330 }
executed: }
Execution Count:1474226
1474226
1331 -
1332 -
1333 -
1334 -
1335 -
1336 if (capBegin == tempCapBegin &&
evaluated: capBegin == tempCapBegin
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:2065653
79-2065653
1337 isBetterCapture(ncap, capBegin, capEnd, nextCapBegin + m * ncap, 12-67
1338 nextCapEnd + m * ncap)) {
evaluated: isBetterCapture(ncap, capBegin, capEnd, nextCapBegin + m * ncap, nextCapEnd + m * ncap)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:67
12-67
1339 memcpy(nextCapBegin + m * ncap, capBegin, ncap * sizeof(int)); -
1340 memcpy(nextCapEnd + m * ncap, capEnd, ncap * sizeof(int)); -
1341 }
executed: }
Execution Count:12
12
1342 }
executed: }
Execution Count:2066863
2066863
1343 -
1344 -
1345 -
1346 -
1347 -
1348 -
1349 -
1350 if (needSomeSleep > 0) {
evaluated: needSomeSleep > 0
TRUEFALSE
yes
Evaluation Count:11762
yes
Evaluation Count:3557355
11762-3557355
1351 QVector<int> zzZ(2 + 2 * ncap); -
1352 zzZ[0] = i + needSomeSleep; -
1353 zzZ[1] = next; -
1354 if (ncap > 0) {
partially evaluated: ncap > 0
TRUEFALSE
yes
Evaluation Count:11762
no
Evaluation Count:0
0-11762
1355 memcpy(zzZ.data() + 2, capBegin, ncap * sizeof(int)); -
1356 memcpy(zzZ.data() + 2 + ncap, capEnd, ncap * sizeof(int)); -
1357 }
executed: }
Execution Count:11762
11762
1358 inNextStack[nextStack[--nnext]] = -1; -
1359 sleeping.append(zzZ); -
1360 }
executed: }
Execution Count:11762
11762
1361 -
1362 -
1363 }
executed: }
Execution Count:3568635
3568635
1364 }
executed: }
Execution Count:9121682
9121682
1365 }
executed: }
Execution Count:4672613
4672613
1366 -
1367 -
1368 -
1369 -
1370 -
1371 if (ncap > 0 && (m = inNextStack[QRegExpEngine::FinalState]) != -1) {
evaluated: ncap > 0
TRUEFALSE
yes
Evaluation Count:2009815
yes
Evaluation Count:2082536
evaluated: (m = inNextStack[QRegExpEngine::FinalState]) != -1
TRUEFALSE
yes
Evaluation Count:317879
yes
Evaluation Count:1694304
317879-2082536
1372 memcpy(capBegin, nextCapBegin + m * ncap, ncap * sizeof(int)); -
1373 memcpy(capEnd, nextCapEnd + m * ncap, ncap * sizeof(int)); -
1374 }
executed: }
Execution Count:317901
317901
1375 -
1376 -
1377 -
1378 -
1379 j = 0; -
1380 while (j < sleeping.count()) {
evaluated: j < sleeping.count()
TRUEFALSE
yes
Evaluation Count:75828
yes
Evaluation Count:4092589
75828-4092589
1381 if (sleeping.at(j)[0] == i) {
evaluated: sleeping.at(j)[0] == i
TRUEFALSE
yes
Evaluation Count:11762
yes
Evaluation Count:64066
11762-64066
1382 const QVector<int> &zzZ = sleeping.at(j); -
1383 int next = zzZ[1]; -
1384 const int *capBegin = zzZ.data() + 2; -
1385 const int *capEnd = zzZ.data() + 2 + ncap; -
1386 bool copyOver = true; -
1387 -
1388 if ((m = inNextStack[next]) == -1) {
evaluated: (m = inNextStack[next]) == -1
TRUEFALSE
yes
Evaluation Count:11742
yes
Evaluation Count:20
20-11742
1389 m = nnext++; -
1390 nextStack[m] = next; -
1391 inNextStack[next] = m; -
1392 } else {
executed: }
Execution Count:11742
11742
1393 copyOver = isBetterCapture(ncap, nextCapBegin + m * ncap, nextCapEnd + m * ncap, -
1394 capBegin, capEnd); -
1395 }
executed: }
Execution Count:20
20
1396 if (copyOver) {
partially evaluated: copyOver
TRUEFALSE
yes
Evaluation Count:11762
no
Evaluation Count:0
0-11762
1397 memcpy(nextCapBegin + m * ncap, capBegin, ncap * sizeof(int)); -
1398 memcpy(nextCapEnd + m * ncap, capEnd, ncap * sizeof(int)); -
1399 }
executed: }
Execution Count:11762
11762
1400 -
1401 sleeping.removeAt(j); -
1402 } else {
executed: }
Execution Count:11762
11762
1403 ++j; -
1404 }
executed: }
Execution Count:64066
64066
1405 } -
1406 -
1407 -
1408 for (j = 0; j < nnext; j++)
evaluated: j < nnext
TRUEFALSE
yes
Evaluation Count:3566278
yes
Evaluation Count:4093026
3566278-4093026
1409 inNextStack[nextStack[j]] = -1;
executed: inNextStack[nextStack[j]] = -1;
Execution Count:3566329
3566329
1410 -
1411 -
1412 if (nnext == 1 && nextStack[0] == QRegExpEngine::FinalState
evaluated: nnext == 1
TRUEFALSE
yes
Evaluation Count:2297135
yes
Evaluation Count:1796205
evaluated: nextStack[0] == QRegExpEngine::FinalState
TRUEFALSE
yes
Evaluation Count:408497
yes
Evaluation Count:1890864
408497-2297135
1413 -
1414 && sleeping.isEmpty()
partially evaluated: sleeping.isEmpty()
TRUEFALSE
yes
Evaluation Count:408497
no
Evaluation Count:0
0-408497
1415 -
1416 ) -
1417 stop = true;
executed: stop = true;
Execution Count:408490
408490
1418 -
1419 qSwap(curStack, nextStack); -
1420 -
1421 qSwap(curCapBegin, nextCapBegin); -
1422 qSwap(curCapEnd, nextCapEnd); -
1423 -
1424 ncur = nnext; -
1425 nnext = 0; -
1426 ++i; -
1427 }
executed: }
Execution Count:4093962
4093962
1428 -
1429 -
1430 -
1431 -
1432 -
1433 -
1434 if (!sleeping.isEmpty())
partially evaluated: !sleeping.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1569667
0-1569667
1435 sleeping.clear();
never executed: sleeping.clear();
0
1436 -
1437 -
1438 oneTestMatchedLen = i - 1; -
1439 return (matchLen >= 0);
executed: return (matchLen >= 0);
Execution Count:1569650
1569650
1440} -
1441 -
1442 -
1443 -
1444QRegExpCharClass::QRegExpCharClass() -
1445 : c(0), n(false) -
1446{ -
1447 -
1448 occ1.fill(NoOccurrence, NumBadChars); -
1449 -
1450}
executed: }
Execution Count:29117
29117
1451 -
1452QRegExpCharClass &QRegExpCharClass::operator=(const QRegExpCharClass &cc) -
1453{ -
1454 c = cc.c; -
1455 r = cc.r; -
1456 n = cc.n; -
1457 -
1458 occ1 = cc.occ1; -
1459 -
1460 return *this;
executed: return *this;
Execution Count:18648
18648
1461} -
1462 -
1463void QRegExpCharClass::clear() -
1464{ -
1465 c = 0; -
1466 r.resize(0); -
1467 n = false; -
1468}
executed: }
Execution Count:32574
32574
1469 -
1470void QRegExpCharClass::setNegative(bool negative) -
1471{ -
1472 n = negative; -
1473 -
1474 occ1.fill(0, NumBadChars); -
1475 -
1476}
executed: }
Execution Count:1363
1363
1477 -
1478void QRegExpCharClass::addCategories(uint cats) -
1479{ -
1480 static const int all_cats = (1 << (QChar::Mark_NonSpacing)) | -
1481 (1 << (QChar::Mark_SpacingCombining)) | -
1482 (1 << (QChar::Mark_Enclosing)) | -
1483 (1 << (QChar::Number_DecimalDigit)) | -
1484 (1 << (QChar::Number_Letter)) | -
1485 (1 << (QChar::Number_Other)) | -
1486 (1 << (QChar::Separator_Space)) | -
1487 (1 << (QChar::Separator_Line)) | -
1488 (1 << (QChar::Separator_Paragraph)) | -
1489 (1 << (QChar::Other_Control)) | -
1490 (1 << (QChar::Other_Format)) | -
1491 (1 << (QChar::Other_Surrogate)) | -
1492 (1 << (QChar::Other_PrivateUse)) | -
1493 (1 << (QChar::Other_NotAssigned)) | -
1494 (1 << (QChar::Letter_Uppercase)) | -
1495 (1 << (QChar::Letter_Lowercase)) | -
1496 (1 << (QChar::Letter_Titlecase)) | -
1497 (1 << (QChar::Letter_Modifier)) | -
1498 (1 << (QChar::Letter_Other)) | -
1499 (1 << (QChar::Punctuation_Connector)) | -
1500 (1 << (QChar::Punctuation_Dash)) | -
1501 (1 << (QChar::Punctuation_Open)) | -
1502 (1 << (QChar::Punctuation_Close)) | -
1503 (1 << (QChar::Punctuation_InitialQuote)) | -
1504 (1 << (QChar::Punctuation_FinalQuote)) | -
1505 (1 << (QChar::Punctuation_Other)) | -
1506 (1 << (QChar::Symbol_Math)) | -
1507 (1 << (QChar::Symbol_Currency)) | -
1508 (1 << (QChar::Symbol_Modifier)) | -
1509 (1 << (QChar::Symbol_Other)); -
1510 c |= (all_cats & cats); -
1511 -
1512 occ1.fill(0, NumBadChars); -
1513 -
1514}
executed: }
Execution Count:169
169
1515 -
1516void QRegExpCharClass::addRange(ushort from, ushort to) -
1517{ -
1518 if (from > to)
partially evaluated: from > to
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7693
0-7693
1519 qSwap(from, to);
never executed: qSwap(from, to);
0
1520 int m = r.size(); -
1521 r.resize(m + 1); -
1522 r[m].from = from; -
1523 r[m].len = to - from + 1; -
1524 -
1525 -
1526 int i; -
1527 -
1528 if (to - from < NumBadChars) {
evaluated: to - from < NumBadChars
TRUEFALSE
yes
Evaluation Count:6573
yes
Evaluation Count:1120
1120-6573
1529 if (from % NumBadChars <= to % NumBadChars) {
evaluated: from % NumBadChars <= to % NumBadChars
TRUEFALSE
yes
Evaluation Count:6559
yes
Evaluation Count:14
14-6559
1530 for (i = from % NumBadChars; i <= to % NumBadChars; i++)
evaluated: i <= to % NumBadChars
TRUEFALSE
yes
Evaluation Count:14737
yes
Evaluation Count:6559
6559-14737
1531 occ1[i] = 0;
executed: occ1[i] = 0;
Execution Count:14737
14737
1532 } else {
executed: }
Execution Count:6559
6559
1533 for (i = 0; i <= to % NumBadChars; i++)
evaluated: i <= to % NumBadChars
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:14
14-62
1534 occ1[i] = 0;
executed: occ1[i] = 0;
Execution Count:62
62
1535 for (i = from % NumBadChars; i < NumBadChars; i++)
evaluated: i < NumBadChars
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:14
14
1536 occ1[i] = 0;
executed: occ1[i] = 0;
Execution Count:14
14
1537 }
executed: }
Execution Count:14
14
1538 } else { -
1539 occ1.fill(0, NumBadChars); -
1540 }
executed: }
Execution Count:1120
1120
1541 -
1542} -
1543 -
1544bool QRegExpCharClass::in(QChar ch) const -
1545{ -
1546 -
1547 if (occ1.at(((ch).unicode() % NumBadChars)) == NoOccurrence)
evaluated: occ1.at(((ch).unicode() % NumBadChars)) == NoOccurrence
TRUEFALSE
yes
Evaluation Count:699562
yes
Evaluation Count:3033464
699562-3033464
1548 return n;
executed: return n;
Execution Count:699567
699567
1549 -
1550 -
1551 if (c != 0 && (c & (1 << (ch.category()))) != 0)
evaluated: c != 0
TRUEFALSE
yes
Evaluation Count:399786
yes
Evaluation Count:2633637
evaluated: (c & (1 << (ch.category()))) != 0
TRUEFALSE
yes
Evaluation Count:200271
yes
Evaluation Count:199515
199515-2633637
1552 return !n;
executed: return !n;
Execution Count:200271
200271
1553 -
1554 const int uc = ch.unicode(); -
1555 int size = r.size(); -
1556 -
1557 for (int i = 0; i < size; ++i) {
evaluated: i < size
TRUEFALSE
yes
Evaluation Count:20687196
yes
Evaluation Count:1524591
1524591-20687196
1558 const QRegExpCharClassRange &range = r.at(i); -
1559 if (uint(uc - range.from) < uint(r.at(i).len))
evaluated: uint(uc - range.from) < uint(r.at(i).len)
TRUEFALSE
yes
Evaluation Count:1308582
yes
Evaluation Count:19378641
1308582-19378641
1560 return !n;
executed: return !n;
Execution Count:1308561
1308561
1561 }
executed: }
Execution Count:19378641
19378641
1562 return n;
executed: return n;
Execution Count:1524591
1524591
1563} -
1564QRegExpEngine::Box::Box(QRegExpEngine *engine) -
1565 : eng(engine), skipanchors(0) -
1566 -
1567 , earlyStart(0), lateStart(0), maxl(0) -
1568 -
1569{ -
1570 -
1571 occ1.fill(NoOccurrence, NumBadChars); -
1572 -
1573 minl = 0; -
1574}
executed: }
Execution Count:30554
30554
1575 -
1576QRegExpEngine::Box &QRegExpEngine::Box::operator=(const Box &b) -
1577{ -
1578 eng = b.eng; -
1579 ls = b.ls; -
1580 rs = b.rs; -
1581 lanchors = b.lanchors; -
1582 ranchors = b.ranchors; -
1583 skipanchors = b.skipanchors; -
1584 -
1585 earlyStart = b.earlyStart; -
1586 lateStart = b.lateStart; -
1587 str = b.str; -
1588 leftStr = b.leftStr; -
1589 rightStr = b.rightStr; -
1590 maxl = b.maxl; -
1591 occ1 = b.occ1; -
1592 -
1593 minl = b.minl; -
1594 return *this;
executed: return *this;
Execution Count:2752
2752
1595} -
1596 -
1597void QRegExpEngine::Box::set(QChar ch) -
1598{ -
1599 ls.resize(1); -
1600 ls[0] = eng->createState(ch); -
1601 rs = ls; -
1602 -
1603 str = ch; -
1604 leftStr = ch; -
1605 rightStr = ch; -
1606 maxl = 1; -
1607 occ1[((ch).unicode() % NumBadChars)] = 0; -
1608 -
1609 minl = 1; -
1610}
executed: }
Execution Count:22163
22163
1611 -
1612void QRegExpEngine::Box::set(const QRegExpCharClass &cc) -
1613{ -
1614 ls.resize(1); -
1615 ls[0] = eng->createState(cc); -
1616 rs = ls; -
1617 -
1618 maxl = 1; -
1619 occ1 = cc.firstOccurrence(); -
1620 -
1621 minl = 1; -
1622}
executed: }
Execution Count:5337
5337
1623 -
1624 -
1625void QRegExpEngine::Box::set(int bref) -
1626{ -
1627 ls.resize(1); -
1628 ls[0] = eng->createState(bref); -
1629 rs = ls; -
1630 if (bref >= 1 && bref <= MaxBackRefs)
partially evaluated: bref >= 1
TRUEFALSE
yes
Evaluation Count:190
no
Evaluation Count:0
partially evaluated: bref <= MaxBackRefs
TRUEFALSE
yes
Evaluation Count:190
no
Evaluation Count:0
0-190
1631 skipanchors = Anchor_BackRef0Empty << bref;
executed: skipanchors = Anchor_BackRef0Empty << bref;
Execution Count:190
190
1632 -
1633 maxl = InftyLen; -
1634 -
1635 minl = 0; -
1636}
executed: }
Execution Count:190
190
1637 -
1638 -
1639void QRegExpEngine::Box::cat(const Box &b) -
1640{ -
1641 eng->addCatTransitions(rs, b.ls); -
1642 addAnchorsToEngine(b); -
1643 if (minl == 0) {
evaluated: minl == 0
TRUEFALSE
yes
Evaluation Count:2598
yes
Evaluation Count:26050
2598-26050
1644 lanchors.unite(b.lanchors); -
1645 if (skipanchors != 0) {
evaluated: skipanchors != 0
TRUEFALSE
yes
Evaluation Count:242
yes
Evaluation Count:2356
242-2356
1646 for (int i = 0; i < b.ls.size(); i++) {
evaluated: i < b.ls.size()
TRUEFALSE
yes
Evaluation Count:381
yes
Evaluation Count:242
242-381
1647 int a = eng->anchorConcatenation(lanchors.value(b.ls.at(i), 0), skipanchors); -
1648 lanchors.insert(b.ls.at(i), a); -
1649 }
executed: }
Execution Count:381
381
1650 }
executed: }
Execution Count:242
242
1651 mergeInto(&ls, b.ls); -
1652 }
executed: }
Execution Count:2598
2598
1653 if (b.minl == 0) {
evaluated: b.minl == 0
TRUEFALSE
yes
Evaluation Count:4578
yes
Evaluation Count:24070
4578-24070
1654 ranchors.unite(b.ranchors); -
1655 if (b.skipanchors != 0) {
evaluated: b.skipanchors != 0
TRUEFALSE
yes
Evaluation Count:398
yes
Evaluation Count:4180
398-4180
1656 for (int i = 0; i < rs.size(); i++) {
evaluated: i < rs.size()
TRUEFALSE
yes
Evaluation Count:1017
yes
Evaluation Count:398
398-1017
1657 int a = eng->anchorConcatenation(ranchors.value(rs.at(i), 0), b.skipanchors); -
1658 ranchors.insert(rs.at(i), a); -
1659 }
executed: }
Execution Count:1017
1017
1660 }
executed: }
Execution Count:398
398
1661 mergeInto(&rs, b.rs); -
1662 } else {
executed: }
Execution Count:4578
4578
1663 ranchors = b.ranchors; -
1664 rs = b.rs; -
1665 }
executed: }
Execution Count:24070
24070
1666 -
1667 -
1668 if (maxl != InftyLen) {
evaluated: maxl != InftyLen
TRUEFALSE
yes
Evaluation Count:25852
yes
Evaluation Count:2796
2796-25852
1669 if (rightStr.length() + b.leftStr.length() > 6686-19166
1670 qMax(str.length(), b.str.length())) {
evaluated: rightStr.length() + b.leftStr.length() > qMax(str.length(), b.str.length())
TRUEFALSE
yes
Evaluation Count:19166
yes
Evaluation Count:6686
6686-19166
1671 earlyStart = minl - rightStr.length(); -
1672 lateStart = maxl - rightStr.length(); -
1673 str = rightStr + b.leftStr; -
1674 } else if (b.str.length() > str.length()) {
executed: }
Execution Count:19166
evaluated: b.str.length() > str.length()
TRUEFALSE
yes
Evaluation Count:820
yes
Evaluation Count:5866
820-19166
1675 earlyStart = minl + b.earlyStart; -
1676 lateStart = maxl + b.lateStart; -
1677 str = b.str; -
1678 }
executed: }
Execution Count:820
820
1679 } -
1680 -
1681 if (leftStr.length() == maxl)
evaluated: leftStr.length() == maxl
TRUEFALSE
yes
Evaluation Count:22456
yes
Evaluation Count:6192
6192-22456
1682 leftStr += b.leftStr;
executed: leftStr += b.leftStr;
Execution Count:22456
22456
1683 -
1684 if (b.rightStr.length() == b.maxl) {
evaluated: b.rightStr.length() == b.maxl
TRUEFALSE
yes
Evaluation Count:21268
yes
Evaluation Count:7380
7380-21268
1685 rightStr += b.rightStr; -
1686 } else {
executed: }
Execution Count:21268
21268
1687 rightStr = b.rightStr; -
1688 }
executed: }
Execution Count:7380
7380
1689 -
1690 if (maxl == InftyLen || b.maxl == InftyLen) {
evaluated: maxl == InftyLen
TRUEFALSE
yes
Evaluation Count:2796
yes
Evaluation Count:25852
evaluated: b.maxl == InftyLen
TRUEFALSE
yes
Evaluation Count:3164
yes
Evaluation Count:22688
2796-25852
1691 maxl = InftyLen; -
1692 } else {
executed: }
Execution Count:5960
5960
1693 maxl += b.maxl; -
1694 }
executed: }
Execution Count:22688
22688
1695 -
1696 for (int i = 0; i < NumBadChars; i++) {
evaluated: i < NumBadChars
TRUEFALSE
yes
Evaluation Count:1832210
yes
Evaluation Count:28645
28645-1832210
1697 if (b.occ1.at(i) != NoOccurrence && minl + b.occ1.at(i) < occ1.at(i))
evaluated: b.occ1.at(i) != NoOccurrence
TRUEFALSE
yes
Evaluation Count:318573
yes
Evaluation Count:1513777
evaluated: minl + b.occ1.at(i) < occ1.at(i)
TRUEFALSE
yes
Evaluation Count:197941
yes
Evaluation Count:120632
120632-1513777
1698 occ1[i] = minl + b.occ1.at(i);
executed: occ1[i] = minl + b.occ1.at(i);
Execution Count:197937
197937
1699 }
executed: }
Execution Count:1832204
1832204
1700 -
1701 -
1702 minl += b.minl; -
1703 if (minl == 0)
evaluated: minl == 0
TRUEFALSE
yes
Evaluation Count:2176
yes
Evaluation Count:26470
2176-26470
1704 skipanchors = eng->anchorConcatenation(skipanchors, b.skipanchors);
executed: skipanchors = eng->anchorConcatenation(skipanchors, b.skipanchors);
Execution Count:2176
2176
1705 else -
1706 skipanchors = 0;
executed: skipanchors = 0;
Execution Count:26470
26470
1707} -
1708 -
1709void QRegExpEngine::Box::orx(const Box &b) -
1710{ -
1711 mergeInto(&ls, b.ls); -
1712 lanchors.unite(b.lanchors); -
1713 mergeInto(&rs, b.rs); -
1714 ranchors.unite(b.ranchors); -
1715 -
1716 if (b.minl == 0) {
evaluated: b.minl == 0
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:401
60-401
1717 if (minl == 0)
evaluated: minl == 0
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:20
20-40
1718 skipanchors = eng->anchorAlternation(skipanchors, b.skipanchors);
executed: skipanchors = eng->anchorAlternation(skipanchors, b.skipanchors);
Execution Count:40
40
1719 else -
1720 skipanchors = b.skipanchors;
executed: skipanchors = b.skipanchors;
Execution Count:20
20
1721 } -
1722 -
1723 -
1724 for (int i = 0; i < NumBadChars; i++) {
evaluated: i < NumBadChars
TRUEFALSE
yes
Evaluation Count:29504
yes
Evaluation Count:461
461-29504
1725 if (occ1.at(i) > b.occ1.at(i))
evaluated: occ1.at(i) > b.occ1.at(i)
TRUEFALSE
yes
Evaluation Count:1067
yes
Evaluation Count:28437
1067-28437
1726 occ1[i] = b.occ1.at(i);
executed: occ1[i] = b.occ1.at(i);
Execution Count:1067
1067
1727 }
executed: }
Execution Count:29504
29504
1728 earlyStart = 0; -
1729 lateStart = 0; -
1730 str = QString(); -
1731 leftStr = QString(); -
1732 rightStr = QString(); -
1733 if (b.maxl > maxl)
evaluated: b.maxl > maxl
TRUEFALSE
yes
Evaluation Count:209
yes
Evaluation Count:252
209-252
1734 maxl = b.maxl;
executed: maxl = b.maxl;
Execution Count:209
209
1735 -
1736 if (b.minl < minl)
evaluated: b.minl < minl
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:423
38-423
1737 minl = b.minl;
executed: minl = b.minl;
Execution Count:38
38
1738}
executed: }
Execution Count:461
461
1739 -
1740void QRegExpEngine::Box::plus(int atom) -
1741{ -
1742 -
1743 eng->addPlusTransitions(rs, ls, atom); -
1744 -
1745 -
1746 -
1747 -
1748 addAnchorsToEngine(*this); -
1749 -
1750 maxl = InftyLen; -
1751 -
1752}
executed: }
Execution Count:2011
2011
1753 -
1754void QRegExpEngine::Box::opt() -
1755{ -
1756 -
1757 earlyStart = 0; -
1758 lateStart = 0; -
1759 str = QString(); -
1760 leftStr = QString(); -
1761 rightStr = QString(); -
1762 -
1763 skipanchors = 0; -
1764 minl = 0; -
1765}
executed: }
Execution Count:2049
2049
1766 -
1767void QRegExpEngine::Box::catAnchor(int a) -
1768{ -
1769 if (a != 0) {
partially evaluated: a != 0
TRUEFALSE
yes
Evaluation Count:342
no
Evaluation Count:0
0-342
1770 for (int i = 0; i < rs.size(); i++) {
partially evaluated: i < rs.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:342
0-342
1771 a = eng->anchorConcatenation(ranchors.value(rs.at(i), 0), a); -
1772 ranchors.insert(rs.at(i), a); -
1773 }
never executed: }
0
1774 if (minl == 0)
partially evaluated: minl == 0
TRUEFALSE
yes
Evaluation Count:342
no
Evaluation Count:0
0-342
1775 skipanchors = eng->anchorConcatenation(skipanchors, a);
executed: skipanchors = eng->anchorConcatenation(skipanchors, a);
Execution Count:342
342
1776 }
executed: }
Execution Count:342
342
1777}
executed: }
Execution Count:342
342
1778 -
1779 -
1780void QRegExpEngine::Box::setupHeuristics() -
1781{ -
1782 eng->goodEarlyStart = earlyStart; -
1783 eng->goodLateStart = lateStart; -
1784 eng->goodStr = eng->cs ? str : str.toLower();
evaluated: eng->cs
TRUEFALSE
yes
Evaluation Count:1210
yes
Evaluation Count:213
213-1210
1785 -
1786 eng->minl = minl; -
1787 if (eng->cs) {
evaluated: eng->cs
TRUEFALSE
yes
Evaluation Count:1210
yes
Evaluation Count:213
213-1210
1788 for (int i = 0; i < NumBadChars; i++) {
evaluated: i < NumBadChars
TRUEFALSE
yes
Evaluation Count:77440
yes
Evaluation Count:1210
1210-77440
1789 if (occ1.at(i) != NoOccurrence && occ1.at(i) >= minl)
evaluated: occ1.at(i) != NoOccurrence
TRUEFALSE
yes
Evaluation Count:18036
yes
Evaluation Count:59404
evaluated: occ1.at(i) >= minl
TRUEFALSE
yes
Evaluation Count:1406
yes
Evaluation Count:16630
1406-59404
1790 occ1[i] = minl;
executed: occ1[i] = minl;
Execution Count:1406
1406
1791 }
executed: }
Execution Count:77440
77440
1792 eng->occ1 = occ1; -
1793 } else {
executed: }
Execution Count:1210
1210
1794 eng->occ1.fill(0, NumBadChars); -
1795 }
executed: }
Execution Count:213
213
1796 -
1797 eng->heuristicallyChooseHeuristic(); -
1798}
executed: }
Execution Count:1423
1423
1799void QRegExpEngine::Box::addAnchorsToEngine(const Box &to) const -
1800{ -
1801 for (int i = 0; i < to.ls.size(); i++) {
evaluated: i < to.ls.size()
TRUEFALSE
yes
Evaluation Count:31562
yes
Evaluation Count:30659
30659-31562
1802 for (int j = 0; j < rs.size(); j++) {
evaluated: j < rs.size()
TRUEFALSE
yes
Evaluation Count:34990
yes
Evaluation Count:31562
31562-34990
1803 int a = eng->anchorConcatenation(ranchors.value(rs.at(j), 0), -
1804 to.lanchors.value(to.ls.at(i), 0)); -
1805 eng->addAnchors(rs[j], to.ls[i], a); -
1806 }
executed: }
Execution Count:34991
34991
1807 }
executed: }
Execution Count:31562
31562
1808}
executed: }
Execution Count:30659
30659
1809 -
1810 -
1811 -
1812 -
1813static const struct CategoriesRangeMapEntry { -
1814 const char name[40]; -
1815 uint first, second; -
1816} categoriesRangeMap[] = { -
1817 { "AegeanNumbers", 0x10100, 0x1013F }, -
1818 { "AlphabeticPresentationForms", 0xFB00, 0xFB4F }, -
1819 { "AncientGreekMusicalNotation", 0x1D200, 0x1D24F }, -
1820 { "AncientGreekNumbers", 0x10140, 0x1018F }, -
1821 { "Arabic", 0x0600, 0x06FF }, -
1822 { "ArabicPresentationForms-A", 0xFB50, 0xFDFF }, -
1823 { "ArabicPresentationForms-B", 0xFE70, 0xFEFF }, -
1824 { "ArabicSupplement", 0x0750, 0x077F }, -
1825 { "Armenian", 0x0530, 0x058F }, -
1826 { "Arrows", 0x2190, 0x21FF }, -
1827 { "BasicLatin", 0x0000, 0x007F }, -
1828 { "Bengali", 0x0980, 0x09FF }, -
1829 { "BlockElements", 0x2580, 0x259F }, -
1830 { "Bopomofo", 0x3100, 0x312F }, -
1831 { "BopomofoExtended", 0x31A0, 0x31BF }, -
1832 { "BoxDrawing", 0x2500, 0x257F }, -
1833 { "BraillePatterns", 0x2800, 0x28FF }, -
1834 { "Buginese", 0x1A00, 0x1A1F }, -
1835 { "Buhid", 0x1740, 0x175F }, -
1836 { "ByzantineMusicalSymbols", 0x1D000, 0x1D0FF }, -
1837 { "CJKCompatibility", 0x3300, 0x33FF }, -
1838 { "CJKCompatibilityForms", 0xFE30, 0xFE4F }, -
1839 { "CJKCompatibilityIdeographs", 0xF900, 0xFAFF }, -
1840 { "CJKCompatibilityIdeographsSupplement", 0x2F800, 0x2FA1F }, -
1841 { "CJKRadicalsSupplement", 0x2E80, 0x2EFF }, -
1842 { "CJKStrokes", 0x31C0, 0x31EF }, -
1843 { "CJKSymbolsandPunctuation", 0x3000, 0x303F }, -
1844 { "CJKUnifiedIdeographs", 0x4E00, 0x9FFF }, -
1845 { "CJKUnifiedIdeographsExtensionA", 0x3400, 0x4DB5 }, -
1846 { "CJKUnifiedIdeographsExtensionB", 0x20000, 0x2A6DF }, -
1847 { "Cherokee", 0x13A0, 0x13FF }, -
1848 { "CombiningDiacriticalMarks", 0x0300, 0x036F }, -
1849 { "CombiningDiacriticalMarksSupplement", 0x1DC0, 0x1DFF }, -
1850 { "CombiningHalfMarks", 0xFE20, 0xFE2F }, -
1851 { "CombiningMarksforSymbols", 0x20D0, 0x20FF }, -
1852 { "ControlPictures", 0x2400, 0x243F }, -
1853 { "Coptic", 0x2C80, 0x2CFF }, -
1854 { "CurrencySymbols", 0x20A0, 0x20CF }, -
1855 { "CypriotSyllabary", 0x10800, 0x1083F }, -
1856 { "Cyrillic", 0x0400, 0x04FF }, -
1857 { "CyrillicSupplement", 0x0500, 0x052F }, -
1858 { "Deseret", 0x10400, 0x1044F }, -
1859 { "Devanagari", 0x0900, 0x097F }, -
1860 { "Dingbats", 0x2700, 0x27BF }, -
1861 { "EnclosedAlphanumerics", 0x2460, 0x24FF }, -
1862 { "EnclosedCJKLettersandMonths", 0x3200, 0x32FF }, -
1863 { "Ethiopic", 0x1200, 0x137F }, -
1864 { "EthiopicExtended", 0x2D80, 0x2DDF }, -
1865 { "EthiopicSupplement", 0x1380, 0x139F }, -
1866 { "GeneralPunctuation", 0x2000, 0x206F }, -
1867 { "GeometricShapes", 0x25A0, 0x25FF }, -
1868 { "Georgian", 0x10A0, 0x10FF }, -
1869 { "GeorgianSupplement", 0x2D00, 0x2D2F }, -
1870 { "Glagolitic", 0x2C00, 0x2C5F }, -
1871 { "Gothic", 0x10330, 0x1034F }, -
1872 { "Greek", 0x0370, 0x03FF }, -
1873 { "GreekExtended", 0x1F00, 0x1FFF }, -
1874 { "Gujarati", 0x0A80, 0x0AFF }, -
1875 { "Gurmukhi", 0x0A00, 0x0A7F }, -
1876 { "HalfwidthandFullwidthForms", 0xFF00, 0xFFEF }, -
1877 { "HangulCompatibilityJamo", 0x3130, 0x318F }, -
1878 { "HangulJamo", 0x1100, 0x11FF }, -
1879 { "HangulSyllables", 0xAC00, 0xD7A3 }, -
1880 { "Hanunoo", 0x1720, 0x173F }, -
1881 { "Hebrew", 0x0590, 0x05FF }, -
1882 { "Hiragana", 0x3040, 0x309F }, -
1883 { "IPAExtensions", 0x0250, 0x02AF }, -
1884 { "IdeographicDescriptionCharacters", 0x2FF0, 0x2FFF }, -
1885 { "Kanbun", 0x3190, 0x319F }, -
1886 { "KangxiRadicals", 0x2F00, 0x2FDF }, -
1887 { "Kannada", 0x0C80, 0x0CFF }, -
1888 { "Katakana", 0x30A0, 0x30FF }, -
1889 { "KatakanaPhoneticExtensions", 0x31F0, 0x31FF }, -
1890 { "Kharoshthi", 0x10A00, 0x10A5F }, -
1891 { "Khmer", 0x1780, 0x17FF }, -
1892 { "KhmerSymbols", 0x19E0, 0x19FF }, -
1893 { "Lao", 0x0E80, 0x0EFF }, -
1894 { "Latin-1Supplement", 0x0080, 0x00FF }, -
1895 { "LatinExtended-A", 0x0100, 0x017F }, -
1896 { "LatinExtended-B", 0x0180, 0x024F }, -
1897 { "LatinExtendedAdditional", 0x1E00, 0x1EFF }, -
1898 { "LetterlikeSymbols", 0x2100, 0x214F }, -
1899 { "Limbu", 0x1900, 0x194F }, -
1900 { "LinearBIdeograms", 0x10080, 0x100FF }, -
1901 { "LinearBSyllabary", 0x10000, 0x1007F }, -
1902 { "Malayalam", 0x0D00, 0x0D7F }, -
1903 { "MathematicalAlphanumericSymbols", 0x1D400, 0x1D7FF }, -
1904 { "MathematicalOperators", 0x2200, 0x22FF }, -
1905 { "MiscellaneousMathematicalSymbols-A", 0x27C0, 0x27EF }, -
1906 { "MiscellaneousMathematicalSymbols-B", 0x2980, 0x29FF }, -
1907 { "MiscellaneousSymbols", 0x2600, 0x26FF }, -
1908 { "MiscellaneousSymbolsandArrows", 0x2B00, 0x2BFF }, -
1909 { "MiscellaneousTechnical", 0x2300, 0x23FF }, -
1910 { "ModifierToneLetters", 0xA700, 0xA71F }, -
1911 { "Mongolian", 0x1800, 0x18AF }, -
1912 { "MusicalSymbols", 0x1D100, 0x1D1FF }, -
1913 { "Myanmar", 0x1000, 0x109F }, -
1914 { "NewTaiLue", 0x1980, 0x19DF }, -
1915 { "NumberForms", 0x2150, 0x218F }, -
1916 { "Ogham", 0x1680, 0x169F }, -
1917 { "OldItalic", 0x10300, 0x1032F }, -
1918 { "OldPersian", 0x103A0, 0x103DF }, -
1919 { "OpticalCharacterRecognition", 0x2440, 0x245F }, -
1920 { "Oriya", 0x0B00, 0x0B7F }, -
1921 { "Osmanya", 0x10480, 0x104AF }, -
1922 { "PhoneticExtensions", 0x1D00, 0x1D7F }, -
1923 { "PhoneticExtensionsSupplement", 0x1D80, 0x1DBF }, -
1924 { "PrivateUse", 0xE000, 0xF8FF }, -
1925 { "Runic", 0x16A0, 0x16FF }, -
1926 { "Shavian", 0x10450, 0x1047F }, -
1927 { "Sinhala", 0x0D80, 0x0DFF }, -
1928 { "SmallFormVariants", 0xFE50, 0xFE6F }, -
1929 { "SpacingModifierLetters", 0x02B0, 0x02FF }, -
1930 { "Specials", 0xFFF0, 0xFFFF }, -
1931 { "SuperscriptsandSubscripts", 0x2070, 0x209F }, -
1932 { "SupplementalArrows-A", 0x27F0, 0x27FF }, -
1933 { "SupplementalArrows-B", 0x2900, 0x297F }, -
1934 { "SupplementalMathematicalOperators", 0x2A00, 0x2AFF }, -
1935 { "SupplementalPunctuation", 0x2E00, 0x2E7F }, -
1936 { "SupplementaryPrivateUseArea-A", 0xF0000, 0xFFFFF }, -
1937 { "SupplementaryPrivateUseArea-B", 0x100000, 0x10FFFF }, -
1938 { "SylotiNagri", 0xA800, 0xA82F }, -
1939 { "Syriac", 0x0700, 0x074F }, -
1940 { "Tagalog", 0x1700, 0x171F }, -
1941 { "Tagbanwa", 0x1760, 0x177F }, -
1942 { "Tags", 0xE0000, 0xE007F }, -
1943 { "TaiLe", 0x1950, 0x197F }, -
1944 { "TaiXuanJingSymbols", 0x1D300, 0x1D35F }, -
1945 { "Tamil", 0x0B80, 0x0BFF }, -
1946 { "Telugu", 0x0C00, 0x0C7F }, -
1947 { "Thaana", 0x0780, 0x07BF }, -
1948 { "Thai", 0x0E00, 0x0E7F }, -
1949 { "Tibetan", 0x0F00, 0x0FFF }, -
1950 { "Tifinagh", 0x2D30, 0x2D7F }, -
1951 { "Ugaritic", 0x10380, 0x1039F }, -
1952 { "UnifiedCanadianAboriginalSyllabics", 0x1400, 0x167F }, -
1953 { "VariationSelectors", 0xFE00, 0xFE0F }, -
1954 { "VariationSelectorsSupplement", 0xE0100, 0xE01EF }, -
1955 { "VerticalForms", 0xFE10, 0xFE1F }, -
1956 { "YiRadicals", 0xA490, 0xA4CF }, -
1957 { "YiSyllables", 0xA000, 0xA48F }, -
1958 { "YijingHexagramSymbols", 0x4DC0, 0x4DFF } -
1959}; -
1960 -
1961inline bool operator<(const char *name, const CategoriesRangeMapEntry &entry) -
1962{ return qstrcmp(name, entry.name) < 0; }
never executed: return qstrcmp(name, entry.name) < 0;
0
1963inline bool operator<(const CategoriesRangeMapEntry &entry, const char *name) -
1964{ return qstrcmp(entry.name, name) < 0; }
never executed: return qstrcmp(entry.name, name) < 0;
0
1965 -
1966 -
1967int QRegExpEngine::getChar() -
1968{ -
1969 return (yyPos == yyLen) ? EOS : yyIn[yyPos++].unicode();
executed: return (yyPos == yyLen) ? EOS : yyIn[yyPos++].unicode();
Execution Count:66433
66433
1970} -
1971 -
1972int QRegExpEngine::getEscape() -
1973{ -
1974 -
1975 const char tab[] = "afnrtv"; -
1976 const char backTab[] = "\a\f\n\r\t\v"; -
1977 ushort low; -
1978 int i; -
1979 -
1980 ushort val; -
1981 int prevCh = yyCh; -
1982 -
1983 if (prevCh == EOS) {
evaluated: prevCh == EOS
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7362
4-7362
1984 error("unexpected end"); -
1985 return Tok_Char | '\\';
executed: return Tok_Char | '\\';
Execution Count:4
4
1986 } -
1987 yyCh = getChar(); -
1988 -
1989 if ((prevCh & ~0xff) == 0) {
partially evaluated: (prevCh & ~0xff) == 0
TRUEFALSE
yes
Evaluation Count:7362
no
Evaluation Count:0
0-7362
1990 const char *p = strchr(tab, prevCh); -
1991 if (p != 0)
evaluated: p != 0
TRUEFALSE
yes
Evaluation Count:905
yes
Evaluation Count:6457
905-6457
1992 return Tok_Char | backTab[p - tab];
executed: return Tok_Char | backTab[p - tab];
Execution Count:905
905
1993 }
executed: }
Execution Count:6457
6457
1994 -
1995 -
1996 switch (prevCh) { -
1997 -
1998 case '0': -
1999 val = 0; -
2000 for (i = 0; i < 3; i++) {
partially evaluated: i < 3
TRUEFALSE
yes
Evaluation Count:3990
no
Evaluation Count:0
0-3990
2001 if (yyCh >= '0' && yyCh <= '7')
evaluated: yyCh >= '0'
TRUEFALSE
yes
Evaluation Count:3110
yes
Evaluation Count:880
evaluated: yyCh <= '7'
TRUEFALSE
yes
Evaluation Count:2660
yes
Evaluation Count:450
450-3110
2002 val = (val << 3) | (yyCh - '0');
executed: val = (val << 3) | (yyCh - '0');
Execution Count:2660
2660
2003 else -
2004 break;
executed: break;
Execution Count:1330
1330
2005 yyCh = getChar(); -
2006 }
executed: }
Execution Count:2660
2660
2007 if ((val & ~0377) != 0)
partially evaluated: (val & ~0377) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1330
0-1330
2008 error("invalid octal value");
never executed: error("invalid octal value");
0
2009 return Tok_Char | val;
executed: return Tok_Char | val;
Execution Count:1330
1330
2010 -
2011 -
2012 case 'B': -
2013 return Tok_NonWord;
never executed: return Tok_NonWord;
0
2014 -
2015 -
2016 case 'D': -
2017 -
2018 yyCharClass->addCategories(uint(-1) ^ (1 << (QChar::Number_DecimalDigit))); -
2019 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:1
1
2020 case 'S': -
2021 -
2022 yyCharClass->addCategories(uint(-1) ^ ((1 << (QChar::Separator_Space)) | -
2023 (1 << (QChar::Separator_Line)) | -
2024 (1 << (QChar::Separator_Paragraph)) | -
2025 (1 << (QChar::Other_Control)))); -
2026 yyCharClass->addRange(0x0000, 0x0008); -
2027 yyCharClass->addRange(0x000e, 0x001f); -
2028 yyCharClass->addRange(0x007f, 0x0084); -
2029 yyCharClass->addRange(0x0086, 0x009f); -
2030 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:12
12
2031 case 'W': -
2032 -
2033 yyCharClass->addCategories(uint(-1) ^ ((1 << (QChar::Mark_NonSpacing)) | -
2034 (1 << (QChar::Mark_SpacingCombining)) | -
2035 (1 << (QChar::Mark_Enclosing)) | -
2036 (1 << (QChar::Number_DecimalDigit)) | -
2037 (1 << (QChar::Number_Letter)) | -
2038 (1 << (QChar::Number_Other)) | -
2039 (1 << (QChar::Letter_Uppercase)) | -
2040 (1 << (QChar::Letter_Lowercase)) | -
2041 (1 << (QChar::Letter_Titlecase)) | -
2042 (1 << (QChar::Letter_Modifier)) | -
2043 (1 << (QChar::Letter_Other)) | -
2044 (1 << (QChar::Punctuation_Connector)))); -
2045 yyCharClass->addRange(0x203f, 0x2040); -
2046 yyCharClass->addSingleton(0x2040); -
2047 yyCharClass->addSingleton(0x2054); -
2048 yyCharClass->addSingleton(0x30fb); -
2049 yyCharClass->addRange(0xfe33, 0xfe34); -
2050 yyCharClass->addRange(0xfe4d, 0xfe4f); -
2051 yyCharClass->addSingleton(0xff3f); -
2052 yyCharClass->addSingleton(0xff65); -
2053 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:2
2
2054 -
2055 -
2056 case 'b': -
2057 return Tok_Word;
executed: return Tok_Word;
Execution Count:1
1
2058 -
2059 -
2060 case 'd': -
2061 -
2062 yyCharClass->addCategories((1 << (QChar::Number_DecimalDigit))); -
2063 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:111
111
2064 case 's': -
2065 -
2066 yyCharClass->addCategories((1 << (QChar::Separator_Space)) | -
2067 (1 << (QChar::Separator_Line)) | -
2068 (1 << (QChar::Separator_Paragraph))); -
2069 yyCharClass->addRange(0x0009, 0x000d); -
2070 yyCharClass->addSingleton(0x0085); -
2071 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:34
34
2072 case 'w': -
2073 -
2074 yyCharClass->addCategories((1 << (QChar::Mark_NonSpacing)) | -
2075 (1 << (QChar::Mark_SpacingCombining)) | -
2076 (1 << (QChar::Mark_Enclosing)) | -
2077 (1 << (QChar::Number_DecimalDigit)) | -
2078 (1 << (QChar::Number_Letter)) | -
2079 (1 << (QChar::Number_Other)) | -
2080 (1 << (QChar::Letter_Uppercase)) | -
2081 (1 << (QChar::Letter_Lowercase)) | -
2082 (1 << (QChar::Letter_Titlecase)) | -
2083 (1 << (QChar::Letter_Modifier)) | -
2084 (1 << (QChar::Letter_Other))); -
2085 yyCharClass->addSingleton(0x005f); -
2086 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:9
9
2087 case 'I': -
2088 if (xmlSchemaExtensions) {
partially evaluated: xmlSchemaExtensions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2089 yyCharClass->setNegative(!yyCharClass->negative()); -
2090 -
2091 } else {
never executed: }
0
2092 break;
executed: break;
Execution Count:2
2
2093 } -
2094 case 'i': -
2095 if (xmlSchemaExtensions) {
partially evaluated: xmlSchemaExtensions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2096 yyCharClass->addCategories((1 << (QChar::Mark_NonSpacing)) | -
2097 (1 << (QChar::Mark_SpacingCombining)) | -
2098 (1 << (QChar::Mark_Enclosing)) | -
2099 (1 << (QChar::Number_DecimalDigit)) | -
2100 (1 << (QChar::Number_Letter)) | -
2101 (1 << (QChar::Number_Other)) | -
2102 (1 << (QChar::Letter_Uppercase)) | -
2103 (1 << (QChar::Letter_Lowercase)) | -
2104 (1 << (QChar::Letter_Titlecase)) | -
2105 (1 << (QChar::Letter_Modifier)) | -
2106 (1 << (QChar::Letter_Other))); -
2107 yyCharClass->addSingleton(0x003a); -
2108 yyCharClass->addSingleton(0x005f); -
2109 yyCharClass->addRange(0x0041, 0x005a); -
2110 yyCharClass->addRange(0x0061, 0x007a); -
2111 yyCharClass->addRange(0xc0, 0xd6); -
2112 yyCharClass->addRange(0xd8, 0xf6); -
2113 yyCharClass->addRange(0xf8, 0x2ff); -
2114 yyCharClass->addRange(0x370, 0x37d); -
2115 yyCharClass->addRange(0x37f, 0x1fff); -
2116 yyCharClass->addRange(0x200c, 0x200d); -
2117 yyCharClass->addRange(0x2070, 0x218f); -
2118 yyCharClass->addRange(0x2c00, 0x2fef); -
2119 yyCharClass->addRange(0x3001, 0xd7ff); -
2120 yyCharClass->addRange(0xf900, 0xfdcf); -
2121 yyCharClass->addRange(0xfdf0, 0xfffd); -
2122 yyCharClass->addRange((ushort)0x10000, (ushort)0xeffff); -
2123 return Tok_CharClass;
never executed: return Tok_CharClass;
0
2124 } else { -
2125 break;
executed: break;
Execution Count:2
2
2126 } -
2127 case 'C': -
2128 if (xmlSchemaExtensions) {
partially evaluated: xmlSchemaExtensions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2129 yyCharClass->setNegative(!yyCharClass->negative()); -
2130 -
2131 } else {
never executed: }
0
2132 break;
executed: break;
Execution Count:2
2
2133 } -
2134 case 'c': -
2135 if (xmlSchemaExtensions) {
partially evaluated: xmlSchemaExtensions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2136 yyCharClass->addCategories((1 << (QChar::Mark_NonSpacing)) | -
2137 (1 << (QChar::Mark_SpacingCombining)) | -
2138 (1 << (QChar::Mark_Enclosing)) | -
2139 (1 << (QChar::Number_DecimalDigit)) | -
2140 (1 << (QChar::Number_Letter)) | -
2141 (1 << (QChar::Number_Other)) | -
2142 (1 << (QChar::Letter_Uppercase)) | -
2143 (1 << (QChar::Letter_Lowercase)) | -
2144 (1 << (QChar::Letter_Titlecase)) | -
2145 (1 << (QChar::Letter_Modifier)) | -
2146 (1 << (QChar::Letter_Other))); -
2147 yyCharClass->addSingleton(0x002d); -
2148 yyCharClass->addSingleton(0x002e); -
2149 yyCharClass->addSingleton(0x003a); -
2150 yyCharClass->addSingleton(0x005f); -
2151 yyCharClass->addSingleton(0xb7); -
2152 yyCharClass->addRange(0x0030, 0x0039); -
2153 yyCharClass->addRange(0x0041, 0x005a); -
2154 yyCharClass->addRange(0x0061, 0x007a); -
2155 yyCharClass->addRange(0xc0, 0xd6); -
2156 yyCharClass->addRange(0xd8, 0xf6); -
2157 yyCharClass->addRange(0xf8, 0x2ff); -
2158 yyCharClass->addRange(0x370, 0x37d); -
2159 yyCharClass->addRange(0x37f, 0x1fff); -
2160 yyCharClass->addRange(0x200c, 0x200d); -
2161 yyCharClass->addRange(0x2070, 0x218f); -
2162 yyCharClass->addRange(0x2c00, 0x2fef); -
2163 yyCharClass->addRange(0x3001, 0xd7ff); -
2164 yyCharClass->addRange(0xf900, 0xfdcf); -
2165 yyCharClass->addRange(0xfdf0, 0xfffd); -
2166 yyCharClass->addRange((ushort)0x10000, (ushort)0xeffff); -
2167 yyCharClass->addRange(0x0300, 0x036f); -
2168 yyCharClass->addRange(0x203f, 0x2040); -
2169 return Tok_CharClass;
never executed: return Tok_CharClass;
0
2170 } else { -
2171 break;
executed: break;
Execution Count:2
2
2172 } -
2173 case 'P': -
2174 if (xmlSchemaExtensions) {
partially evaluated: xmlSchemaExtensions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2175 yyCharClass->setNegative(!yyCharClass->negative()); -
2176 -
2177 } else {
never executed: }
0
2178 break;
executed: break;
Execution Count:2
2
2179 } -
2180 case 'p': -
2181 if (xmlSchemaExtensions) {
partially evaluated: xmlSchemaExtensions
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2182 if (yyCh != '{') {
never evaluated: yyCh != '{'
0
2183 error("bad char class syntax"); -
2184 return Tok_CharClass;
never executed: return Tok_CharClass;
0
2185 } -
2186 -
2187 QByteArray category; -
2188 yyCh = getChar(); -
2189 while (yyCh != '}') {
never evaluated: yyCh != '}'
0
2190 if (yyCh == EOS) {
never evaluated: yyCh == EOS
0
2191 error("unexpected end"); -
2192 return Tok_CharClass;
never executed: return Tok_CharClass;
0
2193 } -
2194 category.append(yyCh); -
2195 yyCh = getChar(); -
2196 }
never executed: }
0
2197 yyCh = getChar(); -
2198 -
2199 int catlen = category.length(); -
2200 if (catlen == 1 || catlen == 2) {
never evaluated: catlen == 1
never evaluated: catlen == 2
0
2201 switch (category.at(0)) { -
2202 case 'M': -
2203 if (catlen == 1) {
never evaluated: catlen == 1
0
2204 yyCharClass->addCategories((1 << (QChar::Mark_NonSpacing)) | -
2205 (1 << (QChar::Mark_SpacingCombining)) | -
2206 (1 << (QChar::Mark_Enclosing))); -
2207 } else {
never executed: }
0
2208 switch (category.at(1)) { -
2209 case 'n': yyCharClass->addCategories((1 << (QChar::Mark_NonSpacing))); break;
never executed: break;
0
2210 case 'c': yyCharClass->addCategories((1 << (QChar::Mark_SpacingCombining))); break;
never executed: break;
0
2211 case 'e': yyCharClass->addCategories((1 << (QChar::Mark_Enclosing))); break;
never executed: break;
0
2212 default: error("invalid category"); break;
never executed: break;
0
2213 } -
2214 }
never executed: }
0
2215 break;
never executed: break;
0
2216 case 'N': -
2217 if (catlen == 1) {
never evaluated: catlen == 1
0
2218 yyCharClass->addCategories((1 << (QChar::Number_DecimalDigit)) | -
2219 (1 << (QChar::Number_Letter)) | -
2220 (1 << (QChar::Number_Other))); -
2221 } else {
never executed: }
0
2222 switch (category.at(1)) { -
2223 case 'd': yyCharClass->addCategories((1 << (QChar::Number_DecimalDigit))); break;
never executed: break;
0
2224 case 'l': yyCharClass->addCategories((1 << (QChar::Number_Letter))); break;
never executed: break;
0
2225 case 'o': yyCharClass->addCategories((1 << (QChar::Number_Other))); break;
never executed: break;
0
2226 default: error("invalid category"); break;
never executed: break;
0
2227 } -
2228 }
never executed: }
0
2229 break;
never executed: break;
0
2230 case 'Z': -
2231 if (catlen == 1) {
never evaluated: catlen == 1
0
2232 yyCharClass->addCategories((1 << (QChar::Separator_Space)) | -
2233 (1 << (QChar::Separator_Line)) | -
2234 (1 << (QChar::Separator_Paragraph))); -
2235 } else {
never executed: }
0
2236 switch (category.at(1)) { -
2237 case 's': yyCharClass->addCategories((1 << (QChar::Separator_Space))); break;
never executed: break;
0
2238 case 'l': yyCharClass->addCategories((1 << (QChar::Separator_Line))); break;
never executed: break;
0
2239 case 'p': yyCharClass->addCategories((1 << (QChar::Separator_Paragraph))); break;
never executed: break;
0
2240 default: error("invalid category"); break;
never executed: break;
0
2241 } -
2242 }
never executed: }
0
2243 break;
never executed: break;
0
2244 case 'C': -
2245 if (catlen == 1) {
never evaluated: catlen == 1
0
2246 yyCharClass->addCategories((1 << (QChar::Other_Control)) | -
2247 (1 << (QChar::Other_Format)) | -
2248 (1 << (QChar::Other_Surrogate)) | -
2249 (1 << (QChar::Other_PrivateUse)) | -
2250 (1 << (QChar::Other_NotAssigned))); -
2251 } else {
never executed: }
0
2252 switch (category.at(1)) { -
2253 case 'c': yyCharClass->addCategories((1 << (QChar::Other_Control))); break;
never executed: break;
0
2254 case 'f': yyCharClass->addCategories((1 << (QChar::Other_Format))); break;
never executed: break;
0
2255 case 's': yyCharClass->addCategories((1 << (QChar::Other_Surrogate))); break;
never executed: break;
0
2256 case 'o': yyCharClass->addCategories((1 << (QChar::Other_PrivateUse))); break;
never executed: break;
0
2257 case 'n': yyCharClass->addCategories((1 << (QChar::Other_NotAssigned))); break;
never executed: break;
0
2258 default: error("invalid category"); break;
never executed: break;
0
2259 } -
2260 }
never executed: }
0
2261 break;
never executed: break;
0
2262 case 'L': -
2263 if (catlen == 1) {
never evaluated: catlen == 1
0
2264 yyCharClass->addCategories((1 << (QChar::Letter_Uppercase)) | -
2265 (1 << (QChar::Letter_Lowercase)) | -
2266 (1 << (QChar::Letter_Titlecase)) | -
2267 (1 << (QChar::Letter_Modifier)) | -
2268 (1 << (QChar::Letter_Other))); -
2269 } else {
never executed: }
0
2270 switch (category.at(1)) { -
2271 case 'u': yyCharClass->addCategories((1 << (QChar::Letter_Uppercase))); break;
never executed: break;
0
2272 case 'l': yyCharClass->addCategories((1 << (QChar::Letter_Lowercase))); break;
never executed: break;
0
2273 case 't': yyCharClass->addCategories((1 << (QChar::Letter_Titlecase))); break;
never executed: break;
0
2274 case 'm': yyCharClass->addCategories((1 << (QChar::Letter_Modifier))); break;
never executed: break;
0
2275 case 'o': yyCharClass->addCategories((1 << (QChar::Letter_Other))); break;
never executed: break;
0
2276 default: error("invalid category"); break;
never executed: break;
0
2277 } -
2278 }
never executed: }
0
2279 break;
never executed: break;
0
2280 case 'P': -
2281 if (catlen == 1) {
never evaluated: catlen == 1
0
2282 yyCharClass->addCategories((1 << (QChar::Punctuation_Connector)) | -
2283 (1 << (QChar::Punctuation_Dash)) | -
2284 (1 << (QChar::Punctuation_Open)) | -
2285 (1 << (QChar::Punctuation_Close)) | -
2286 (1 << (QChar::Punctuation_InitialQuote)) | -
2287 (1 << (QChar::Punctuation_FinalQuote)) | -
2288 (1 << (QChar::Punctuation_Other))); -
2289 } else {
never executed: }
0
2290 switch (category.at(1)) { -
2291 case 'c': yyCharClass->addCategories((1 << (QChar::Punctuation_Connector))); break;
never executed: break;
0
2292 case 'd': yyCharClass->addCategories((1 << (QChar::Punctuation_Dash))); break;
never executed: break;
0
2293 case 's': yyCharClass->addCategories((1 << (QChar::Punctuation_Open))); break;
never executed: break;
0
2294 case 'e': yyCharClass->addCategories((1 << (QChar::Punctuation_Close))); break;
never executed: break;
0
2295 case 'i': yyCharClass->addCategories((1 << (QChar::Punctuation_InitialQuote))); break;
never executed: break;
0
2296 case 'f': yyCharClass->addCategories((1 << (QChar::Punctuation_FinalQuote))); break;
never executed: break;
0
2297 case 'o': yyCharClass->addCategories((1 << (QChar::Punctuation_Other))); break;
never executed: break;
0
2298 default: error("invalid category"); break;
never executed: break;
0
2299 } -
2300 }
never executed: }
0
2301 break;
never executed: break;
0
2302 case 'S': -
2303 if (catlen == 1) {
never evaluated: catlen == 1
0
2304 yyCharClass->addCategories((1 << (QChar::Symbol_Math)) | -
2305 (1 << (QChar::Symbol_Currency)) | -
2306 (1 << (QChar::Symbol_Modifier)) | -
2307 (1 << (QChar::Symbol_Other))); -
2308 } else {
never executed: }
0
2309 switch (category.at(1)) { -
2310 case 'm': yyCharClass->addCategories((1 << (QChar::Symbol_Math))); break;
never executed: break;
0
2311 case 'c': yyCharClass->addCategories((1 << (QChar::Symbol_Currency))); break;
never executed: break;
0
2312 case 'k': yyCharClass->addCategories((1 << (QChar::Symbol_Modifier))); break;
never executed: break;
0
2313 case 'o': yyCharClass->addCategories((1 << (QChar::Symbol_Other))); break;
never executed: break;
0
2314 default: error("invalid category"); break;
never executed: break;
0
2315 } -
2316 }
never executed: }
0
2317 break;
never executed: break;
0
2318 default: -
2319 error("invalid category"); -
2320 break;
never executed: break;
0
2321 } -
2322 } else if (catlen > 2 && category.at(0) == 'I' && category.at(1) == 's') {
never executed: }
never evaluated: catlen > 2
never evaluated: category.at(0) == 'I'
never evaluated: category.at(1) == 's'
0
2323 static const int N = sizeof(categoriesRangeMap) / sizeof(categoriesRangeMap[0]); -
2324 const CategoriesRangeMapEntry *r = qBinaryFind(categoriesRangeMap, categoriesRangeMap + N, category.constData() + 2); -
2325 if (r != categoriesRangeMap + N)
never evaluated: r != categoriesRangeMap + N
0
2326 yyCharClass->addRange(r->first, r->second);
never executed: yyCharClass->addRange(r->first, r->second);
0
2327 else -
2328 error("invalid category");
never executed: error("invalid category");
0
2329 } else { -
2330 error("invalid category"); -
2331 }
never executed: }
0
2332 return Tok_CharClass;
never executed: return Tok_CharClass;
0
2333 } else { -
2334 break;
executed: break;
Execution Count:2
2
2335 } -
2336 -
2337 -
2338 case 'x': -
2339 val = 0; -
2340 for (i = 0; i < 4; i++) {
partially evaluated: i < 4
TRUEFALSE
yes
Evaluation Count:6720
no
Evaluation Count:0
0-6720
2341 low = QChar(yyCh).toLower().unicode(); -
2342 if (low >= '0' && low <= '9')
evaluated: low >= '0'
TRUEFALSE
yes
Evaluation Count:5600
yes
Evaluation Count:1120
evaluated: low <= '9'
TRUEFALSE
yes
Evaluation Count:2240
yes
Evaluation Count:3360
1120-5600
2343 val = (val << 4) | (low - '0');
executed: val = (val << 4) | (low - '0');
Execution Count:2240
2240
2344 else if (low >= 'a' && low <= 'f')
evaluated: low >= 'a'
TRUEFALSE
yes
Evaluation Count:2240
yes
Evaluation Count:2240
partially evaluated: low <= 'f'
TRUEFALSE
yes
Evaluation Count:2240
no
Evaluation Count:0
0-2240
2345 val = (val << 4) | (low - 'a' + 10);
executed: val = (val << 4) | (low - 'a' + 10);
Execution Count:2240
2240
2346 else -
2347 break;
executed: break;
Execution Count:2240
2240
2348 yyCh = getChar(); -
2349 }
executed: }
Execution Count:4480
4480
2350 return Tok_Char | val;
executed: return Tok_Char | val;
Execution Count:2240
2240
2351 -
2352 default: -
2353 break;
executed: break;
Execution Count:2705
2705
2354 } -
2355 if (prevCh >= '1' && prevCh <= '9') {
evaluated: prevCh >= '1'
TRUEFALSE
yes
Evaluation Count:1959
yes
Evaluation Count:758
evaluated: prevCh <= '9'
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:1769
190-1959
2356 -
2357 val = prevCh - '0'; -
2358 while (yyCh >= '0' && yyCh <= '9') {
evaluated: yyCh >= '0'
TRUEFALSE
yes
Evaluation Count:145
yes
Evaluation Count:65
evaluated: yyCh <= '9'
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:125
20-145
2359 val = (val * 10) + (yyCh - '0'); -
2360 yyCh = getChar(); -
2361 }
executed: }
Execution Count:20
20
2362 return Tok_BackRef | val;
executed: return Tok_BackRef | val;
Execution Count:190
190
2363 -
2364 -
2365 -
2366 } -
2367 return Tok_Char | prevCh;
executed: return Tok_Char | prevCh;
Execution Count:2527
2527
2368} -
2369 -
2370 -
2371int QRegExpEngine::getRep(int def) -
2372{ -
2373 if (yyCh >= '0' && yyCh <= '9') {
evaluated: yyCh >= '0'
TRUEFALSE
yes
Evaluation Count:1178
yes
Evaluation Count:4
evaluated: yyCh <= '9'
TRUEFALSE
yes
Evaluation Count:817
yes
Evaluation Count:361
4-1178
2374 int rep = 0; -
2375 do { -
2376 rep = 10 * rep + yyCh - '0'; -
2377 if (rep >= InftyRep) {
partially evaluated: rep >= InftyRep
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1137
0-1137
2378 error("bad repetition syntax"); -
2379 rep = def; -
2380 }
never executed: }
0
2381 yyCh = getChar(); -
2382 } while (yyCh >= '0' && yyCh <= '9');
executed: }
Execution Count:1137
evaluated: yyCh >= '0'
TRUEFALSE
yes
Evaluation Count:564
yes
Evaluation Count:573
evaluated: yyCh <= '9'
TRUEFALSE
yes
Evaluation Count:320
yes
Evaluation Count:244
244-1137
2383 return rep;
executed: return rep;
Execution Count:817
817
2384 } else { -
2385 return def;
executed: return def;
Execution Count:365
365
2386 } -
2387} -
2388 -
2389 -
2390 -
2391void QRegExpEngine::skipChars(int n) -
2392{ -
2393 if (n > 0) {
evaluated: n > 0
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:48
48-78
2394 yyPos += n - 1; -
2395 yyCh = getChar(); -
2396 }
executed: }
Execution Count:78
78
2397}
executed: }
Execution Count:126
126
2398 -
2399 -
2400void QRegExpEngine::error(const char *msg) -
2401{ -
2402 if (yyError.isEmpty())
evaluated: yyError.isEmpty()
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:84
52-84
2403 yyError = QLatin1String(msg);
executed: yyError = QLatin1String(msg);
Execution Count:52
52
2404}
executed: }
Execution Count:136
136
2405 -
2406void QRegExpEngine::startTokenizer(const QChar *rx, int len) -
2407{ -
2408 yyIn = rx; -
2409 yyPos0 = 0; -
2410 yyPos = 0; -
2411 yyLen = len; -
2412 yyCh = getChar(); -
2413 yyCharClass.reset(new QRegExpCharClass); -
2414 yyMinRep = 0; -
2415 yyMaxRep = 0; -
2416 yyError = QString(); -
2417}
executed: }
Execution Count:1423
1423
2418 -
2419int QRegExpEngine::getToken() -
2420{ -
2421 -
2422 ushort pendingCh = 0; -
2423 bool charPending; -
2424 bool rangePending; -
2425 int tok; -
2426 -
2427 int prevCh = yyCh; -
2428 -
2429 yyPos0 = yyPos - 1; -
2430 -
2431 yyCharClass->clear(); -
2432 -
2433 yyMinRep = 0; -
2434 yyMaxRep = 0; -
2435 yyCh = getChar(); -
2436 -
2437 switch (prevCh) { -
2438 case EOS: -
2439 yyPos0 = yyPos; -
2440 return Tok_Eos;
executed: return Tok_Eos;
Execution Count:1298
1298
2441 case '$': -
2442 return Tok_Dollar;
executed: return Tok_Dollar;
Execution Count:98
98
2443 case '(': -
2444 if (yyCh == '?') {
evaluated: yyCh == '?'
TRUEFALSE
yes
Evaluation Count:973
yes
Evaluation Count:603
603-973
2445 prevCh = getChar(); -
2446 yyCh = getChar(); -
2447 switch (prevCh) { -
2448 -
2449 case '!': -
2450 return Tok_NegLookahead;
executed: return Tok_NegLookahead;
Execution Count:90
90
2451 case '=': -
2452 return Tok_PosLookahead;
executed: return Tok_PosLookahead;
Execution Count:36
36
2453 -
2454 case ':': -
2455 return Tok_MagicLeftParen;
executed: return Tok_MagicLeftParen;
Execution Count:847
847
2456 case '<': -
2457 error("lookbehinds not supported, see QTBUG-2371"); -
2458 return Tok_MagicLeftParen;
never executed: return Tok_MagicLeftParen;
0
2459 default: -
2460 error("bad lookahead syntax"); -
2461 return Tok_MagicLeftParen;
never executed: return Tok_MagicLeftParen;
0
2462 } -
2463 } else {
never executed: }
0
2464 return Tok_LeftParen;
executed: return Tok_LeftParen;
Execution Count:603
603
2465 } -
2466 case ')': -
2467 return Tok_RightParen;
executed: return Tok_RightParen;
Execution Count:1813
1813
2468 case '*': -
2469 yyMinRep = 0; -
2470 yyMaxRep = InftyRep; -
2471 return Tok_Quantifier;
executed: return Tok_Quantifier;
Execution Count:1783
1783
2472 case '+': -
2473 yyMinRep = 1; -
2474 yyMaxRep = InftyRep; -
2475 return Tok_Quantifier;
executed: return Tok_Quantifier;
Execution Count:211
211
2476 case '.': -
2477 -
2478 yyCharClass->setNegative(true); -
2479 -
2480 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:230
230
2481 case '?': -
2482 yyMinRep = 0; -
2483 yyMaxRep = 1; -
2484 return Tok_Quantifier;
executed: return Tok_Quantifier;
Execution Count:142
142
2485 case '[': -
2486 -
2487 if (yyCh == '^') {
evaluated: yyCh == '^'
TRUEFALSE
yes
Evaluation Count:1133
yes
Evaluation Count:619
619-1133
2488 yyCharClass->setNegative(true); -
2489 yyCh = getChar(); -
2490 }
executed: }
Execution Count:1133
1133
2491 charPending = false; -
2492 rangePending = false; -
2493 do { -
2494 if (yyCh == '-' && charPending && !rangePending) {
evaluated: yyCh == '-'
TRUEFALSE
yes
Evaluation Count:1588
yes
Evaluation Count:9127
evaluated: charPending
TRUEFALSE
yes
Evaluation Count:1587
yes
Evaluation Count:1
partially evaluated: !rangePending
TRUEFALSE
yes
Evaluation Count:1587
no
Evaluation Count:0
0-9127
2495 rangePending = true; -
2496 yyCh = getChar(); -
2497 } else {
executed: }
Execution Count:1587
1587
2498 if (charPending && !rangePending) {
evaluated: charPending
TRUEFALSE
yes
Evaluation Count:6467
yes
Evaluation Count:2661
evaluated: !rangePending
TRUEFALSE
yes
Evaluation Count:4886
yes
Evaluation Count:1581
1581-6467
2499 yyCharClass->addSingleton(pendingCh); -
2500 charPending = false; -
2501 }
executed: }
Execution Count:4886
4886
2502 if (yyCh == '\\') {
evaluated: yyCh == '\\'
TRUEFALSE
yes
Evaluation Count:5648
yes
Evaluation Count:3480
3480-5648
2503 yyCh = getChar(); -
2504 tok = getEscape(); -
2505 if (tok == Tok_Word)
partially evaluated: tok == Tok_Word
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5648
0-5648
2506 tok = '\b';
never executed: tok = '\b';
0
2507 } else {
executed: }
Execution Count:5648
5648
2508 tok = Tok_Char | yyCh; -
2509 yyCh = getChar(); -
2510 }
executed: }
Execution Count:3480
3480
2511 if (tok == Tok_CharClass) {
evaluated: tok == Tok_CharClass
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9127
1-9127
2512 if (rangePending) {
partially evaluated: rangePending
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2513 yyCharClass->addSingleton('-'); -
2514 yyCharClass->addSingleton(pendingCh); -
2515 charPending = false; -
2516 rangePending = false; -
2517 }
never executed: }
0
2518 } else if ((tok & Tok_Char) != 0) {
executed: }
Execution Count:1
partially evaluated: (tok & Tok_Char) != 0
TRUEFALSE
yes
Evaluation Count:9127
no
Evaluation Count:0
0-9127
2519 if (rangePending) {
evaluated: rangePending
TRUEFALSE
yes
Evaluation Count:1581
yes
Evaluation Count:7546
1581-7546
2520 yyCharClass->addRange(pendingCh, tok ^ Tok_Char); -
2521 charPending = false; -
2522 rangePending = false; -
2523 } else {
executed: }
Execution Count:1581
1581
2524 pendingCh = tok ^ Tok_Char; -
2525 charPending = true; -
2526 }
executed: }
Execution Count:7546
7546
2527 } else { -
2528 error("bad char class syntax"); -
2529 }
never executed: }
0
2530 } -
2531 } while (yyCh != ']' && yyCh != EOS);
evaluated: yyCh != ']'
TRUEFALSE
yes
Evaluation Count:8983
yes
Evaluation Count:1732
evaluated: yyCh != EOS
TRUEFALSE
yes
Evaluation Count:8963
yes
Evaluation Count:20
20-8983
2532 if (rangePending)
evaluated: rangePending
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1746
6-1746
2533 yyCharClass->addSingleton('-');
executed: yyCharClass->addSingleton('-');
Execution Count:6
6
2534 if (charPending)
evaluated: charPending
TRUEFALSE
yes
Evaluation Count:1079
yes
Evaluation Count:673
673-1079
2535 yyCharClass->addSingleton(pendingCh);
executed: yyCharClass->addSingleton(pendingCh);
Execution Count:1079
1079
2536 if (yyCh == EOS)
evaluated: yyCh == EOS
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:1732
20-1732
2537 error("unexpected end");
executed: error("unexpected end");
Execution Count:20
20
2538 else -
2539 yyCh = getChar();
executed: yyCh = getChar();
Execution Count:1732
1732
2540 return Tok_CharClass;
executed: return Tok_CharClass;
Execution Count:1752
1752
2541 -
2542 -
2543 -
2544 -
2545 case '\\': -
2546 return getEscape();
executed: return getEscape();
Execution Count:1718
1718
2547 case ']': -
2548 error("missing left delim"); -
2549 return Tok_Char | ']';
executed: return Tok_Char | ']';
Execution Count:22
22
2550 case '^': -
2551 return Tok_Caret;
executed: return Tok_Caret;
Execution Count:117
117
2552 case '{': -
2553 -
2554 yyMinRep = getRep(0); -
2555 yyMaxRep = yyMinRep; -
2556 if (yyCh == ',') {
evaluated: yyCh == ','
TRUEFALSE
yes
Evaluation Count:577
yes
Evaluation Count:28
28-577
2557 yyCh = getChar(); -
2558 yyMaxRep = getRep(InftyRep); -
2559 }
executed: }
Execution Count:577
577
2560 if (yyMaxRep < yyMinRep)
evaluated: yyMaxRep < yyMinRep
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:604
1-604
2561 error("invalid interval");
executed: error("invalid interval");
Execution Count:1
1
2562 if (yyCh != '}')
evaluated: yyCh != '}'
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:592
13-592
2563 error("bad repetition syntax");
executed: error("bad repetition syntax");
Execution Count:13
13
2564 yyCh = getChar(); -
2565 return Tok_Quantifier;
executed: return Tok_Quantifier;
Execution Count:605
605
2566 -
2567 -
2568 -
2569 -
2570 case '|': -
2571 return Tok_Bar;
executed: return Tok_Bar;
Execution Count:461
461
2572 case '}': -
2573 error("missing left delim"); -
2574 return Tok_Char | '}';
executed: return Tok_Char | '}';
Execution Count:13
13
2575 default: -
2576 return Tok_Char | prevCh;
executed: return Tok_Char | prevCh;
Execution Count:20735
20735
2577 } -
2578}
never executed: }
0
2579 -
2580int QRegExpEngine::parse(const QChar *pattern, int len) -
2581{ -
2582 valid = true; -
2583 startTokenizer(pattern, len); -
2584 yyTok = getToken(); -
2585 -
2586 yyMayCapture = true; -
2587 -
2588 -
2589 -
2590 -
2591 -
2592 int atom = startAtom(false); -
2593 -
2594 QRegExpCharClass anything; -
2595 Box box(this); -
2596 box.set(anything); -
2597 Box rightBox(this); -
2598 rightBox.set(anything); -
2599 -
2600 Box middleBox(this); -
2601 parseExpression(&middleBox); -
2602 -
2603 finishAtom(atom, false); -
2604 -
2605 -
2606 middleBox.setupHeuristics(); -
2607 -
2608 box.cat(middleBox); -
2609 box.cat(rightBox); -
2610 yyCharClass.reset(0); -
2611 -
2612 -
2613 for (int i = 0; i < nf; ++i) {
evaluated: i < nf
TRUEFALSE
yes
Evaluation Count:30153
yes
Evaluation Count:1423
1423-30153
2614 switch (f[i].capture) { -
2615 case QRegExpAtom::NoCapture: -
2616 break;
executed: break;
Execution Count:28458
28458
2617 case QRegExpAtom::OfficialCapture: -
2618 f[i].capture = ncap; -
2619 captureForOfficialCapture.append(ncap); -
2620 ++ncap; -
2621 ++officialncap; -
2622 break;
executed: break;
Execution Count:559
559
2623 case QRegExpAtom::UnofficialCapture: -
2624 f[i].capture = greedyQuantifiers ? ncap++ : QRegExpAtom::NoCapture;
partially evaluated: greedyQuantifiers
TRUEFALSE
yes
Evaluation Count:1136
no
Evaluation Count:0
0-1136
2625 }
executed: }
Execution Count:1136
1136
2626 }
executed: }
Execution Count:30153
30153
2627 -
2628 -
2629 -
2630 if (officialncap == 0 && nbrefs == 0) {
evaluated: officialncap == 0
TRUEFALSE
yes
Evaluation Count:1202
yes
Evaluation Count:221
evaluated: nbrefs == 0
TRUEFALSE
yes
Evaluation Count:1199
yes
Evaluation Count:3
3-1202
2631 ncap = nf = 0; -
2632 f.clear(); -
2633 }
executed: }
Execution Count:1199
1199
2634 -
2635 -
2636 -
2637 for (int i = 0; i < nbrefs - officialncap; ++i) {
evaluated: i < nbrefs - officialncap
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1423
11-1423
2638 captureForOfficialCapture.append(ncap); -
2639 ++ncap; -
2640 }
executed: }
Execution Count:11
11
2641 -
2642 -
2643 -
2644 if (!yyError.isEmpty())
evaluated: !yyError.isEmpty()
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:1371
52-1371
2645 return -1;
executed: return -1;
Execution Count:52
52
2646 -
2647 -
2648 const QRegExpAutomatonState &sinit = s.at(InitialState); -
2649 caretAnchored = !sinit.anchors.isEmpty(); -
2650 if (caretAnchored) {
partially evaluated: caretAnchored
TRUEFALSE
yes
Evaluation Count:1371
no
Evaluation Count:0
0-1371
2651 const QMap<int, int> &anchors = sinit.anchors; -
2652 QMap<int, int>::const_iterator a; -
2653 for (a = anchors.constBegin(); a != anchors.constEnd(); ++a) {
evaluated: a != anchors.constEnd()
TRUEFALSE
yes
Evaluation Count:1554
yes
Evaluation Count:87
87-1554
2654 if ( -
2655 -
2656 (*a & Anchor_Alternation) != 0 ||
evaluated: (*a & Anchor_Alternation) != 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1548
6-1548
2657 -
2658 (*a & Anchor_Caret) == 0)
evaluated: (*a & Anchor_Caret) == 0
TRUEFALSE
yes
Evaluation Count:1278
yes
Evaluation Count:270
270-1278
2659 { -
2660 caretAnchored = false; -
2661 break;
executed: break;
Execution Count:1284
1284
2662 } -
2663 }
executed: }
Execution Count:270
270
2664 }
executed: }
Execution Count:1371
1371
2665 -
2666 -
2667 -
2668 int numStates = s.count(); -
2669 for (int i = 0; i < numStates; ++i) {
evaluated: i < numStates
TRUEFALSE
yes
Evaluation Count:26338
yes
Evaluation Count:1371
1371-26338
2670 QRegExpAutomatonState &state = s[i]; -
2671 if (!state.anchors.isEmpty()) {
evaluated: !state.anchors.isEmpty()
TRUEFALSE
yes
Evaluation Count:24959
yes
Evaluation Count:1379
1379-24959
2672 QMap<int, int>::iterator a = state.anchors.begin(); -
2673 while (a != state.anchors.end()) {
evaluated: a != state.anchors.end()
TRUEFALSE
yes
Evaluation Count:33469
yes
Evaluation Count:24959
24959-33469
2674 if (a.value() == 0)
evaluated: a.value() == 0
TRUEFALSE
yes
Evaluation Count:31660
yes
Evaluation Count:1809
1809-31660
2675 a = state.anchors.erase(a);
executed: a = state.anchors.erase(a);
Execution Count:31660
31660
2676 else -
2677 ++a;
executed: ++a;
Execution Count:1809
1809
2678 } -
2679 }
executed: }
Execution Count:24959
24959
2680 }
executed: }
Execution Count:26338
26338
2681 -
2682 return yyPos0;
executed: return yyPos0;
Execution Count:1371
1371
2683} -
2684 -
2685void QRegExpEngine::parseAtom(Box *box) -
2686{ -
2687 -
2688 QRegExpEngine *eng = 0; -
2689 bool neg; -
2690 int len; -
2691 -
2692 -
2693 if ((yyTok & Tok_Char) != 0) {
evaluated: (yyTok & Tok_Char) != 0
TRUEFALSE
yes
Evaluation Count:22163
yes
Evaluation Count:4595
4595-22163
2694 box->set(QChar(yyTok ^ Tok_Char)); -
2695 } else {
executed: }
Execution Count:22163
22163
2696 -
2697 trivial = false; -
2698 -
2699 switch (yyTok) { -
2700 case Tok_Dollar: -
2701 box->catAnchor(Anchor_Dollar); -
2702 break;
executed: break;
Execution Count:98
98
2703 case Tok_Caret: -
2704 box->catAnchor(Anchor_Caret); -
2705 break;
executed: break;
Execution Count:117
117
2706 -
2707 case Tok_PosLookahead: -
2708 case Tok_NegLookahead: -
2709 neg = (yyTok == Tok_NegLookahead); -
2710 eng = new QRegExpEngine(cs, greedyQuantifiers); -
2711 len = eng->parse(yyIn + yyPos - 1, yyLen - yyPos + 1); -
2712 if (len >= 0)
partially evaluated: len >= 0
TRUEFALSE
yes
Evaluation Count:126
no
Evaluation Count:0
0-126
2713 skipChars(len);
executed: skipChars(len);
Execution Count:126
126
2714 else -
2715 error("bad lookahead syntax");
never executed: error("bad lookahead syntax");
0
2716 box->catAnchor(addLookahead(eng, neg)); -
2717 yyTok = getToken(); -
2718 if (yyTok != Tok_RightParen)
partially evaluated: yyTok != Tok_RightParen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:126
0-126
2719 error("bad lookahead syntax");
never executed: error("bad lookahead syntax");
0
2720 break;
executed: break;
Execution Count:126
126
2721 -
2722 -
2723 case Tok_Word: -
2724 box->catAnchor(Anchor_Word); -
2725 break;
executed: break;
Execution Count:1
1
2726 case Tok_NonWord: -
2727 box->catAnchor(Anchor_NonWord); -
2728 break;
never executed: break;
0
2729 -
2730 case Tok_LeftParen: -
2731 case Tok_MagicLeftParen: -
2732 yyTok = getToken(); -
2733 parseExpression(box); -
2734 if (yyTok != Tok_RightParen)
evaluated: yyTok != Tok_RightParen
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1561
1-1561
2735 error("unexpected end");
executed: error("unexpected end");
Execution Count:1
1
2736 break;
executed: break;
Execution Count:1562
1562
2737 case Tok_CharClass: -
2738 box->set(*yyCharClass); -
2739 break;
executed: break;
Execution Count:2491
2491
2740 case Tok_Quantifier: -
2741 error("bad repetition syntax"); -
2742 break;
executed: break;
Execution Count:10
10
2743 default: -
2744 -
2745 if ((yyTok & Tok_BackRef) != 0)
partially evaluated: (yyTok & Tok_BackRef) != 0
TRUEFALSE
yes
Evaluation Count:190
no
Evaluation Count:0
0-190
2746 box->set(yyTok ^ Tok_BackRef);
executed: box->set(yyTok ^ Tok_BackRef);
Execution Count:190
190
2747 else -
2748 -
2749 error("disabled feature used");
never executed: error("disabled feature used");
0
2750 } -
2751 }
executed: }
Execution Count:4595
4595
2752 yyTok = getToken(); -
2753}
executed: }
Execution Count:26758
26758
2754 -
2755void QRegExpEngine::parseFactor(Box *box) -
2756{ -
2757 -
2758 int outerAtom = greedyQuantifiers ? startAtom(false) : -1;
evaluated: greedyQuantifiers
TRUEFALSE
yes
Evaluation Count:2459
yes
Evaluation Count:23811
2459-23811
2759 int innerAtom = startAtom(yyMayCapture && yyTok == Tok_LeftParen); -
2760 bool magicLeftParen = (yyTok == Tok_MagicLeftParen); -
2761 const QChar *in = yyIn; -
2762 int pos0 = yyPos0; -
2763 int pos = yyPos; -
2764 int len = yyLen; -
2765 int ch = yyCh; -
2766 QRegExpCharClass charClass; -
2767 if (yyTok == Tok_CharClass)
evaluated: yyTok == Tok_CharClass
TRUEFALSE
yes
Evaluation Count:2150
yes
Evaluation Count:24121
2150-24121
2768 charClass = *yyCharClass;
executed: charClass = *yyCharClass;
Execution Count:2150
2150
2769 int tok = yyTok; -
2770 bool mayCapture = yyMayCapture; -
2771 -
2772 -
2773 parseAtom(box); -
2774 -
2775 finishAtom(innerAtom, magicLeftParen); -
2776 -
2777 -
2778 bool hasQuantifier = (yyTok == Tok_Quantifier); -
2779 if (hasQuantifier) {
evaluated: hasQuantifier
TRUEFALSE
yes
Evaluation Count:2244
yes
Evaluation Count:24027
2244-24027
2780 -
2781 trivial = false; -
2782 -
2783 if (yyMaxRep == InftyRep) {
evaluated: yyMaxRep == InftyRep
TRUEFALSE
yes
Evaluation Count:2011
yes
Evaluation Count:233
233-2011
2784 box->plus(innerAtom); -
2785 -
2786 } else if (yyMaxRep == 0) {
executed: }
Execution Count:2011
evaluated: yyMaxRep == 0
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:211
22-2011
2787 box->clear(); -
2788 -
2789 }
executed: }
Execution Count:22
22
2790 if (yyMinRep == 0)
evaluated: yyMinRep == 0
TRUEFALSE
yes
Evaluation Count:1961
yes
Evaluation Count:283
283-1961
2791 box->opt();
executed: box->opt();
Execution Count:1961
1961
2792 -
2793 -
2794 yyMayCapture = false; -
2795 int alpha = (yyMinRep == 0) ? 0 : yyMinRep - 1;
evaluated: (yyMinRep == 0)
TRUEFALSE
yes
Evaluation Count:1961
yes
Evaluation Count:283
283-1961
2796 int beta = (yyMaxRep == InftyRep) ? 0 : yyMaxRep - (alpha + 1);
evaluated: (yyMaxRep == InftyRep)
TRUEFALSE
yes
Evaluation Count:2011
yes
Evaluation Count:233
233-2011
2797 -
2798 Box rightBox(this); -
2799 int i; -
2800 -
2801 for (i = 0; i < beta; i++) {
evaluated: i < beta
TRUEFALSE
yes
Evaluation Count:88
yes
Evaluation Count:2244
88-2244
2802 yyIn = in, yyPos0 = pos0, yyPos = pos, yyLen = len, yyCh = ch, *yyCharClass = charClass, yyMinRep = 0, yyMaxRep = 0, yyTok = tok; -
2803 Box leftBox(this); -
2804 parseAtom(&leftBox); -
2805 leftBox.cat(rightBox); -
2806 leftBox.opt(); -
2807 rightBox = leftBox; -
2808 }
executed: }
Execution Count:88
88
2809 for (i = 0; i < alpha; i++) {
evaluated: i < alpha
TRUEFALSE
yes
Evaluation Count:399
yes
Evaluation Count:2244
399-2244
2810 yyIn = in, yyPos0 = pos0, yyPos = pos, yyLen = len, yyCh = ch, *yyCharClass = charClass, yyMinRep = 0, yyMaxRep = 0, yyTok = tok; -
2811 Box leftBox(this); -
2812 parseAtom(&leftBox); -
2813 leftBox.cat(rightBox); -
2814 rightBox = leftBox; -
2815 }
executed: }
Execution Count:399
399
2816 rightBox.cat(*box); -
2817 *box = rightBox; -
2818 -
2819 yyTok = getToken(); -
2820 -
2821 yyMayCapture = mayCapture; -
2822 -
2823 }
executed: }
Execution Count:2243
2243
2824 -
2825 -
2826 if (greedyQuantifiers)
evaluated: greedyQuantifiers
TRUEFALSE
yes
Evaluation Count:2459
yes
Evaluation Count:23811
2459-23811
2827 finishAtom(outerAtom, hasQuantifier);
executed: finishAtom(outerAtom, hasQuantifier);
Execution Count:2459
2459
2828 -
2829}
executed: }
Execution Count:26270
26270
2830 -
2831void QRegExpEngine::parseTerm(Box *box) -
2832{ -
2833 -
2834 if (yyTok != Tok_Eos && yyTok != Tok_RightParen && yyTok != Tok_Bar)
evaluated: yyTok != Tok_Eos
TRUEFALSE
yes
Evaluation Count:3300
yes
Evaluation Count:146
evaluated: yyTok != Tok_RightParen
TRUEFALSE
yes
Evaluation Count:3216
yes
Evaluation Count:84
evaluated: yyTok != Tok_Bar
TRUEFALSE
yes
Evaluation Count:3200
yes
Evaluation Count:16
16-3300
2835 parseFactor(box);
executed: parseFactor(box);
Execution Count:3200
3200
2836 -
2837 while (yyTok != Tok_Eos && yyTok != Tok_RightParen && yyTok != Tok_Bar) {
evaluated: yyTok != Tok_Eos
TRUEFALSE
yes
Evaluation Count:25219
yes
Evaluation Count:1298
evaluated: yyTok != Tok_RightParen
TRUEFALSE
yes
Evaluation Count:23532
yes
Evaluation Count:1687
evaluated: yyTok != Tok_Bar
TRUEFALSE
yes
Evaluation Count:23071
yes
Evaluation Count:461
461-25219
2838 Box rightBox(this); -
2839 parseFactor(&rightBox); -
2840 box->cat(rightBox); -
2841 }
executed: }
Execution Count:23070
23070
2842}
executed: }
Execution Count:3446
3446
2843 -
2844void QRegExpEngine::parseExpression(Box *box) -
2845{ -
2846 parseTerm(box); -
2847 while (yyTok == Tok_Bar) {
evaluated: yyTok == Tok_Bar
TRUEFALSE
yes
Evaluation Count:461
yes
Evaluation Count:2985
461-2985
2848 -
2849 trivial = false; -
2850 -
2851 Box rightBox(this); -
2852 yyTok = getToken(); -
2853 parseTerm(&rightBox); -
2854 box->orx(rightBox); -
2855 }
executed: }
Execution Count:461
461
2856}
executed: }
Execution Count:2985
2985
2857 -
2858 -
2859 -
2860 -
2861 -
2862 -
2863 -
2864struct QRegExpPrivate -
2865{ -
2866 QRegExpEngine *eng; -
2867 QRegExpEngineKey engineKey; -
2868 bool minimal; -
2869 -
2870 QString t; -
2871 QStringList capturedCache; -
2872 -
2873 QRegExpMatchState matchState; -
2874 -
2875 inline QRegExpPrivate() -
2876 : eng(0), engineKey(QString(), QRegExp::RegExp, Qt::CaseSensitive), minimal(false) { }
executed: }
Execution Count:384356
384356
2877 inline QRegExpPrivate(const QRegExpEngineKey &key) -
2878 : eng(0), engineKey(key), minimal(false) {}
executed: }
Execution Count:141738
141738
2879}; -
2880 -
2881 -
2882uint qHash(const QRegExpEngineKey &key, uint seed = 0) -
2883{ -
2884 return qHash(key.pattern, seed);
executed: return qHash(key.pattern, seed);
Execution Count:569834
569834
2885} -
2886 -
2887typedef QCache<QRegExpEngineKey, QRegExpEngine> EngineCache; -
2888static EngineCache *globalEngineCache() { static QGlobalStatic<EngineCache > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { EngineCache *x = new EngineCache; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<EngineCache > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:570236
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:570187
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:49
no
Evaluation Count:0
0-570236
2889static QBasicMutex globalEngineCacheMutex; -
2890 -
2891 -
2892static void derefEngine(QRegExpEngine *eng, const QRegExpEngineKey &key) -
2893{ -
2894 if (!eng->ref.deref()) {
evaluated: !eng->ref.deref()
TRUEFALSE
yes
Evaluation Count:142558
yes
Evaluation Count:384178
142558-384178
2895 -
2896 if (globalEngineCache()) {
partially evaluated: globalEngineCache()
TRUEFALSE
yes
Evaluation Count:142558
no
Evaluation Count:0
0-142558
2897 QMutexLocker locker(&globalEngineCacheMutex); -
2898 try { -
2899 globalEngineCache()->insert(key, eng, 4 + key.pattern.length() / 4); -
2900 } catch (const std::bad_alloc &) {
executed: }
Execution Count:142558
142558
2901 -
2902 delete eng; -
2903 }
never executed: }
0
2904 } else {
executed: }
Execution Count:142558
142558
2905 delete eng; -
2906 }
never executed: }
0
2907 -
2908 -
2909 -
2910 -
2911 } -
2912}
executed: }
Execution Count:526736
526736
2913 -
2914static void prepareEngine_helper(QRegExpPrivate *priv) -
2915{ -
2916 bool initMatchState = !priv->eng; -
2917 -
2918 if (!priv->eng && globalEngineCache()) {
partially evaluated: !priv->eng
TRUEFALSE
yes
Evaluation Count:142560
no
Evaluation Count:0
partially evaluated: globalEngineCache()
TRUEFALSE
yes
Evaluation Count:142560
no
Evaluation Count:0
0-142560
2919 QMutexLocker locker(&globalEngineCacheMutex); -
2920 priv->eng = globalEngineCache()->take(priv->engineKey); -
2921 if (priv->eng != 0)
evaluated: priv->eng != 0
TRUEFALSE
yes
Evaluation Count:141263
yes
Evaluation Count:1297
1297-141263
2922 priv->eng->ref.ref();
executed: priv->eng->ref.ref();
Execution Count:141263
141263
2923 }
executed: }
Execution Count:142560
142560
2924 -
2925 -
2926 if (!priv->eng)
evaluated: !priv->eng
TRUEFALSE
yes
Evaluation Count:1297
yes
Evaluation Count:141263
1297-141263
2927 priv->eng = new QRegExpEngine(priv->engineKey);
executed: priv->eng = new QRegExpEngine(priv->engineKey);
Execution Count:1297
1297
2928 -
2929 if (initMatchState)
partially evaluated: initMatchState
TRUEFALSE
yes
Evaluation Count:142560
no
Evaluation Count:0
0-142560
2930 priv->matchState.prepareForMatch(priv->eng);
executed: priv->matchState.prepareForMatch(priv->eng);
Execution Count:142560
142560
2931}
executed: }
Execution Count:142560
142560
2932 -
2933inline static void prepareEngine(QRegExpPrivate *priv) -
2934{ -
2935 if (priv->eng)
evaluated: priv->eng
TRUEFALSE
yes
Evaluation Count:1355199
yes
Evaluation Count:142560
142560-1355199
2936 return;
executed: return;
Execution Count:1355411
1355411
2937 prepareEngine_helper(priv); -
2938}
executed: }
Execution Count:142560
142560
2939 -
2940static void prepareEngineForMatch(QRegExpPrivate *priv, const QString &str) -
2941{ -
2942 prepareEngine(priv); -
2943 priv->matchState.prepareForMatch(priv->eng); -
2944 -
2945 priv->t = str; -
2946 priv->capturedCache.clear(); -
2947 -
2948 -
2949 -
2950}
executed: }
Execution Count:884048
884048
2951 -
2952static void invalidateEngine(QRegExpPrivate *priv) -
2953{ -
2954 if (priv->eng != 0) {
evaluated: priv->eng != 0
TRUEFALSE
yes
Evaluation Count:526736
yes
Evaluation Count:383851
383851-526736
2955 derefEngine(priv->eng, priv->engineKey); -
2956 priv->eng = 0; -
2957 priv->matchState.drain(); -
2958 }
executed: }
Execution Count:526736
526736
2959}
executed: }
Execution Count:910587
910587
2960QRegExp::QRegExp() -
2961{ -
2962 priv = new QRegExpPrivate; -
2963 prepareEngine(priv); -
2964}
executed: }
Execution Count:564
564
2965QRegExp::QRegExp(const QString &pattern, Qt::CaseSensitivity cs, PatternSyntax syntax) -
2966{ -
2967 priv = new QRegExpPrivate(QRegExpEngineKey(pattern, syntax, cs)); -
2968 prepareEngine(priv); -
2969}
executed: }
Execution Count:141738
141738
2970 -
2971 -
2972 -
2973 -
2974 -
2975 -
2976QRegExp::QRegExp(const QRegExp &rx) -
2977{ -
2978 priv = new QRegExpPrivate; -
2979 operator=(rx); -
2980}
executed: }
Execution Count:383792
383792
2981 -
2982 -
2983 -
2984 -
2985QRegExp::~QRegExp() -
2986{ -
2987 invalidateEngine(priv); -
2988 delete priv; -
2989}
executed: }
Execution Count:526092
526092
2990 -
2991 -
2992 -
2993 -
2994 -
2995 -
2996QRegExp &QRegExp::operator=(const QRegExp &rx) -
2997{ -
2998 prepareEngine(rx.priv); -
2999 QRegExpEngine *otherEng = rx.priv->eng; -
3000 if (otherEng)
partially evaluated: otherEng
TRUEFALSE
yes
Evaluation Count:384178
no
Evaluation Count:0
0-384178
3001 otherEng->ref.ref();
executed: otherEng->ref.ref();
Execution Count:384178
384178
3002 invalidateEngine(priv); -
3003 priv->eng = otherEng; -
3004 priv->engineKey = rx.priv->engineKey; -
3005 priv->minimal = rx.priv->minimal; -
3006 -
3007 priv->t = rx.priv->t; -
3008 priv->capturedCache = rx.priv->capturedCache; -
3009 -
3010 if (priv->eng)
partially evaluated: priv->eng
TRUEFALSE
yes
Evaluation Count:384178
no
Evaluation Count:0
0-384178
3011 priv->matchState.prepareForMatch(priv->eng);
executed: priv->matchState.prepareForMatch(priv->eng);
Execution Count:384178
384178
3012 priv->matchState.captured = rx.priv->matchState.captured; -
3013 return *this;
executed: return *this;
Execution Count:384178
384178
3014} -
3015bool QRegExp::operator==(const QRegExp &rx) const -
3016{ -
3017 return priv->engineKey == rx.priv->engineKey && priv->minimal == rx.priv->minimal;
executed: return priv->engineKey == rx.priv->engineKey && priv->minimal == rx.priv->minimal;
Execution Count:2237
2237
3018} -
3019bool QRegExp::isEmpty() const -
3020{ -
3021 return priv->engineKey.pattern.isEmpty();
executed: return priv->engineKey.pattern.isEmpty();
Execution Count:69719
69719
3022} -
3023bool QRegExp::isValid() const -
3024{ -
3025 if (priv->engineKey.pattern.isEmpty()) {
evaluated: priv->engineKey.pattern.isEmpty()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:1755
32-1755
3026 return true;
executed: return true;
Execution Count:32
32
3027 } else { -
3028 prepareEngine(priv); -
3029 return priv->eng->isValid();
executed: return priv->eng->isValid();
Execution Count:1755
1755
3030 } -
3031} -
3032QString QRegExp::pattern() const -
3033{ -
3034 return priv->engineKey.pattern;
executed: return priv->engineKey.pattern;
Execution Count:429
429
3035} -
3036 -
3037 -
3038 -
3039 -
3040 -
3041 -
3042 -
3043void QRegExp::setPattern(const QString &pattern) -
3044{ -
3045 if (priv->engineKey.pattern != pattern) {
evaluated: priv->engineKey.pattern != pattern
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:11
11-62
3046 invalidateEngine(priv); -
3047 priv->engineKey.pattern = pattern; -
3048 }
executed: }
Execution Count:62
62
3049}
executed: }
Execution Count:73
73
3050 -
3051 -
3052 -
3053 -
3054 -
3055 -
3056 -
3057Qt::CaseSensitivity QRegExp::caseSensitivity() const -
3058{ -
3059 return priv->engineKey.cs;
executed: return priv->engineKey.cs;
Execution Count:173
173
3060} -
3061void QRegExp::setCaseSensitivity(Qt::CaseSensitivity cs) -
3062{ -
3063 if ((bool)cs != (bool)priv->engineKey.cs) {
evaluated: (bool)cs != (bool)priv->engineKey.cs
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:55
42-55
3064 invalidateEngine(priv); -
3065 priv->engineKey.cs = cs; -
3066 }
executed: }
Execution Count:42
42
3067}
executed: }
Execution Count:97
97
3068 -
3069 -
3070 -
3071 -
3072 -
3073 -
3074 -
3075QRegExp::PatternSyntax QRegExp::patternSyntax() const -
3076{ -
3077 return priv->engineKey.patternSyntax;
executed: return priv->engineKey.patternSyntax;
Execution Count:177
177
3078} -
3079void QRegExp::setPatternSyntax(PatternSyntax syntax) -
3080{ -
3081 if (syntax != priv->engineKey.patternSyntax) {
evaluated: syntax != priv->engineKey.patternSyntax
TRUEFALSE
yes
Evaluation Count:213
yes
Evaluation Count:42
42-213
3082 invalidateEngine(priv); -
3083 priv->engineKey.patternSyntax = syntax; -
3084 }
executed: }
Execution Count:213
213
3085}
executed: }
Execution Count:255
255
3086 -
3087 -
3088 -
3089 -
3090 -
3091 -
3092 -
3093bool QRegExp::isMinimal() const -
3094{ -
3095 return priv->minimal;
executed: return priv->minimal;
Execution Count:173
173
3096} -
3097void QRegExp::setMinimal(bool minimal) -
3098{ -
3099 priv->minimal = minimal; -
3100}
executed: }
Execution Count:239
239
3101bool QRegExp::exactMatch(const QString &str) const -
3102{ -
3103 prepareEngineForMatch(priv, str); -
3104 priv->matchState.match(str.unicode(), str.length(), 0, priv->minimal, true, 0); -
3105 if (priv->matchState.captured[1] == str.length()) {
evaluated: priv->matchState.captured[1] == str.length()
TRUEFALSE
yes
Evaluation Count:219679
yes
Evaluation Count:300702
219679-300702
3106 return true;
executed: return true;
Execution Count:219679
219679
3107 } else { -
3108 priv->matchState.captured[0] = 0; -
3109 priv->matchState.captured[1] = priv->matchState.oneTestMatchedLen; -
3110 return false;
executed: return false;
Execution Count:300702
300702
3111 } -
3112} -
3113int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const -
3114{ -
3115 prepareEngineForMatch(priv, str); -
3116 if (offset < 0)
partially evaluated: offset < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:362625
0-362625
3117 offset += str.length();
never executed: offset += str.length();
0
3118 priv->matchState.match(str.unicode(), str.length(), offset, -
3119 priv->minimal, false, caretIndex(offset, caretMode)); -
3120 return priv->matchState.captured[0];
executed: return priv->matchState.captured[0];
Execution Count:361711
361711
3121} -
3122int QRegExp::lastIndexIn(const QString &str, int offset, CaretMode caretMode) const -
3123{ -
3124 prepareEngineForMatch(priv, str); -
3125 if (offset < 0)
evaluated: offset < 0
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:929
24-929
3126 offset += str.length();
executed: offset += str.length();
Execution Count:24
24
3127 if (offset < 0 || offset > str.length()) {
evaluated: offset < 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:945
partially evaluated: offset > str.length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:945
0-945
3128 memset(priv->matchState.captured, -1, priv->matchState.capturedSize*sizeof(int)); -
3129 return -1;
executed: return -1;
Execution Count:8
8
3130 } -
3131 -
3132 while (offset >= 0) {
evaluated: offset >= 0
TRUEFALSE
yes
Evaluation Count:31890
yes
Evaluation Count:604
604-31890
3133 priv->matchState.match(str.unicode(), str.length(), offset, -
3134 priv->minimal, true, caretIndex(offset, caretMode)); -
3135 if (priv->matchState.captured[0] == offset)
evaluated: priv->matchState.captured[0] == offset
TRUEFALSE
yes
Evaluation Count:341
yes
Evaluation Count:31549
341-31549
3136 return offset;
executed: return offset;
Execution Count:341
341
3137 --offset; -
3138 }
executed: }
Execution Count:31549
31549
3139 return -1;
executed: return -1;
Execution Count:604
604
3140} -
3141 -
3142 -
3143 -
3144 -
3145 -
3146 -
3147 -
3148int QRegExp::matchedLength() const -
3149{ -
3150 return priv->matchState.captured[1];
executed: return priv->matchState.captured[1];
Execution Count:7062
7062
3151} -
3152 -
3153 -
3154 -
3155 -
3156 -
3157 -
3158 -
3159int QRegExp::captureCount() const -
3160{ -
3161 prepareEngine(priv); -
3162 return priv->eng->captureCount();
executed: return priv->eng->captureCount();
Execution Count:83501
83501
3163} -
3164QStringList QRegExp::capturedTexts() const -
3165{ -
3166 if (priv->capturedCache.isEmpty()) {
evaluated: priv->capturedCache.isEmpty()
TRUEFALSE
yes
Evaluation Count:2557
yes
Evaluation Count:302
302-2557
3167 prepareEngine(priv); -
3168 const int *captured = priv->matchState.captured; -
3169 int n = priv->matchState.capturedSize; -
3170 -
3171 for (int i = 0; i < n; i += 2) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:9034
yes
Evaluation Count:2557
2557-9034
3172 QString m; -
3173 if (captured[i + 1] == 0)
evaluated: captured[i + 1] == 0
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:8874
160-8874
3174 m = QLatin1String("");
executed: m = QLatin1String("");
Execution Count:160
160
3175 else if (captured[i] >= 0)
evaluated: captured[i] >= 0
TRUEFALSE
yes
Evaluation Count:3784
yes
Evaluation Count:5090
3784-5090
3176 m = priv->t.mid(captured[i], captured[i + 1]);
executed: m = priv->t.mid(captured[i], captured[i + 1]);
Execution Count:3784
3784
3177 priv->capturedCache.append(m); -
3178 }
executed: }
Execution Count:9034
9034
3179 priv->t.clear(); -
3180 }
executed: }
Execution Count:2557
2557
3181 return priv->capturedCache;
executed: return priv->capturedCache;
Execution Count:2859
2859
3182} -
3183 -
3184 -
3185 -
3186 -
3187QStringList QRegExp::capturedTexts() -
3188{ -
3189 return const_cast<const QRegExp *>(this)->capturedTexts();
executed: return const_cast<const QRegExp *>(this)->capturedTexts();
Execution Count:2049
2049
3190} -
3191QString QRegExp::cap(int nth) const -
3192{ -
3193 return capturedTexts().value(nth);
executed: return capturedTexts().value(nth);
Execution Count:810
810
3194} -
3195 -
3196 -
3197 -
3198 -
3199QString QRegExp::cap(int nth) -
3200{ -
3201 return const_cast<const QRegExp *>(this)->cap(nth);
executed: return const_cast<const QRegExp *>(this)->cap(nth);
Execution Count:810
810
3202} -
3203int QRegExp::pos(int nth) const -
3204{ -
3205 if (nth < 0 || nth >= priv->matchState.capturedSize / 2)
partially evaluated: nth < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
partially evaluated: nth >= priv->matchState.capturedSize / 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52
0-52
3206 return -1;
never executed: return -1;
0
3207 else -
3208 return priv->matchState.captured[2 * nth];
executed: return priv->matchState.captured[2 * nth];
Execution Count:52
52
3209} -
3210 -
3211 -
3212 -
3213 -
3214int QRegExp::pos(int nth) -
3215{ -
3216 return const_cast<const QRegExp *>(this)->pos(nth);
executed: return const_cast<const QRegExp *>(this)->pos(nth);
Execution Count:52
52
3217} -
3218 -
3219 -
3220 -
3221 -
3222 -
3223 -
3224 -
3225QString QRegExp::errorString() const -
3226{ -
3227 if (isValid()) {
never evaluated: isValid()
0
3228 return QString::fromLatin1("no error occurred");
never executed: return QString::fromLatin1("no error occurred");
0
3229 } else { -
3230 return priv->eng->errorString();
never executed: return priv->eng->errorString();
0
3231 } -
3232} -
3233 -
3234 -
3235 -
3236 -
3237QString QRegExp::errorString() -
3238{ -
3239 return const_cast<const QRegExp *>(this)->errorString();
never executed: return const_cast<const QRegExp *>(this)->errorString();
0
3240} -
3241QString QRegExp::escape(const QString &str) -
3242{ -
3243 QString quoted; -
3244 const int count = str.count(); -
3245 quoted.reserve(count * 2); -
3246 const QLatin1Char backslash('\\'); -
3247 for (int i = 0; i < count; i++) {
evaluated: i < count
TRUEFALSE
yes
Evaluation Count:17285
yes
Evaluation Count:746
746-17285
3248 switch (str.at(i).toLatin1()) { -
3249 case '$': -
3250 case '(': -
3251 case ')': -
3252 case '*': -
3253 case '+': -
3254 case '.': -
3255 case '?': -
3256 case '[': -
3257 case '\\': -
3258 case ']': -
3259 case '^': -
3260 case '{': -
3261 case '|': -
3262 case '}': -
3263 quoted.append(backslash); -
3264 }
executed: }
Execution Count:55
55
3265 quoted.append(str.at(i)); -
3266 }
executed: }
Execution Count:17285
17285
3267 return quoted;
executed: return quoted;
Execution Count:746
746
3268} -
3269QDataStream &operator<<(QDataStream &out, const QRegExp &regExp) -
3270{ -
3271 return out << regExp.pattern() << (quint8)regExp.caseSensitivity() 173
3272 << (quint8)regExp.patternSyntax() 173
3273 << (quint8)!!regExp.isMinimal();
executed: return out << regExp.pattern() << (quint8)regExp.caseSensitivity() << (quint8)regExp.patternSyntax() << (quint8)!!regExp.isMinimal();
Execution Count:173
173
3274} -
3275QDataStream &operator>>(QDataStream &in, QRegExp &regExp) -
3276{ -
3277 QString pattern; -
3278 quint8 cs; -
3279 quint8 patternSyntax; -
3280 quint8 isMinimal; -
3281 -
3282 in >> pattern >> cs >> patternSyntax >> isMinimal; -
3283 -
3284 QRegExp newRegExp(pattern, Qt::CaseSensitivity(cs), -
3285 QRegExp::PatternSyntax(patternSyntax)); -
3286 -
3287 newRegExp.setMinimal(isMinimal); -
3288 regExp = newRegExp; -
3289 return in;
executed: return in;
Execution Count:177
177
3290} -
3291 -
3292 -
3293 -
3294QDebug operator<<(QDebug dbg, const QRegExp &r) -
3295{ -
3296 dbg.nospace() << "QRegExp(patternSyntax=" << r.patternSyntax() -
3297 << ", pattern='"<< r.pattern() << "')"; -
3298 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
3299} -
3300 -
3301 -
3302 -
3303 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial