diff --git a/src/lib/ExtFmt.rs b/src/lib/ExtFmt.rs index fb7c4b9a0ae..a87fc87904d 100644 --- a/src/lib/ExtFmt.rs +++ b/src/lib/ExtFmt.rs @@ -382,7 +382,7 @@ mod RT { } fn conv_char(&conv cv, char c) -> str { - ret conv_str(cv, _str.from_char(c)); + ret pad(cv, _str.from_char(c), pad_nozero); } fn conv_str(&conv cv, str s) -> str { diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs index c5ad77f80d2..b69533702fe 100644 --- a/src/test/run-pass/syntax-extension-fmt.rs +++ b/src/test/run-pass/syntax-extension-fmt.rs @@ -67,7 +67,7 @@ fn main() { test(#fmt("%.s", "test"), ""); test(#fmt("%.x", 127u), "7f"); test(#fmt("%.t", 3u), "11"); - test(#fmt("%.c", 'A'), ""); + test(#fmt("%.c", 'A'), "A"); test(#fmt("%.0d", 0), ""); test(#fmt("%.0u", 0u), ""); @@ -79,7 +79,7 @@ fn main() { test(#fmt("%.0s", "test"), ""); test(#fmt("%.0x", 127u), "7f"); test(#fmt("%.0t", 3u), "11"); - test(#fmt("%.0c", 'A'), ""); + test(#fmt("%.0c", 'A'), "A"); test(#fmt("%.1d", 0), "0"); test(#fmt("%.1u", 0u), "0"); @@ -137,6 +137,7 @@ fn main() { test(#fmt("%05t", 3u), "00011"); // 0-padding a string is undefined but glibc does this: test(#fmt("%05s", "test"), " test"); + test(#fmt("%05c", 'A'), " A"); test(#fmt("%05b", true), " true"); // Left-justify overrides 0-padding @@ -148,6 +149,7 @@ fn main() { test(#fmt("%-05X", 127u), "7F "); test(#fmt("%-05t", 3u), "11 "); test(#fmt("%-05s", "test"), "test "); + test(#fmt("%-05c", 'A'), "A "); test(#fmt("%-05b", true), "true "); // Precision overrides 0-padding @@ -158,6 +160,7 @@ fn main() { test(#fmt("%06.5d", -10), "-00010"); test(#fmt("%06.5u", 10u), " 00010"); test(#fmt("%06.5s", "test"), " test"); + test(#fmt("%06.5c", 'A'), " A"); test(#fmt("%06.5x", 127u), " 0007f"); test(#fmt("%06.5X", 127u), " 0007F");