From 834218d789430ac238e5ef4fa99cfe4bcf006f2d Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Thu, 9 Jan 2020 01:56:38 -0800 Subject: [PATCH] Fix remaining variadic formatted prints Used a series of regex searches to try to find as many instances of the old pattern as I could and update them. --- lib/std/crypto/benchmark.zig | 12 +++---- lib/std/hash/benchmark.zig | 19 +++------- lib/std/os/uefi.zig | 8 ++++- lib/std/special/c.zig | 2 +- lib/std/special/compiler_rt.zig | 2 +- lib/std/special/compiler_rt/ashrti3_test.zig | 4 +-- lib/std/special/compiler_rt/fixdfdi_test.zig | 4 +-- lib/std/special/compiler_rt/fixdfsi_test.zig | 4 +-- lib/std/special/compiler_rt/fixdfti_test.zig | 4 +-- lib/std/special/compiler_rt/fixint_test.zig | 2 +- lib/std/special/compiler_rt/fixsfdi_test.zig | 4 +-- lib/std/special/compiler_rt/fixsfsi_test.zig | 4 +-- lib/std/special/compiler_rt/fixsfti_test.zig | 4 +-- lib/std/special/compiler_rt/fixtfdi_test.zig | 4 +-- lib/std/special/compiler_rt/fixtfsi_test.zig | 4 +-- lib/std/special/compiler_rt/fixtfti_test.zig | 4 +-- lib/std/zig/perf_test.zig | 2 +- src-self-hosted/dep_tokenizer.zig | 2 +- src-self-hosted/test.zig | 15 ++++---- src-self-hosted/translate_c.zig | 4 +-- src-self-hosted/type.zig | 2 +- tools/process_headers.zig | 37 +++++++++----------- tools/update_glibc.zig | 12 +++---- 23 files changed, 76 insertions(+), 83 deletions(-) diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index 95761b7ba64bb43ea413659e4ac477bdc6a314ee..b8bb69419d14735215dabae18610295b40942642 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -125,9 +125,9 @@ fn mode(comptime x: comptime_int) comptime_int { fn printPad(stdout: var, s: []const u8) !void { var i: usize = 0; while (i < 12 - s.len) : (i += 1) { - try stdout.print(" "); + try stdout.print(" ", .{}); } - try stdout.print("{}", s); + try stdout.print("{}", .{s}); } pub fn main() !void { @@ -142,7 +142,7 @@ pub fn main() !void { var i: usize = 1; while (i < args.len) : (i += 1) { if (std.mem.eql(u8, args[i], "--mode")) { - try stdout.print("{}\n", builtin.mode); + try stdout.print("{}\n", .{builtin.mode}); return; } else if (std.mem.eql(u8, args[i], "--seed")) { i += 1; @@ -174,7 +174,7 @@ pub fn main() !void { if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { const throughput = try benchmarkHash(H.ty, mode(32 * MiB)); try printPad(stdout, H.name); - try stdout.print(": {} MiB/s\n", throughput / (1 * MiB)); + try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)}); } } @@ -182,7 +182,7 @@ pub fn main() !void { if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) { const throughput = try benchmarkMac(M.ty, mode(128 * MiB)); try printPad(stdout, M.name); - try stdout.print(": {} MiB/s\n", throughput / (1 * MiB)); + try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)}); } } @@ -190,7 +190,7 @@ pub fn main() !void { if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) { const throughput = try benchmarkKeyExchange(E.ty, mode(1000)); try printPad(stdout, E.name); - try stdout.print(": {} exchanges/s\n", throughput); + try stdout.print(": {} exchanges/s\n", .{throughput}); } } } diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig index f1b39bff643fcce54ffa26d6ea28a8f6acfec0f9..ce9ed75b5847f6efa20e05281a7e88434d3e950f 100644 --- a/lib/std/hash/benchmark.zig +++ b/lib/std/hash/benchmark.zig @@ -171,15 +171,6 @@ fn mode(comptime x: comptime_int) comptime_int { return if (builtin.mode == builtin.Mode.Debug) x / 64 else x; } -// TODO(#1358): Replace with builtin formatted padding when available. -fn printPad(stdout: var, s: []const u8) !void { - var i: usize = 0; - while (i < 12 - s.len) : (i += 1) { - try stdout.print(" "); - } - try stdout.print("{}", s); -} - pub fn main() !void { var stdout_file = std.io.getStdOut(); var stdout_out_stream = stdout_file.outStream(); @@ -198,7 +189,7 @@ pub fn main() !void { var i: usize = 1; while (i < args.len) : (i += 1) { if (std.mem.eql(u8, args[i], "--mode")) { - try stdout.print("{}\n", builtin.mode); + try stdout.print("{}\n", .{builtin.mode}); return; } else if (std.mem.eql(u8, args[i], "--seed")) { i += 1; @@ -235,7 +226,7 @@ pub fn main() !void { key_size = try std.fmt.parseUnsigned(usize, args[i], 10); if (key_size > block_size) { - try stdout.print("key_size cannot exceed block size of {}\n", block_size); + try stdout.print("key_size cannot exceed block size of {}\n", .{block_size}); std.os.exit(1); } } else if (std.mem.eql(u8, args[i], "--iterative-only")) { @@ -252,20 +243,20 @@ pub fn main() !void { inline for (hashes) |H| { if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { if (!test_iterative_only or H.has_iterative_api) { - try stdout.print("{}\n", H.name); + try stdout.print("{}\n", .{H.name}); // Always reseed prior to every call so we are hashing the same buffer contents. // This allows easier comparison between different implementations. if (H.has_iterative_api) { prng.seed(seed); const result = try benchmarkHash(H, count); - try stdout.print(" iterative: {:4} MiB/s [{x:0<16}]\n", result.throughput / (1 * MiB), result.hash); + try stdout.print(" iterative: {:4} MiB/s [{x:0<16}]\n", .{result.throughput / (1 * MiB), result.hash}); } if (!test_iterative_only) { prng.seed(seed); const result_small = try benchmarkHashSmallKeys(H, key_size, count); - try stdout.print(" small keys: {:4} MiB/s [{x:0<16}]\n", result_small.throughput / (1 * MiB), result_small.hash); + try stdout.print(" small keys: {:4} MiB/s [{x:0<16}]\n", .{result_small.throughput / (1 * MiB), result_small.hash}); } } } diff --git a/lib/std/os/uefi.zig b/lib/std/os/uefi.zig index c780cfd3b5cdaaf1e09975073ba692344771e426..1095706c9749ebccbfe90d91b43aaa1ab8c7e644 100644 --- a/lib/std/os/uefi.zig +++ b/lib/std/os/uefi.zig @@ -35,7 +35,13 @@ pub const Guid = extern struct { output: fn (@TypeOf(context), []const u8) Errors!void, ) Errors!void { if (f.len == 0) { - return fmt.format(context, Errors, output, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", self.time_low, self.time_mid, self.time_high_and_version, self.clock_seq_high_and_reserved, self.clock_seq_low, self.node); + return fmt.format(context, Errors, output, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ + self.time_low, + self.time_mid, + self.time_high_and_version, + self.clock_seq_high_and_reserved, + self.clock_seq_low, self.node, + }); } else { @compileError("Unknown format character: '" ++ f ++ "'"); } diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index 604bfd277a4c10a29905d4b8891723f3fe67ab37..581a004e863ab36a27bbdc987bd2b556d69312a4 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -81,7 +81,7 @@ test "strncmp" { pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { if (builtin.is_test) { @setCold(true); - std.debug.panic("{}", msg); + std.debug.panic("{}", .{msg}); } if (builtin.os != .freestanding and builtin.os != .other) { std.os.abort(); diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index efa21d6cd751dcbedc9a4b897ec0640a78de247e..6a2f11e1aa424bd3e735ef8c6cfb4af201354b73 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -308,7 +308,7 @@ const __udivmoddi4 = @import("compiler_rt/udivmoddi4.zig").__udivmoddi4; pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { @setCold(true); if (is_test) { - std.debug.panic("{}", msg); + std.debug.panic("{}", .{msg}); } else { unreachable; } diff --git a/lib/std/special/compiler_rt/ashrti3_test.zig b/lib/std/special/compiler_rt/ashrti3_test.zig index ad3164be8dc32bc8e2ee91f312eae428cb9a6f83..6a7565e557e87d2d46ccb980bf1e2f8f39adb359 100644 --- a/lib/std/special/compiler_rt/ashrti3_test.zig +++ b/lib/std/special/compiler_rt/ashrti3_test.zig @@ -3,8 +3,8 @@ const testing = @import("std").testing; fn test__ashrti3(a: i128, b: i32, expected: i128) void { const x = __ashrti3(a, b); - // @import("std").debug.warn("got 0x{x}\nexp 0x{x}\n", @truncate(u64, - // @bitCast(u128, x) >> 64), @truncate(u64, @bitCast(u128, expected)) >> 64); + // @import("std").debug.warn("got 0x{x}\nexp 0x{x}\n", .{@truncate(u64, + // @bitCast(u128, x) >> 64), @truncate(u64, @bitCast(u128, expected)) >> 64}); testing.expect(x == expected); } diff --git a/lib/std/special/compiler_rt/fixdfdi_test.zig b/lib/std/special/compiler_rt/fixdfdi_test.zig index e06d641824e88ca69d57677839766aa33a957491..92dbdc2a5e1a2bc694cd7c2d8f994f1e5f7792c3 100644 --- a/lib/std/special/compiler_rt/fixdfdi_test.zig +++ b/lib/std/special/compiler_rt/fixdfdi_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixdfdi(a: f64, expected: i64) void { const x = __fixdfdi(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u64, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u64, expected)}); testing.expect(x == expected); } test "fixdfdi" { - //warn("\n"); + //warn("\n", .{}); test__fixdfdi(-math.f64_max, math.minInt(i64)); test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); diff --git a/lib/std/special/compiler_rt/fixdfsi_test.zig b/lib/std/special/compiler_rt/fixdfsi_test.zig index da53468c7da8d850317314333c110d53e02f26ff..fb9051889292fa7c1cb921220f744f2954ed2e67 100644 --- a/lib/std/special/compiler_rt/fixdfsi_test.zig +++ b/lib/std/special/compiler_rt/fixdfsi_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixdfsi(a: f64, expected: i32) void { const x = __fixdfsi(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u32, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u32, expected)}); testing.expect(x == expected); } test "fixdfsi" { - //warn("\n"); + //warn("\n", .{}); test__fixdfsi(-math.f64_max, math.minInt(i32)); test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); diff --git a/lib/std/special/compiler_rt/fixdfti_test.zig b/lib/std/special/compiler_rt/fixdfti_test.zig index b0c9049ba85742ad50279f7280daf8d98ba5d83b..f66e4a3d88821414e85a442a92775cd42aacc1be 100644 --- a/lib/std/special/compiler_rt/fixdfti_test.zig +++ b/lib/std/special/compiler_rt/fixdfti_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixdfti(a: f64, expected: i128) void { const x = __fixdfti(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u128, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u128, expected)}); testing.expect(x == expected); } test "fixdfti" { - //warn("\n"); + //warn("\n", .{}); test__fixdfti(-math.f64_max, math.minInt(i128)); test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); diff --git a/lib/std/special/compiler_rt/fixint_test.zig b/lib/std/special/compiler_rt/fixint_test.zig index d5f7b3898d2341d92041572e9df4733de21dccca..4efb1e6ab3a44809e5700074687132309dedb500 100644 --- a/lib/std/special/compiler_rt/fixint_test.zig +++ b/lib/std/special/compiler_rt/fixint_test.zig @@ -8,7 +8,7 @@ const fixint = @import("fixint.zig").fixint; fn test__fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t, expected: fixint_t) void { const x = fixint(fp_t, fixint_t, a); - //warn("a={} x={}:{x} expected={}:{x})\n", a, x, x, expected, expected); + //warn("a={} x={}:{x} expected={}:{x})\n", .{a, x, x, expected, expected}); testing.expect(x == expected); } diff --git a/lib/std/special/compiler_rt/fixsfdi_test.zig b/lib/std/special/compiler_rt/fixsfdi_test.zig index 02844946a7845be17d567565af0d991cb1922a71..5888c9804d9826565fbf306da9331860b6db6911 100644 --- a/lib/std/special/compiler_rt/fixsfdi_test.zig +++ b/lib/std/special/compiler_rt/fixsfdi_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixsfdi(a: f32, expected: i64) void { const x = __fixsfdi(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u64, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", .{a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u64, expected)}); testing.expect(x == expected); } test "fixsfdi" { - //warn("\n"); + //warn("\n", .{}); test__fixsfdi(-math.f32_max, math.minInt(i64)); test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); diff --git a/lib/std/special/compiler_rt/fixsfsi_test.zig b/lib/std/special/compiler_rt/fixsfsi_test.zig index 69d8309de0715a6e058305ab23e461894d31081c..844235bc9db9290af56fc508bab756671cdfa594 100644 --- a/lib/std/special/compiler_rt/fixsfsi_test.zig +++ b/lib/std/special/compiler_rt/fixsfsi_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixsfsi(a: f32, expected: i32) void { const x = __fixsfsi(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u32, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", .{a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u32, expected)}); testing.expect(x == expected); } test "fixsfsi" { - //warn("\n"); + //warn("\n", .{}); test__fixsfsi(-math.f32_max, math.minInt(i32)); test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); diff --git a/lib/std/special/compiler_rt/fixsfti_test.zig b/lib/std/special/compiler_rt/fixsfti_test.zig index cecfeda557adc20cd95d167d97be4031dd2804fc..9eb2883f38c68480ee9a163edf38f2986eb398bb 100644 --- a/lib/std/special/compiler_rt/fixsfti_test.zig +++ b/lib/std/special/compiler_rt/fixsfti_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixsfti(a: f32, expected: i128) void { const x = __fixsfti(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u128, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", .{a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u128, expected)}); testing.expect(x == expected); } test "fixsfti" { - //warn("\n"); + //warn("\n", .{}); test__fixsfti(-math.f32_max, math.minInt(i128)); test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); diff --git a/lib/std/special/compiler_rt/fixtfdi_test.zig b/lib/std/special/compiler_rt/fixtfdi_test.zig index b45001e18eef939eddac0959530d09f120bfc126..6baa9011c3ea49ca0f854dd78c9cf7976a744f00 100644 --- a/lib/std/special/compiler_rt/fixtfdi_test.zig +++ b/lib/std/special/compiler_rt/fixtfdi_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixtfdi(a: f128, expected: i64) void { const x = __fixtfdi(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u64, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u64, expected)}); testing.expect(x == expected); } test "fixtfdi" { - //warn("\n"); + //warn("\n", .{}); test__fixtfdi(-math.f128_max, math.minInt(i64)); test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); diff --git a/lib/std/special/compiler_rt/fixtfsi_test.zig b/lib/std/special/compiler_rt/fixtfsi_test.zig index c6f66239950b5a70af62f984f505c1ce36834e81..c7294fe250146af0346957d38c6fba8e07a5c408 100644 --- a/lib/std/special/compiler_rt/fixtfsi_test.zig +++ b/lib/std/special/compiler_rt/fixtfsi_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixtfsi(a: f128, expected: i32) void { const x = __fixtfsi(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u32, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", .{a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u32, expected)}); testing.expect(x == expected); } test "fixtfsi" { - //warn("\n"); + //warn("\n", .{}); test__fixtfsi(-math.f128_max, math.minInt(i32)); test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); diff --git a/lib/std/special/compiler_rt/fixtfti_test.zig b/lib/std/special/compiler_rt/fixtfti_test.zig index b36c5beb4eb678a404265c3ae3224d4bb5cd017d..6b8218e2f61a9f1ea1958c4ae8694bd8cb082bc8 100644 --- a/lib/std/special/compiler_rt/fixtfti_test.zig +++ b/lib/std/special/compiler_rt/fixtfti_test.zig @@ -6,12 +6,12 @@ const warn = std.debug.warn; fn test__fixtfti(a: f128, expected: i128) void { const x = __fixtfti(a); - //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u128, expected)); + //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", .{a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u128, expected)}); testing.expect(x == expected); } test "fixtfti" { - //warn("\n"); + //warn("\n", .{}); test__fixtfti(-math.f128_max, math.minInt(i128)); test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); diff --git a/lib/std/zig/perf_test.zig b/lib/std/zig/perf_test.zig index d1ef05a02a5899c15bd26896ba38fad2f169cf8c..fe9d35fa43bb24632a19e4edf1e4470883ef4f01 100644 --- a/lib/std/zig/perf_test.zig +++ b/lib/std/zig/perf_test.zig @@ -25,7 +25,7 @@ pub fn main() !void { var stdout_file = std.io.getStdOut(); const stdout = &stdout_file.outStream().stream; - try stdout.print("{:.3} MiB/s, {} KiB used \n", mb_per_sec, memory_used / 1024); + try stdout.print("{:.3} MiB/s, {} KiB used \n", .{mb_per_sec, memory_used / 1024}); } fn testOnce() usize { diff --git a/src-self-hosted/dep_tokenizer.zig b/src-self-hosted/dep_tokenizer.zig index eb3500cad17bd452146f11c6a75d6fe782766193..c5b0f0cd1401f13ec131ed1ffb529656abb0ab2c 100644 --- a/src-self-hosted/dep_tokenizer.zig +++ b/src-self-hosted/dep_tokenizer.zig @@ -894,7 +894,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void { fn printLabel(out: var, label: []const u8, bytes: []const u8) !void { var buf: [80]u8 = undefined; - var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", label, bytes.len); + var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{label, bytes.len}); try out.write(text); var i: usize = text.len; const end = 79; diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index 62b7914dbc8dcb3fb6db8454f5076cb7eeb0ea79..8c322e5fb62aa64bb9fe09dec31e3f446f16602a 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -81,7 +81,7 @@ pub const TestContext = struct { msg: []const u8, ) !void { var file_index_buf: [20]u8 = undefined; - const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr()); + const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()}); const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 }); if (std.fs.path.dirname(file1_path)) |dirname| { @@ -114,10 +114,10 @@ pub const TestContext = struct { expected_output: []const u8, ) !void { var file_index_buf: [20]u8 = undefined; - const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr()); + const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()}); const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 }); - const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (Target{ .Native = {} }).exeFileExt()); + const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() }); if (std.fs.path.dirname(file1_path)) |dirname| { try std.fs.makePath(allocator, dirname); } @@ -214,21 +214,20 @@ pub const TestContext = struct { } } } - std.debug.warn( - "\n=====source:=======\n{}\n====expected:========\n{}:{}:{}: error: {}\n", + std.debug.warn("\n=====source:=======\n{}\n====expected:========\n{}:{}:{}: error: {}\n", .{ source, path, line, column, text, - ); - std.debug.warn("\n====found:========\n"); + }); + std.debug.warn("\n====found:========\n", .{}); const stderr = std.io.getStdErr(); for (msgs) |msg| { defer msg.destroy(); try msg.printToFile(stderr, errmsg.Color.Auto); } - std.debug.warn("============\n"); + std.debug.warn("============\n", .{}); return error.TestFailed; }, } diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index 87e887d130f292927f9dfbc869fcb7b890383765..8223d5b265db47ea6113bf26da72684eb715960f 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -330,11 +330,11 @@ pub fn translate( tree.root_node.eof_token = try appendToken(&context, .Eof, ""); tree.source = source_buffer.toOwnedSlice(); if (false) { - std.debug.warn("debug source:\n{}\n==EOF==\ntokens:\n", tree.source); + std.debug.warn("debug source:\n{}\n==EOF==\ntokens:\n", .{tree.source}); var i: usize = 0; while (i < tree.tokens.len) : (i += 1) { const token = tree.tokens.at(i); - std.debug.warn("{}\n", token); + std.debug.warn("{}\n", .{token}); } } return tree; diff --git a/src-self-hosted/type.zig b/src-self-hosted/type.zig index d4ffc355c0fbe032fe231813718d7e8fccdd01fb..67e1aebdca75617f0f9f5ff75ee8806a7f277584 100644 --- a/src-self-hosted/type.zig +++ b/src-self-hosted/type.zig @@ -162,7 +162,7 @@ pub const Type = struct { } pub fn dump(base: *const Type) void { - std.debug.warn("{}", @tagName(base.id)); + std.debug.warn("{}", .{@tagName(base.id)}); } fn init(base: *Type, comp: *Compilation, id: Id, name: []const u8) void { diff --git a/tools/process_headers.zig b/tools/process_headers.zig index fd39cb93addb54193283843da089d7b88bd58fe7..9952147aac946fa3473154b935b18f9d08391140 100644 --- a/tools/process_headers.zig +++ b/tools/process_headers.zig @@ -270,7 +270,7 @@ pub fn main() !void { if (std.mem.eql(u8, args[arg_i], "--help")) usageAndExit(args[0]); if (arg_i + 1 >= args.len) { - std.debug.warn("expected argument after '{}'\n", args[arg_i]); + std.debug.warn("expected argument after '{}'\n", .{args[arg_i]}); usageAndExit(args[0]); } @@ -283,7 +283,7 @@ pub fn main() !void { assert(opt_abi == null); opt_abi = args[arg_i + 1]; } else { - std.debug.warn("unrecognized argument: {}\n", args[arg_i]); + std.debug.warn("unrecognized argument: {}\n", .{args[arg_i]}); usageAndExit(args[0]); } @@ -297,10 +297,10 @@ pub fn main() !void { else if (std.mem.eql(u8, abi_name, "glibc")) LibCVendor.glibc else { - std.debug.warn("unrecognized C ABI: {}\n", abi_name); + std.debug.warn("unrecognized C ABI: {}\n", .{abi_name}); usageAndExit(args[0]); }; - const generic_name = try std.fmt.allocPrint(allocator, "generic-{}", abi_name); + const generic_name = try std.fmt.allocPrint(allocator, "generic-{}", .{abi_name}); // TODO compiler crashed when I wrote this the canonical way var libc_targets: []const LibCTarget = undefined; @@ -365,12 +365,11 @@ pub fn main() !void { if (gop.found_existing) { max_bytes_saved += raw_bytes.len; gop.kv.value.hit_count += 1; - std.debug.warn( - "duplicate: {} {} ({Bi:2})\n", + std.debug.warn("duplicate: {} {} ({Bi:2})\n", .{ libc_target.name, rel_path, raw_bytes.len, - ); + }); } else { gop.kv.value = Contents{ .bytes = trimmed, @@ -388,16 +387,16 @@ pub fn main() !void { }; assert((try target_to_hash.put(dest_target, hash)) == null); }, - else => std.debug.warn("warning: weird file: {}\n", full_path), + else => std.debug.warn("warning: weird file: {}\n", .{full_path}), } } } break; } else { - std.debug.warn("warning: libc target not found: {}\n", libc_target.name); + std.debug.warn("warning: libc target not found: {}\n", .{libc_target.name}); } } - std.debug.warn("summary: {Bi:2} could be reduced to {Bi:2}\n", total_bytes, total_bytes - max_bytes_saved); + std.debug.warn("summary: {Bi:2} could be reduced to {Bi:2}\n", .{total_bytes, total_bytes - max_bytes_saved}); try std.fs.makePath(allocator, out_dir); var missed_opportunity_bytes: usize = 0; @@ -426,7 +425,7 @@ pub fn main() !void { if (contender.hit_count > 1) { const this_missed_bytes = contender.hit_count * contender.bytes.len; missed_opportunity_bytes += this_missed_bytes; - std.debug.warn("Missed opportunity ({Bi:2}): {}\n", this_missed_bytes, path_kv.key); + std.debug.warn("Missed opportunity ({Bi:2}): {}\n", .{this_missed_bytes, path_kv.key}); } else break; } } @@ -440,13 +439,11 @@ pub fn main() !void { .specific => |a| @tagName(a), else => @tagName(dest_target.arch), }; - const out_subpath = try std.fmt.allocPrint( - allocator, - "{}-{}-{}", + const out_subpath = try std.fmt.allocPrint(allocator, "{}-{}-{}", .{ arch_name, @tagName(dest_target.os), @tagName(dest_target.abi), - ); + }); const full_path = try std.fs.path.join(allocator, [_][]const u8{ out_dir, out_subpath, path_kv.key }); try std.fs.makePath(allocator, std.fs.path.dirname(full_path).?); try std.io.writeFile(full_path, contents.bytes); @@ -455,10 +452,10 @@ pub fn main() !void { } fn usageAndExit(arg0: []const u8) noreturn { - std.debug.warn("Usage: {} [--search-path ] --out --abi \n", arg0); - std.debug.warn("--search-path can be used any number of times.\n"); - std.debug.warn(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n"); - std.debug.warn("--out is a dir that will be created, and populated with the results\n"); - std.debug.warn("--abi is either musl or glibc\n"); + std.debug.warn("Usage: {} [--search-path ] --out --abi \n", .{arg0}); + std.debug.warn("--search-path can be used any number of times.\n", .{}); + std.debug.warn(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{}); + std.debug.warn("--out is a dir that will be created, and populated with the results\n", .{}); + std.debug.warn("--abi is either musl or glibc\n", .{}); std.process.exit(1); } diff --git a/tools/update_glibc.zig b/tools/update_glibc.zig index ca2ee295ecc70f4b145d8f3c30cb681f856c7bfc..b97f81d286b53ea1bcc5e7df5c135f2036387ab3 100644 --- a/tools/update_glibc.zig +++ b/tools/update_glibc.zig @@ -155,7 +155,7 @@ pub fn main() !void { const fn_set = &target_funcs_gop.kv.value.list; for (lib_names) |lib_name, lib_name_index| { - const basename = try fmt.allocPrint(allocator, "lib{}.abilist", lib_name); + const basename = try fmt.allocPrint(allocator, "lib{}.abilist", .{lib_name}); const abi_list_filename = blk: { if (abi_list.targets[0].abi == .gnuabi64 and std.mem.eql(u8, lib_name, "c")) { break :blk try fs.path.join(allocator, [_][]const u8{ prefix, abi_list.path, "n64", basename }); @@ -177,7 +177,7 @@ pub fn main() !void { break :blk try fs.path.join(allocator, [_][]const u8{ prefix, abi_list.path, basename }); }; const contents = std.io.readFileAlloc(allocator, abi_list_filename) catch |err| { - std.debug.warn("unable to open {}: {}\n", abi_list_filename, err); + std.debug.warn("unable to open {}: {}\n", .{abi_list_filename, err}); std.process.exit(1); }; var lines_it = std.mem.tokenize(contents, "\n"); @@ -235,7 +235,7 @@ pub fn main() !void { const vers_txt = &buffered.stream; for (global_ver_list) |name, i| { _ = global_ver_set.put(name, i) catch unreachable; - try vers_txt.print("{}\n", name); + try vers_txt.print("{}\n", .{name}); } try buffered.flush(); } @@ -248,7 +248,7 @@ pub fn main() !void { for (global_fn_list) |name, i| { const kv = global_fn_set.get(name).?; kv.value.index = i; - try fns_txt.print("{} {}\n", name, kv.value.lib); + try fns_txt.print("{} {}\n", .{name, kv.value.lib}); } try buffered.flush(); } @@ -282,7 +282,7 @@ pub fn main() !void { const fn_vers_list = &target_functions.get(@ptrToInt(abi_list)).?.value.fn_vers_list; for (abi_list.targets) |target, it_i| { if (it_i != 0) try abilist_txt.writeByte(' '); - try abilist_txt.print("{}-linux-{}", @tagName(target.arch), @tagName(target.abi)); + try abilist_txt.print("{}-linux-{}", .{@tagName(target.arch), @tagName(target.abi)}); } try abilist_txt.writeByte('\n'); // next, each line implicitly corresponds to a function @@ -293,7 +293,7 @@ pub fn main() !void { }; for (kv.value.toSliceConst()) |ver_index, it_i| { if (it_i != 0) try abilist_txt.writeByte(' '); - try abilist_txt.print("{d}", ver_index); + try abilist_txt.print("{d}", .{ver_index}); } try abilist_txt.writeByte('\n'); } -- 2.54.0