@@ -693,21 +693,35 @@ class FormatLiteral extends Literal {
693693 )
694694 }
695695
696+ /**
697+ * Gets the char type required by the nth conversion specifier.
698+ * - in the base case this is the default for the formatting function
699+ * (e.g. `char` for `printf`, `wchar_t` for `wprintf`).
700+ * - the `%S` format character reverses wideness.
701+ * - the size prefixes 'l'/'w' and 'h' override the type character
702+ * to wide or single-byte characters respectively.
703+ */
696704 private Type getConversionType1b ( int n ) {
697- exists ( string cnv | cnv = this .getEffectiveCharConversionChar ( n ) |
705+ exists ( string len , string conv |
706+ this .parseConvSpec ( n , _, _, _, _, _, len , conv ) and
698707 (
699- cnv = "c" and
700- result instanceof CharType and
701- not result .( CharType ) .isExplicitlySigned ( ) and
702- not result .( CharType ) .isExplicitlyUnsigned ( )
703- ) or (
704- cnv = "C" and
705- isMicrosoft ( ) and
706- result instanceof WideCharType
707- ) or (
708- cnv = "C" and
709- not isMicrosoft ( ) and
710- result .hasName ( "wint_t" )
708+ (
709+ ( conv = "c" or conv = "C" ) and
710+ len = "h" and
711+ result instanceof PlainCharType
712+ ) or (
713+ ( conv = "c" or conv = "C" ) and
714+ ( len = "l" or len = "w" ) and
715+ result = getWideCharType ( )
716+ ) or (
717+ conv = "c" and
718+ ( len != "l" and len != "w" and len != "h" ) and
719+ result = getDefaultCharType ( )
720+ ) or (
721+ conv = "C" and
722+ ( len != "l" and len != "w" and len != "h" ) and
723+ result = getNonDefaultCharType ( )
724+ )
711725 )
712726 )
713727 }
0 commit comments