@@ -74,8 +74,8 @@ impl Length {
7474 unsafe fn parse_signed ( self , args : & mut VaList ) -> SignedInt {
7575 match self {
7676 Length :: Int => SignedInt :: Int ( args. arg ( ) ) ,
77- Length :: Char => SignedInt :: Char ( args. arg :: < i32 > ( ) as i8 ) ,
78- Length :: Short => SignedInt :: Short ( args. arg :: < i32 > ( ) as i16 ) ,
77+ Length :: Char => SignedInt :: Char ( args. arg :: < c_int > ( ) as c_schar ) ,
78+ Length :: Short => SignedInt :: Short ( args. arg :: < c_int > ( ) as c_short ) ,
7979 Length :: Long => SignedInt :: Long ( args. arg ( ) ) ,
8080 Length :: LongLong => SignedInt :: LongLong ( args. arg ( ) ) ,
8181 // for some reason, these exist as different options, yet produce the same output
@@ -85,8 +85,8 @@ impl Length {
8585 unsafe fn parse_unsigned ( self , args : & mut VaList ) -> UnsignedInt {
8686 match self {
8787 Length :: Int => UnsignedInt :: Int ( args. arg ( ) ) ,
88- Length :: Char => UnsignedInt :: Char ( args. arg :: < u32 > ( ) as u8 ) ,
89- Length :: Short => UnsignedInt :: Short ( args. arg :: < u32 > ( ) as u16 ) ,
88+ Length :: Char => UnsignedInt :: Char ( args. arg :: < c_uint > ( ) as c_uchar ) ,
89+ Length :: Short => UnsignedInt :: Short ( args. arg :: < c_uint > ( ) as c_ushort ) ,
9090 Length :: Long => UnsignedInt :: Long ( args. arg ( ) ) ,
9191 Length :: LongLong => UnsignedInt :: LongLong ( args. arg ( ) ) ,
9292 // for some reason, these exist as different options, yet produce the same output
@@ -197,7 +197,21 @@ pub unsafe fn format(
197197 Specifier :: String ( CStr :: from_ptr( arg) )
198198 }
199199 }
200- b'c' => Specifier :: Char ( args. arg:: <u32 >( ) as u8 ) ,
200+ b'c' => {
201+ trait CharToInt {
202+ type IntType ;
203+ }
204+
205+ impl CharToInt for c_schar {
206+ type IntType = c_int;
207+ }
208+
209+ impl CharToInt for c_uchar {
210+ type IntType = c_uint;
211+ }
212+
213+ Specifier :: Char ( args. arg:: <<c_char as CharToInt >:: IntType >( ) as c_char)
214+ }
201215 b'p' => Specifier :: Pointer ( args. arg( ) ) ,
202216 b'n' => Specifier :: WriteBytesWritten ( written, args. arg( ) ) ,
203217 _ => return -1 ,
0 commit comments