@@ -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,22 +531,20 @@ 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 convSpec , string regexp |
535+ convSpec = this .getConvSpecString ( n ) and
531536 regexp = this .getConvSpecRegexp ( ) and
532537 (
533- spec = rst .regexpCapture ( regexp , 1 ) and
534- params = rst .regexpCapture ( regexp , 2 ) and
535- flags = rst .regexpCapture ( regexp , 3 ) and
536- width = rst .regexpCapture ( regexp , 4 ) and
537- prec = rst .regexpCapture ( regexp , 5 ) and
538- len = rst .regexpCapture ( regexp , 6 ) and
539- conv = rst .regexpCapture ( regexp , 7 )
538+ spec = convSpec .regexpCapture ( regexp , 1 ) and
539+ params = convSpec .regexpCapture ( regexp , 2 ) and
540+ flags = convSpec .regexpCapture ( regexp , 3 ) and
541+ width = convSpec .regexpCapture ( regexp , 4 ) and
542+ prec = convSpec .regexpCapture ( regexp , 5 ) and
543+ len = convSpec .regexpCapture ( regexp , 6 ) and
544+ conv = convSpec .regexpCapture ( regexp , 7 )
540545 or
541- spec = rst .regexpCapture ( regexp , 1 ) and
542- not exists ( rst .regexpCapture ( regexp , 2 ) ) and
546+ spec = convSpec .regexpCapture ( regexp , 1 ) and
547+ not exists ( convSpec .regexpCapture ( regexp , 2 ) ) and
543548 params = "" and
544549 flags = "" and
545550 width = "" and
@@ -554,12 +559,10 @@ 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 convSpec , string regexp |
563+ convSpec = this .getConvSpecString ( n ) and
561564 regexp = this .getConvSpecRegexp ( ) and
562- result = rst .regexpCapture ( regexp , 1 )
565+ result = convSpec .regexpCapture ( regexp , 1 )
563566 )
564567 }
565568
0 commit comments