@@ -459,6 +459,13 @@ class FormatLiteral extends Literal instanceof StringLiteral {
459459 */
460460 int getConvSpecOffset ( int n ) { result = this .getFormat ( ) .indexOf ( "%" , n , 0 ) }
461461
462+ /**
463+ * Gets the nth conversion specifier string.
464+ */
465+ private string getConvSpecString ( int n ) {
466+ n >= 0 and result = "%" + this .getFormat ( ) .splitAt ( "%" , n + 1 )
467+ }
468+
462469 /*
463470 * Each of these predicates gets a regular expressions to match each individual
464471 * parts of a conversion specifier.
@@ -524,10 +531,8 @@ class FormatLiteral extends Literal instanceof StringLiteral {
524531 int n , string spec , string params , string flags , string width , string prec , string len ,
525532 string conv
526533 ) {
527- exists ( int offset , string fmt , string rst , string regexp |
528- offset = this .getConvSpecOffset ( n ) and
529- fmt = this .getFormat ( ) and
530- rst = fmt .substring ( offset , fmt .length ( ) ) and
534+ exists ( string rst , string regexp |
535+ rst = this .getConvSpecString ( n ) and
531536 regexp = this .getConvSpecRegexp ( ) and
532537 (
533538 spec = rst .regexpCapture ( regexp , 1 ) and
@@ -554,10 +559,8 @@ class FormatLiteral extends Literal instanceof StringLiteral {
554559 * Gets the nth conversion specifier (including the initial `%`).
555560 */
556561 string getConvSpec ( int n ) {
557- exists ( int offset , string fmt , string rst , string regexp |
558- offset = this .getConvSpecOffset ( n ) and
559- fmt = this .getFormat ( ) and
560- rst = fmt .substring ( offset , fmt .length ( ) ) and
562+ exists ( string rst , string regexp |
563+ rst = this .getConvSpecString ( n ) and
561564 regexp = this .getConvSpecRegexp ( ) and
562565 result = rst .regexpCapture ( regexp , 1 )
563566 )
0 commit comments