@@ -186,13 +186,7 @@ private predicate isCanonicalTerm(RelevantRegExpTerm term, string str) {
186
186
*/
187
187
string getCanonicalizationFlags ( RegExpTerm root ) {
188
188
root .isRootTerm ( ) and
189
- (
190
- RegExpFlags:: isIgnoreCase ( root ) and
191
- result = "i"
192
- or
193
- not RegExpFlags:: isIgnoreCase ( root ) and
194
- result = ""
195
- )
189
+ ( if RegExpFlags:: isIgnoreCase ( root ) then result = "i" else result = "" )
196
190
}
197
191
198
192
/**
@@ -207,7 +201,7 @@ private newtype TInputSymbol =
207
201
not RegExpFlags:: isIgnoreCase ( cc .getRootTerm ( ) )
208
202
) .getValue ( ) .charAt ( _)
209
203
or
210
- // normalize to lower case if the regexp is case insensitive
204
+ // normalize everything to lower case if the regexp is case insensitive
211
205
c =
212
206
any ( RegexpCharacterConstant cc , string char |
213
207
cc instanceof RelevantRegExpTerm and
@@ -325,16 +319,16 @@ private module CharacterClasses {
325
319
if RegExpFlags:: isIgnoreCase ( cc .getRootTerm ( ) )
326
320
then
327
321
// normalize everything to lower case if the regexp is case insensitive
328
- exists ( string c | hasChildThatMatchesIgnoringCasing ( cc , c ) | char = c .toLowerCase ( ) )
329
- else hasChildThatMatchesIgnoringCasing ( cc , char )
322
+ exists ( string c | hasChildThatMatchesIgnoringCasingFlags ( cc , c ) | char = c .toLowerCase ( ) )
323
+ else hasChildThatMatchesIgnoringCasingFlags ( cc , char )
330
324
}
331
325
332
326
/**
333
327
* Holds if the character class `cc` has a child (constant or range) that matches `char`.
334
- * Ignores whether the character class is inside a regular expression that ignores casing .
328
+ * Ignores whether the character class is inside a regular expression that has the ignore case flag .
335
329
*/
336
330
pragma [ noinline]
337
- predicate hasChildThatMatchesIgnoringCasing ( RegExpCharacterClass cc , string char ) {
331
+ predicate hasChildThatMatchesIgnoringCasingFlags ( RegExpCharacterClass cc , string char ) {
338
332
exists ( getCanonicalCharClass ( cc ) ) and
339
333
exists ( RegExpTerm child | child = cc .getAChild ( ) |
340
334
char = child .( RegexpCharacterConstant ) .getValue ( )
@@ -583,7 +577,7 @@ predicate delta(State q1, EdgeLabel lbl, State q2) {
583
577
not RegExpFlags:: isIgnoreCase ( s .getRootTerm ( ) ) and
584
578
lbl = Char ( s .getValue ( ) .charAt ( i ) )
585
579
or
586
- // normalizing to lower case if ignorecase flag is set
580
+ // normalize everything to lower case if the regexp is case insensitive
587
581
RegExpFlags:: isIgnoreCase ( s .getRootTerm ( ) ) and
588
582
exists ( string c | c = s .getValue ( ) .charAt ( i ) | lbl = Char ( c .toLowerCase ( ) ) )
589
583
) and
0 commit comments