@@ -215,8 +215,9 @@ class FormatLiteral extends Literal {
215215 /**
216216 * Holds if the default meaning of `%s` is a `wchar_t *`, rather than
217217 * a `char *` (either way, `%S` will have the opposite meaning).
218+ * DEPRECATED: Use getDefaultCharType() instead.
218219 */
219- predicate isWideCharDefault ( ) {
220+ deprecated predicate isWideCharDefault ( ) {
220221 getUse ( ) .getTarget ( ) .( FormattingFunction ) .isWideCharDefault ( )
221222 }
222223
@@ -671,37 +672,34 @@ class FormatLiteral extends Literal {
671672 }
672673
673674 /**
674- * Gets the 'effective' char type character, that is, 'c' (meaning a `char`) or
675- * 'C' (meaning a `wchar_t`).
676- * - in the base case this is the same as the format type character .
677- * - for a `wprintf` or similar function call, the meanings are reversed .
678- * - the size prefixes 'l'/'w' (long) and 'h' (short) override the
679- * type character to effectively 'C' or 'c' respectively.
675+ * Gets the char type required by the nth conversion specifier.
676+ * - in the base case this is the default for the formatting function
677+ * (e.g. `char` for `printf`, `wchar_t` for `wprintf`) .
678+ * - the `%S` format character reverses wideness .
679+ * - the size prefixes 'l'/'w' and 'h' override the type character
680+ * to wide or single-byte characters respectively.
680681 */
681- private string getEffectiveCharConversionChar ( int n ) {
682- exists ( string len , string conv | this .parseConvSpec ( n , _, _, _, _, _, len , conv ) and ( conv = "c" or conv = "C" ) |
683- ( len = "l" and result = "C" ) or
684- ( len = "w" and result = "C" ) or
685- ( len = "h" and result = "c" ) or
686- ( len != "l" and len != "w" and len != "h" and ( result = "c" or result = "C" ) and ( if isWideCharDefault ( ) then result != conv else result = conv ) )
687- )
688- }
689-
690682 private Type getConversionType1b ( int n ) {
691- exists ( string cnv | cnv = this .getEffectiveCharConversionChar ( n ) |
683+ exists ( string len , string conv |
684+ this .parseConvSpec ( n , _, _, _, _, _, len , conv ) and
692685 (
693- cnv = "c" and
694- result instanceof CharType and
695- not result .( CharType ) .isExplicitlySigned ( ) and
696- not result .( CharType ) .isExplicitlyUnsigned ( )
697- ) or (
698- cnv = "C" and
699- isMicrosoft ( ) and
700- result instanceof WideCharType
701- ) or (
702- cnv = "C" and
703- not isMicrosoft ( ) and
704- result .hasName ( "wint_t" )
686+ (
687+ ( conv = "c" or conv = "C" ) and
688+ len = "h" and
689+ result instanceof PlainCharType
690+ ) or (
691+ ( conv = "c" or conv = "C" ) and
692+ ( len = "l" or len = "w" ) and
693+ result = getWideCharType ( )
694+ ) or (
695+ conv = "c" and
696+ ( len != "l" and len != "w" and len != "h" ) and
697+ result = getDefaultCharType ( )
698+ ) or (
699+ conv = "C" and
700+ ( len != "l" and len != "w" and len != "h" ) and
701+ result = getNonDefaultCharType ( )
702+ )
705703 )
706704 )
707705 }
@@ -846,15 +844,7 @@ class FormatLiteral extends Literal {
846844 len = 1
847845 or (
848846 this .getConversionChar ( n ) .toLowerCase ( ) = "c" and
849- if ( this .getEffectiveCharConversionChar ( n ) = "C" and
850- not isMicrosoft ( ) and
851- not isWideCharDefault ( ) ) then (
852- len = 6 // MB_LEN_MAX
853- // the wint_t (wide character) argument is converted
854- // to a multibyte sequence by a call to the wcrtomb(3)
855- ) else (
856- len = 1 // e.g. 'a'
857- )
847+ len = 1 // e.g. 'a'
858848 ) or this .getConversionChar ( n ) .toLowerCase ( ) = "f" and
859849 exists ( int dot , int afterdot |
860850 ( if this .getPrecision ( n ) = 0 then dot = 0 else dot = 1 )
0 commit comments