Implement more printf length specifiers.

This commit is contained in:
Victor Zverovich 2014-08-09 10:04:35 -07:00
parent 6a8becb5bf
commit 316ae7e244
2 changed files with 12 additions and 8 deletions

View File

@ -908,26 +908,30 @@ void fmt::internal::PrintfFormatter<Char>::format(
} }
// Parse length and convert the argument to the required type. // Parse length and convert the argument to the required type.
switch (*s) { switch (*s++) {
case 'h': { case 'h':
++s;
if (*s == 'h') if (*s == 'h')
ArgConverter<signed char>(arg, *++s).visit(arg); ArgConverter<signed char>(arg, *++s).visit(arg);
else else
ArgConverter<short>(arg, *s).visit(arg); ArgConverter<short>(arg, *s).visit(arg);
break; break;
}
case 'l': case 'l':
++s;
ArgConverter<long>(arg, *s).visit(arg); ArgConverter<long>(arg, *s).visit(arg);
break; break;
case 'j': case 'j':
ArgConverter<intmax_t>(arg, *s).visit(arg);
break;
case 'z': case 'z':
ArgConverter<size_t>(arg, *s).visit(arg);
break;
case 't': case 't':
ArgConverter<ptrdiff_t>(arg, *s).visit(arg);
break;
case 'L': case 'L':
// TODO: handle length // TODO: handle length
++s;
break; break;
default:
--s;
} }
// Parse type. // Parse type.

View File

@ -350,8 +350,8 @@ TEST(PrintfTest, Length) {
TestLength<unsigned char>("hh"); TestLength<unsigned char>("hh");
TestLength<short>("h"); TestLength<short>("h");
TestLength<unsigned short>("h"); TestLength<unsigned short>("h");
//TestLength<long>("l"); TestLength<long>("l");
//TestLength<unsigned long>("l"); TestLength<unsigned long>("l");
// TODO: more tests // TODO: more tests
} }