| ... | @@ -64,6 +64,7 @@ fn peekIsAlign(comptime fmt: []const u8) bool { | ... | @@ -64,6 +64,7 @@ fn peekIsAlign(comptime fmt: []const u8) bool { |
| 64 | /// - `e`: output floating point value in scientific notation | 64 | /// - `e`: output floating point value in scientific notation |
| 65 | /// - `d`: output numeric value in decimal notation | 65 | /// - `d`: output numeric value in decimal notation |
| 66 | /// - `b`: output integer value in binary notation | 66 | /// - `b`: output integer value in binary notation |
| | 67 | /// - `o`: output integer value in octal notation |
| 67 | /// - `c`: output integer as an ASCII character. Integer type must have 8 bits at max. | 68 | /// - `c`: output integer as an ASCII character. Integer type must have 8 bits at max. |
| 68 | /// - `*`: output the address of the value instead of the value itself. | 69 | /// - `*`: output the address of the value instead of the value itself. |
| 69 | /// | 70 | /// |
| ... | @@ -543,6 +544,9 @@ pub fn formatIntValue( | ... | @@ -543,6 +544,9 @@ pub fn formatIntValue( |
| 543 | } else if (comptime std.mem.eql(u8, fmt, "X")) { | 544 | } else if (comptime std.mem.eql(u8, fmt, "X")) { |
| 544 | radix = 16; | 545 | radix = 16; |
| 545 | uppercase = true; | 546 | uppercase = true; |
| | 547 | } else if (comptime std.mem.eql(u8, fmt, "o")) { |
| | 548 | radix = 8; |
| | 549 | uppercase = false; |
| 546 | } else { | 550 | } else { |
| 547 | @compileError("Unknown format string: '" ++ fmt ++ "'"); | 551 | @compileError("Unknown format string: '" ++ fmt ++ "'"); |
| 548 | } | 552 | } |
| ... | @@ -1240,6 +1244,10 @@ test "int.specifier" { | ... | @@ -1240,6 +1244,10 @@ test "int.specifier" { |
| 1240 | const value: u8 = 0b1100; | 1244 | const value: u8 = 0b1100; |
| 1241 | try testFmt("u8: 0b1100\n", "u8: 0b{b}\n", .{value}); | 1245 | try testFmt("u8: 0b1100\n", "u8: 0b{b}\n", .{value}); |
| 1242 | } | 1246 | } |
| | 1247 | { |
| | 1248 | const value: u16 = 0o1234; |
| | 1249 | try testFmt("u16: 0o1234\n", "u16: 0o{o}\n", .{value}); |
| | 1250 | } |
| 1243 | } | 1251 | } |
| 1244 | | 1252 | |
| 1245 | test "int.padded" { | 1253 | test "int.padded" { |