correct printf handling of %x with long ints

Fixes #3352
This commit is contained in:
Kurtis Rader 2017-02-20 17:58:08 -08:00
parent 9f5ce04229
commit 3d0a377e26
4 changed files with 18 additions and 0 deletions

View file

@ -437,6 +437,8 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
// Create a copy of the % directive, with an intmax_t-wide width modifier substituted for any
// existing integer length modifier.
switch (conversion) {
case L'x':
case L'X':
case L'd':
case L'i':
case L'u': {

View file

@ -1 +1,2 @@
2,34: value not completely converted
0xABCDEF12345678901: Result too large

View file

@ -61,3 +61,12 @@ else
echo '3,450000e+00'
echo '4,560000e+00'
end
# Verify long long ints are handled correctly. See issue #3352.
printf 'long hex1 %x\n' 498216206234
printf 'long hex2 %X\n' 498216206234
printf 'long hex3 %X\n' 0xABCDEF1234567890
printf 'long hex4 %X\n' 0xABCDEF12345678901
printf 'long decimal %d\n' 498216206594
printf 'long signed %d\n' -498216206595
printf 'long signed to unsigned %u\n' -498216206596

View file

@ -18,3 +18,9 @@ a
1.230000e+00
3,450000e+00
4,560000e+00
long hex1 73ffffff9a
long hex2 73FFFFFF9A
long hex3 ABCDEF1234567890
long hex4 long decimal 498216206594
long signed -498216206595
long signed to unsigned 18446743575493345020