| ... | @@ -512,17 +512,19 @@ pub fn bufPrintInt(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usiz | ... | @@ -512,17 +512,19 @@ pub fn bufPrintInt(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usiz |
| 512 | | 512 | |
| 513 | fn bufPrintSigned(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usize) -> usize { | 513 | fn bufPrintSigned(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usize) -> usize { |
| 514 | const uint = @intType(false, @typeOf(x).bit_count); | 514 | const uint = @intType(false, @typeOf(x).bit_count); |
| 515 | // include the sign in the width | | |
| 516 | const new_width = if (width == 0) 0 else (width - 1); | | |
| 517 | var new_value: uint = undefined; | | |
| 518 | if (x < 0) { | 515 | if (x < 0) { |
| 519 | out_buf[0] = '-'; | 516 | out_buf[0] = '-'; |
| 520 | new_value = uint(-(x + 1)) + 1; | 517 | const new_value = uint(-(x + 1)) + 1; |
| | 518 | const new_width = if (width == 0) 0 else (width - 1); |
| | 519 | return 1 + bufPrintUnsigned(out_buf[1...], new_value, base, uppercase, new_width); |
| | 520 | } else if (width == 0) { |
| | 521 | return bufPrintUnsigned(out_buf, uint(x), base, uppercase, width); |
| 521 | } else { | 522 | } else { |
| 522 | out_buf[0] = '+'; | 523 | out_buf[0] = '+'; |
| 523 | new_value = uint(x); | 524 | const new_value = uint(x); |
| | 525 | const new_width = if (width == 0) 0 else (width - 1); |
| | 526 | return 1 + bufPrintUnsigned(out_buf[1...], new_value, base, uppercase, new_width); |
| 524 | } | 527 | } |
| 525 | return 1 + bufPrintUnsigned(out_buf[1...], new_value, base, uppercase, new_width); | | |
| 526 | } | 528 | } |
| 527 | | 529 | |
| 528 | fn bufPrintUnsigned(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usize) -> usize { | 530 | fn bufPrintUnsigned(out_buf: []u8, x: var, base: u8, uppercase: bool, width: usize) -> usize { |