mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Incorrect justify formatting of integers.
This commit is contained in:
@@ -628,15 +628,15 @@ fn usz! Formatter.out_reverse(&self, char[] buf) @private
|
|||||||
usz buffer_start_idx = self.idx;
|
usz buffer_start_idx = self.idx;
|
||||||
usz len = buf.len;
|
usz len = buf.len;
|
||||||
// pad spaces up to given width
|
// pad spaces up to given width
|
||||||
if (!self.flags.zeropad)
|
if (!self.flags.zeropad && !self.flags.left)
|
||||||
{
|
{
|
||||||
n += self.adjust(len)!;
|
n += self.pad(' ', self.width, len)!;
|
||||||
}
|
}
|
||||||
// reverse string
|
// reverse string
|
||||||
while (len) n += self.out(buf[--len])!;
|
while (len) n += self.out(buf[--len])!;
|
||||||
|
|
||||||
// append pad spaces up to given width
|
// append pad spaces up to given width
|
||||||
n += self.adjust(self.idx - buffer_start_idx)!;
|
n += self.adjust(n)!;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
- Fix incorrect linker selection on some platforms.
|
- Fix incorrect linker selection on some platforms.
|
||||||
- Struct members declared in a single line declaration were not sharing attributes. #1266
|
- Struct members declared in a single line declaration were not sharing attributes. #1266
|
||||||
- `opt` project setting now properly documented.
|
- `opt` project setting now properly documented.
|
||||||
|
- Incorrect justify formatting of integers.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
module std::io @test;
|
module std::io @test;
|
||||||
|
|
||||||
|
fn void printf_int()
|
||||||
|
{
|
||||||
|
String s;
|
||||||
|
s = string::new_format("[%-10d]", 78);
|
||||||
|
assert(s == "[78 ]");
|
||||||
|
s = string::new_format("[%10d]", 78);
|
||||||
|
assert(s == "[ 78]");
|
||||||
|
s = string::new_format("[%010d]", 78);
|
||||||
|
assert(s == "[0000000078]");
|
||||||
|
s = string::new_format("[%+10d]", 78);
|
||||||
|
assert(s == "[ +78]");
|
||||||
|
s = string::new_format("[%-+10d]", 78);
|
||||||
|
assert(s == "[+78 ]");
|
||||||
|
}
|
||||||
|
|
||||||
fn void printf_a()
|
fn void printf_a()
|
||||||
{
|
{
|
||||||
String s;
|
String s;
|
||||||
|
|||||||
Reference in New Issue
Block a user