diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 94b25c79a1..f2ee24a9e3 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -1,11 +1,12 @@ const std = @import("std.zig"); +const builtin = @import("builtin"); + const io = std.io; const math = std.math; const assert = std.debug.assert; const mem = std.mem; const unicode = std.unicode; const meta = std.meta; -const builtin = @import("builtin"); const errol = @import("fmt/errol.zig"); const lossyCast = std.math.lossyCast; const expectFmt = std.testing.expectFmt; @@ -190,7 +191,7 @@ pub fn format( .precision = precision, }, writer, - default_max_depth, + std.options.fmt_max_depth, ); } @@ -2140,15 +2141,15 @@ test "buffer" { { var buf1: [32]u8 = undefined; var fbs = std.io.fixedBufferStream(&buf1); - try formatType(1234, "", FormatOptions{}, fbs.writer(), default_max_depth); + try formatType(1234, "", FormatOptions{}, fbs.writer(), std.options.fmt_max_depth); try std.testing.expect(mem.eql(u8, fbs.getWritten(), "1234")); fbs.reset(); - try formatType('a', "c", FormatOptions{}, fbs.writer(), default_max_depth); + try formatType('a', "c", FormatOptions{}, fbs.writer(), std.options.fmt_max_depth); try std.testing.expect(mem.eql(u8, fbs.getWritten(), "a")); fbs.reset(); - try formatType(0b1100, "b", FormatOptions{}, fbs.writer(), default_max_depth); + try formatType(0b1100, "b", FormatOptions{}, fbs.writer(), std.options.fmt_max_depth); try std.testing.expect(mem.eql(u8, fbs.getWritten(), "1100")); } } diff --git a/lib/std/std.zig b/lib/std/std.zig index 40ba896569..e02be2ebaf 100644 --- a/lib/std/std.zig +++ b/lib/std/std.zig @@ -153,6 +153,11 @@ pub const options = struct { else log.defaultLog; + pub const fmt_max_depth = if (@hasDecl(options_override, "fmt_max_depth")) + options_override.fmt_max_depth + else + fmt.default_max_depth; + pub const cryptoRandomSeed: fn (buffer: []u8) void = if (@hasDecl(options_override, "cryptoRandomSeed")) options_override.cryptoRandomSeed else