authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2020-01-09 01:56:38-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-09 13:36:44-05:00
log834218d789430ac238e5ef4fa99cfe4bcf006f2d
tree6a43ac11524812625dba225dde6a091bcf2b0b2d
parentd7333d8798a929312ceb897007e7bb6a8b2999ee

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.

23 files changed, 76 insertions(+), 83 deletions(-)

lib/std/crypto/benchmark.zig+6-6
...@@ -125,9 +125,9 @@ fn mode(comptime x: comptime_int) comptime_int {...@@ -125,9 +125,9 @@ fn mode(comptime x: comptime_int) comptime_int {
125fn printPad(stdout: var, s: []const u8) !void {125fn printPad(stdout: var, s: []const u8) !void {
126 var i: usize = 0;126 var i: usize = 0;
127 while (i < 12 - s.len) : (i += 1) {127 while (i < 12 - s.len) : (i += 1) {
128 try stdout.print(" ");128 try stdout.print(" ", .{});
129 }129 }
130 try stdout.print("{}", s);130 try stdout.print("{}", .{s});
131}131}
132132
133pub fn main() !void {133pub fn main() !void {
...@@ -142,7 +142,7 @@ pub fn main() !void {...@@ -142,7 +142,7 @@ pub fn main() !void {
142 var i: usize = 1;142 var i: usize = 1;
143 while (i < args.len) : (i += 1) {143 while (i < args.len) : (i += 1) {
144 if (std.mem.eql(u8, args[i], "--mode")) {144 if (std.mem.eql(u8, args[i], "--mode")) {
145 try stdout.print("{}\n", builtin.mode);145 try stdout.print("{}\n", .{builtin.mode});
146 return;146 return;
147 } else if (std.mem.eql(u8, args[i], "--seed")) {147 } else if (std.mem.eql(u8, args[i], "--seed")) {
148 i += 1;148 i += 1;
...@@ -174,7 +174,7 @@ pub fn main() !void {...@@ -174,7 +174,7 @@ pub fn main() !void {
174 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {174 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {
175 const throughput = try benchmarkHash(H.ty, mode(32 * MiB));175 const throughput = try benchmarkHash(H.ty, mode(32 * MiB));
176 try printPad(stdout, H.name);176 try printPad(stdout, H.name);
177 try stdout.print(": {} MiB/s\n", throughput / (1 * MiB));177 try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)});
178 }178 }
179 }179 }
180180
...@@ -182,7 +182,7 @@ pub fn main() !void {...@@ -182,7 +182,7 @@ pub fn main() !void {
182 if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) {182 if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) {
183 const throughput = try benchmarkMac(M.ty, mode(128 * MiB));183 const throughput = try benchmarkMac(M.ty, mode(128 * MiB));
184 try printPad(stdout, M.name);184 try printPad(stdout, M.name);
185 try stdout.print(": {} MiB/s\n", throughput / (1 * MiB));185 try stdout.print(": {} MiB/s\n", .{throughput / (1 * MiB)});
186 }186 }
187 }187 }
188188
...@@ -190,7 +190,7 @@ pub fn main() !void {...@@ -190,7 +190,7 @@ pub fn main() !void {
190 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {190 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {
191 const throughput = try benchmarkKeyExchange(E.ty, mode(1000));191 const throughput = try benchmarkKeyExchange(E.ty, mode(1000));
192 try printPad(stdout, E.name);192 try printPad(stdout, E.name);
193 try stdout.print(": {} exchanges/s\n", throughput);193 try stdout.print(": {} exchanges/s\n", .{throughput});
194 }194 }
195 }195 }
196}196}
lib/std/hash/benchmark.zig+5-14
...@@ -171,15 +171,6 @@ fn mode(comptime x: comptime_int) comptime_int {...@@ -171,15 +171,6 @@ fn mode(comptime x: comptime_int) comptime_int {
171 return if (builtin.mode == builtin.Mode.Debug) x / 64 else x;171 return if (builtin.mode == builtin.Mode.Debug) x / 64 else x;
172}172}
173173
174// TODO(#1358): Replace with builtin formatted padding when available.
175fn printPad(stdout: var, s: []const u8) !void {
176 var i: usize = 0;
177 while (i < 12 - s.len) : (i += 1) {
178 try stdout.print(" ");
179 }
180 try stdout.print("{}", s);
181}
182
183pub fn main() !void {174pub fn main() !void {
184 var stdout_file = std.io.getStdOut();175 var stdout_file = std.io.getStdOut();
185 var stdout_out_stream = stdout_file.outStream();176 var stdout_out_stream = stdout_file.outStream();
...@@ -198,7 +189,7 @@ pub fn main() !void {...@@ -198,7 +189,7 @@ pub fn main() !void {
198 var i: usize = 1;189 var i: usize = 1;
199 while (i < args.len) : (i += 1) {190 while (i < args.len) : (i += 1) {
200 if (std.mem.eql(u8, args[i], "--mode")) {191 if (std.mem.eql(u8, args[i], "--mode")) {
201 try stdout.print("{}\n", builtin.mode);192 try stdout.print("{}\n", .{builtin.mode});
202 return;193 return;
203 } else if (std.mem.eql(u8, args[i], "--seed")) {194 } else if (std.mem.eql(u8, args[i], "--seed")) {
204 i += 1;195 i += 1;
...@@ -235,7 +226,7 @@ pub fn main() !void {...@@ -235,7 +226,7 @@ pub fn main() !void {
235226
236 key_size = try std.fmt.parseUnsigned(usize, args[i], 10);227 key_size = try std.fmt.parseUnsigned(usize, args[i], 10);
237 if (key_size > block_size) {228 if (key_size > block_size) {
238 try stdout.print("key_size cannot exceed block size of {}\n", block_size);229 try stdout.print("key_size cannot exceed block size of {}\n", .{block_size});
239 std.os.exit(1);230 std.os.exit(1);
240 }231 }
241 } else if (std.mem.eql(u8, args[i], "--iterative-only")) {232 } else if (std.mem.eql(u8, args[i], "--iterative-only")) {
...@@ -252,20 +243,20 @@ pub fn main() !void {...@@ -252,20 +243,20 @@ pub fn main() !void {
252 inline for (hashes) |H| {243 inline for (hashes) |H| {
253 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {244 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {
254 if (!test_iterative_only or H.has_iterative_api) {245 if (!test_iterative_only or H.has_iterative_api) {
255 try stdout.print("{}\n", H.name);246 try stdout.print("{}\n", .{H.name});
256247
257 // Always reseed prior to every call so we are hashing the same buffer contents.248 // Always reseed prior to every call so we are hashing the same buffer contents.
258 // This allows easier comparison between different implementations.249 // This allows easier comparison between different implementations.
259 if (H.has_iterative_api) {250 if (H.has_iterative_api) {
260 prng.seed(seed);251 prng.seed(seed);
261 const result = try benchmarkHash(H, count);252 const result = try benchmarkHash(H, count);
262 try stdout.print(" iterative: {:4} MiB/s [{x:0<16}]\n", result.throughput / (1 * MiB), result.hash);253 try stdout.print(" iterative: {:4} MiB/s [{x:0<16}]\n", .{result.throughput / (1 * MiB), result.hash});
263 }254 }
264255
265 if (!test_iterative_only) {256 if (!test_iterative_only) {
266 prng.seed(seed);257 prng.seed(seed);
267 const result_small = try benchmarkHashSmallKeys(H, key_size, count);258 const result_small = try benchmarkHashSmallKeys(H, key_size, count);
268 try stdout.print(" small keys: {:4} MiB/s [{x:0<16}]\n", result_small.throughput / (1 * MiB), result_small.hash);259 try stdout.print(" small keys: {:4} MiB/s [{x:0<16}]\n", .{result_small.throughput / (1 * MiB), result_small.hash});
269 }260 }
270 }261 }
271 }262 }
lib/std/os/uefi.zig+7-1
...@@ -35,7 +35,13 @@ pub const Guid = extern struct {...@@ -35,7 +35,13 @@ pub const Guid = extern struct {
35 output: fn (@TypeOf(context), []const u8) Errors!void,35 output: fn (@TypeOf(context), []const u8) Errors!void,
36 ) Errors!void {36 ) Errors!void {
37 if (f.len == 0) {37 if (f.len == 0) {
38 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);38 return fmt.format(context, Errors, output, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
39 self.time_low,
40 self.time_mid,
41 self.time_high_and_version,
42 self.clock_seq_high_and_reserved,
43 self.clock_seq_low, self.node,
44 });
39 } else {45 } else {
40 @compileError("Unknown format character: '" ++ f ++ "'");46 @compileError("Unknown format character: '" ++ f ++ "'");
41 }47 }
lib/std/special/c.zig+1-1
...@@ -81,7 +81,7 @@ test "strncmp" {...@@ -81,7 +81,7 @@ test "strncmp" {
81pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {81pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
82 if (builtin.is_test) {82 if (builtin.is_test) {
83 @setCold(true);83 @setCold(true);
84 std.debug.panic("{}", msg);84 std.debug.panic("{}", .{msg});
85 }85 }
86 if (builtin.os != .freestanding and builtin.os != .other) {86 if (builtin.os != .freestanding and builtin.os != .other) {
87 std.os.abort();87 std.os.abort();
lib/std/special/compiler_rt.zig+1-1
...@@ -308,7 +308,7 @@ const __udivmoddi4 = @import("compiler_rt/udivmoddi4.zig").__udivmoddi4;...@@ -308,7 +308,7 @@ const __udivmoddi4 = @import("compiler_rt/udivmoddi4.zig").__udivmoddi4;
308pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {308pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
309 @setCold(true);309 @setCold(true);
310 if (is_test) {310 if (is_test) {
311 std.debug.panic("{}", msg);311 std.debug.panic("{}", .{msg});
312 } else {312 } else {
313 unreachable;313 unreachable;
314 }314 }
lib/std/special/compiler_rt/ashrti3_test.zig+2-2
...@@ -3,8 +3,8 @@ const testing = @import("std").testing;...@@ -3,8 +3,8 @@ const testing = @import("std").testing;
33
4fn test__ashrti3(a: i128, b: i32, expected: i128) void {4fn test__ashrti3(a: i128, b: i32, expected: i128) void {
5 const x = __ashrti3(a, b);5 const x = __ashrti3(a, b);
6 // @import("std").debug.warn("got 0x{x}\nexp 0x{x}\n", @truncate(u64,6 // @import("std").debug.warn("got 0x{x}\nexp 0x{x}\n", .{@truncate(u64,
7 // @bitCast(u128, x) >> 64), @truncate(u64, @bitCast(u128, expected)) >> 64);7 // @bitCast(u128, x) >> 64), @truncate(u64, @bitCast(u128, expected)) >> 64});
8 testing.expect(x == expected);8 testing.expect(x == expected);
9}9}
1010
lib/std/special/compiler_rt/fixdfdi_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixdfdi(a: f64, expected: i64) void {7fn test__fixdfdi(a: f64, expected: i64) void {
8 const x = __fixdfdi(a);8 const x = __fixdfdi(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u64, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u64, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixdfdi" {13test "fixdfdi" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixdfdi(-math.f64_max, math.minInt(i64));15 test__fixdfdi(-math.f64_max, math.minInt(i64));
1616
17 test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));17 test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
lib/std/special/compiler_rt/fixdfsi_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixdfsi(a: f64, expected: i32) void {7fn test__fixdfsi(a: f64, expected: i32) void {
8 const x = __fixdfsi(a);8 const x = __fixdfsi(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u32, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u32, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixdfsi" {13test "fixdfsi" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixdfsi(-math.f64_max, math.minInt(i32));15 test__fixdfsi(-math.f64_max, math.minInt(i32));
1616
17 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));17 test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
lib/std/special/compiler_rt/fixdfti_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixdfti(a: f64, expected: i128) void {7fn test__fixdfti(a: f64, expected: i128) void {
8 const x = __fixdfti(a);8 const x = __fixdfti(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u128, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u64, a), x, x, expected, expected, @bitCast(u128, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixdfti" {13test "fixdfti" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixdfti(-math.f64_max, math.minInt(i128));15 test__fixdfti(-math.f64_max, math.minInt(i128));
1616
17 test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));17 test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
lib/std/special/compiler_rt/fixint_test.zig+1-1
...@@ -8,7 +8,7 @@ const fixint = @import("fixint.zig").fixint;...@@ -8,7 +8,7 @@ const fixint = @import("fixint.zig").fixint;
88
9fn test__fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t, expected: fixint_t) void {9fn test__fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t, expected: fixint_t) void {
10 const x = fixint(fp_t, fixint_t, a);10 const x = fixint(fp_t, fixint_t, a);
11 //warn("a={} x={}:{x} expected={}:{x})\n", a, x, x, expected, expected);11 //warn("a={} x={}:{x} expected={}:{x})\n", .{a, x, x, expected, expected});
12 testing.expect(x == expected);12 testing.expect(x == expected);
13}13}
1414
lib/std/special/compiler_rt/fixsfdi_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixsfdi(a: f32, expected: i64) void {7fn test__fixsfdi(a: f32, expected: i64) void {
8 const x = __fixsfdi(a);8 const x = __fixsfdi(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u64, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", .{a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u64, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixsfdi" {13test "fixsfdi" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixsfdi(-math.f32_max, math.minInt(i64));15 test__fixsfdi(-math.f32_max, math.minInt(i64));
1616
17 test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));17 test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
lib/std/special/compiler_rt/fixsfsi_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixsfsi(a: f32, expected: i32) void {7fn test__fixsfsi(a: f32, expected: i32) void {
8 const x = __fixsfsi(a);8 const x = __fixsfsi(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u32, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", .{a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u32, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixsfsi" {13test "fixsfsi" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixsfsi(-math.f32_max, math.minInt(i32));15 test__fixsfsi(-math.f32_max, math.minInt(i32));
1616
17 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));17 test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
lib/std/special/compiler_rt/fixsfti_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixsfti(a: f32, expected: i128) void {7fn test__fixsfti(a: f32, expected: i128) void {
8 const x = __fixsfti(a);8 const x = __fixsfti(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u128, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", .{a, @bitCast(u32, a), x, x, expected, expected, @bitCast(u128, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixsfti" {13test "fixsfti" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixsfti(-math.f32_max, math.minInt(i128));15 test__fixsfti(-math.f32_max, math.minInt(i128));
1616
17 test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));17 test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
lib/std/special/compiler_rt/fixtfdi_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixtfdi(a: f128, expected: i64) void {7fn test__fixtfdi(a: f128, expected: i64) void {
8 const x = __fixtfdi(a);8 const x = __fixtfdi(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u64, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u64, {x})\n", .{a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u64, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixtfdi" {13test "fixtfdi" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixtfdi(-math.f128_max, math.minInt(i64));15 test__fixtfdi(-math.f128_max, math.minInt(i64));
1616
17 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));17 test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
lib/std/special/compiler_rt/fixtfsi_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixtfsi(a: f128, expected: i32) void {7fn test__fixtfsi(a: f128, expected: i32) void {
8 const x = __fixtfsi(a);8 const x = __fixtfsi(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u32, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u32, {x})\n", .{a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u32, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixtfsi" {13test "fixtfsi" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixtfsi(-math.f128_max, math.minInt(i32));15 test__fixtfsi(-math.f128_max, math.minInt(i32));
1616
17 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));17 test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
lib/std/special/compiler_rt/fixtfti_test.zig+2-2
...@@ -6,12 +6,12 @@ const warn = std.debug.warn;...@@ -6,12 +6,12 @@ const warn = std.debug.warn;
66
7fn test__fixtfti(a: f128, expected: i128) void {7fn test__fixtfti(a: f128, expected: i128) void {
8 const x = __fixtfti(a);8 const x = __fixtfti(a);
9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u128, expected));9 //warn("a={}:{x} x={}:{x} expected={}:{x}:@as(u128, {x})\n", .{a, @bitCast(u128, a), x, x, expected, expected, @bitCast(u128, expected)});
10 testing.expect(x == expected);10 testing.expect(x == expected);
11}11}
1212
13test "fixtfti" {13test "fixtfti" {
14 //warn("\n");14 //warn("\n", .{});
15 test__fixtfti(-math.f128_max, math.minInt(i128));15 test__fixtfti(-math.f128_max, math.minInt(i128));
1616
17 test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));17 test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
lib/std/zig/perf_test.zig+1-1
...@@ -25,7 +25,7 @@ pub fn main() !void {...@@ -25,7 +25,7 @@ pub fn main() !void {
2525
26 var stdout_file = std.io.getStdOut();26 var stdout_file = std.io.getStdOut();
27 const stdout = &stdout_file.outStream().stream;27 const stdout = &stdout_file.outStream().stream;
28 try stdout.print("{:.3} MiB/s, {} KiB used \n", mb_per_sec, memory_used / 1024);28 try stdout.print("{:.3} MiB/s, {} KiB used \n", .{mb_per_sec, memory_used / 1024});
29}29}
3030
31fn testOnce() usize {31fn testOnce() usize {
src-self-hosted/dep_tokenizer.zig+1-1
...@@ -894,7 +894,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void {...@@ -894,7 +894,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void {
894894
895fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {895fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {
896 var buf: [80]u8 = undefined;896 var buf: [80]u8 = undefined;
897 var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", label, bytes.len);897 var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{label, bytes.len});
898 try out.write(text);898 try out.write(text);
899 var i: usize = text.len;899 var i: usize = text.len;
900 const end = 79;900 const end = 79;
src-self-hosted/test.zig+7-8
...@@ -81,7 +81,7 @@ pub const TestContext = struct {...@@ -81,7 +81,7 @@ pub const TestContext = struct {
81 msg: []const u8,81 msg: []const u8,
82 ) !void {82 ) !void {
83 var file_index_buf: [20]u8 = undefined;83 var file_index_buf: [20]u8 = undefined;
84 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());84 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
85 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });85 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
8686
87 if (std.fs.path.dirname(file1_path)) |dirname| {87 if (std.fs.path.dirname(file1_path)) |dirname| {
...@@ -114,10 +114,10 @@ pub const TestContext = struct {...@@ -114,10 +114,10 @@ pub const TestContext = struct {
114 expected_output: []const u8,114 expected_output: []const u8,
115 ) !void {115 ) !void {
116 var file_index_buf: [20]u8 = undefined;116 var file_index_buf: [20]u8 = undefined;
117 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", self.file_index.incr());117 const file_index = try std.fmt.bufPrint(file_index_buf[0..], "{}", .{self.file_index.incr()});
118 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });118 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
119119
120 const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", file1_path, (Target{ .Native = {} }).exeFileExt());120 const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });
121 if (std.fs.path.dirname(file1_path)) |dirname| {121 if (std.fs.path.dirname(file1_path)) |dirname| {
122 try std.fs.makePath(allocator, dirname);122 try std.fs.makePath(allocator, dirname);
123 }123 }
...@@ -214,21 +214,20 @@ pub const TestContext = struct {...@@ -214,21 +214,20 @@ pub const TestContext = struct {
214 }214 }
215 }215 }
216 }216 }
217 std.debug.warn(217 std.debug.warn("\n=====source:=======\n{}\n====expected:========\n{}:{}:{}: error: {}\n", .{
218 "\n=====source:=======\n{}\n====expected:========\n{}:{}:{}: error: {}\n",
219 source,218 source,
220 path,219 path,
221 line,220 line,
222 column,221 column,
223 text,222 text,
224 );223 });
225 std.debug.warn("\n====found:========\n");224 std.debug.warn("\n====found:========\n", .{});
226 const stderr = std.io.getStdErr();225 const stderr = std.io.getStdErr();
227 for (msgs) |msg| {226 for (msgs) |msg| {
228 defer msg.destroy();227 defer msg.destroy();
229 try msg.printToFile(stderr, errmsg.Color.Auto);228 try msg.printToFile(stderr, errmsg.Color.Auto);
230 }229 }
231 std.debug.warn("============\n");230 std.debug.warn("============\n", .{});
232 return error.TestFailed;231 return error.TestFailed;
233 },232 },
234 }233 }
src-self-hosted/translate_c.zig+2-2
...@@ -330,11 +330,11 @@ pub fn translate(...@@ -330,11 +330,11 @@ pub fn translate(
330 tree.root_node.eof_token = try appendToken(&context, .Eof, "");330 tree.root_node.eof_token = try appendToken(&context, .Eof, "");
331 tree.source = source_buffer.toOwnedSlice();331 tree.source = source_buffer.toOwnedSlice();
332 if (false) {332 if (false) {
333 std.debug.warn("debug source:\n{}\n==EOF==\ntokens:\n", tree.source);333 std.debug.warn("debug source:\n{}\n==EOF==\ntokens:\n", .{tree.source});
334 var i: usize = 0;334 var i: usize = 0;
335 while (i < tree.tokens.len) : (i += 1) {335 while (i < tree.tokens.len) : (i += 1) {
336 const token = tree.tokens.at(i);336 const token = tree.tokens.at(i);
337 std.debug.warn("{}\n", token);337 std.debug.warn("{}\n", .{token});
338 }338 }
339 }339 }
340 return tree;340 return tree;
src-self-hosted/type.zig+1-1
...@@ -162,7 +162,7 @@ pub const Type = struct {...@@ -162,7 +162,7 @@ pub const Type = struct {
162 }162 }
163163
164 pub fn dump(base: *const Type) void {164 pub fn dump(base: *const Type) void {
165 std.debug.warn("{}", @tagName(base.id));165 std.debug.warn("{}", .{@tagName(base.id)});
166 }166 }
167167
168 fn init(base: *Type, comp: *Compilation, id: Id, name: []const u8) void {168 fn init(base: *Type, comp: *Compilation, id: Id, name: []const u8) void {
tools/process_headers.zig+17-20
...@@ -270,7 +270,7 @@ pub fn main() !void {...@@ -270,7 +270,7 @@ pub fn main() !void {
270 if (std.mem.eql(u8, args[arg_i], "--help"))270 if (std.mem.eql(u8, args[arg_i], "--help"))
271 usageAndExit(args[0]);271 usageAndExit(args[0]);
272 if (arg_i + 1 >= args.len) {272 if (arg_i + 1 >= args.len) {
273 std.debug.warn("expected argument after '{}'\n", args[arg_i]);273 std.debug.warn("expected argument after '{}'\n", .{args[arg_i]});
274 usageAndExit(args[0]);274 usageAndExit(args[0]);
275 }275 }
276276
...@@ -283,7 +283,7 @@ pub fn main() !void {...@@ -283,7 +283,7 @@ pub fn main() !void {
283 assert(opt_abi == null);283 assert(opt_abi == null);
284 opt_abi = args[arg_i + 1];284 opt_abi = args[arg_i + 1];
285 } else {285 } else {
286 std.debug.warn("unrecognized argument: {}\n", args[arg_i]);286 std.debug.warn("unrecognized argument: {}\n", .{args[arg_i]});
287 usageAndExit(args[0]);287 usageAndExit(args[0]);
288 }288 }
289289
...@@ -297,10 +297,10 @@ pub fn main() !void {...@@ -297,10 +297,10 @@ pub fn main() !void {
297 else if (std.mem.eql(u8, abi_name, "glibc"))297 else if (std.mem.eql(u8, abi_name, "glibc"))
298 LibCVendor.glibc298 LibCVendor.glibc
299 else {299 else {
300 std.debug.warn("unrecognized C ABI: {}\n", abi_name);300 std.debug.warn("unrecognized C ABI: {}\n", .{abi_name});
301 usageAndExit(args[0]);301 usageAndExit(args[0]);
302 };302 };
303 const generic_name = try std.fmt.allocPrint(allocator, "generic-{}", abi_name);303 const generic_name = try std.fmt.allocPrint(allocator, "generic-{}", .{abi_name});
304304
305 // TODO compiler crashed when I wrote this the canonical way305 // TODO compiler crashed when I wrote this the canonical way
306 var libc_targets: []const LibCTarget = undefined;306 var libc_targets: []const LibCTarget = undefined;
...@@ -365,12 +365,11 @@ pub fn main() !void {...@@ -365,12 +365,11 @@ pub fn main() !void {
365 if (gop.found_existing) {365 if (gop.found_existing) {
366 max_bytes_saved += raw_bytes.len;366 max_bytes_saved += raw_bytes.len;
367 gop.kv.value.hit_count += 1;367 gop.kv.value.hit_count += 1;
368 std.debug.warn(368 std.debug.warn("duplicate: {} {} ({Bi:2})\n", .{
369 "duplicate: {} {} ({Bi:2})\n",
370 libc_target.name,369 libc_target.name,
371 rel_path,370 rel_path,
372 raw_bytes.len,371 raw_bytes.len,
373 );372 });
374 } else {373 } else {
375 gop.kv.value = Contents{374 gop.kv.value = Contents{
376 .bytes = trimmed,375 .bytes = trimmed,
...@@ -388,16 +387,16 @@ pub fn main() !void {...@@ -388,16 +387,16 @@ pub fn main() !void {
388 };387 };
389 assert((try target_to_hash.put(dest_target, hash)) == null);388 assert((try target_to_hash.put(dest_target, hash)) == null);
390 },389 },
391 else => std.debug.warn("warning: weird file: {}\n", full_path),390 else => std.debug.warn("warning: weird file: {}\n", .{full_path}),
392 }391 }
393 }392 }
394 }393 }
395 break;394 break;
396 } else {395 } else {
397 std.debug.warn("warning: libc target not found: {}\n", libc_target.name);396 std.debug.warn("warning: libc target not found: {}\n", .{libc_target.name});
398 }397 }
399 }398 }
400 std.debug.warn("summary: {Bi:2} could be reduced to {Bi:2}\n", total_bytes, total_bytes - max_bytes_saved);399 std.debug.warn("summary: {Bi:2} could be reduced to {Bi:2}\n", .{total_bytes, total_bytes - max_bytes_saved});
401 try std.fs.makePath(allocator, out_dir);400 try std.fs.makePath(allocator, out_dir);
402401
403 var missed_opportunity_bytes: usize = 0;402 var missed_opportunity_bytes: usize = 0;
...@@ -426,7 +425,7 @@ pub fn main() !void {...@@ -426,7 +425,7 @@ pub fn main() !void {
426 if (contender.hit_count > 1) {425 if (contender.hit_count > 1) {
427 const this_missed_bytes = contender.hit_count * contender.bytes.len;426 const this_missed_bytes = contender.hit_count * contender.bytes.len;
428 missed_opportunity_bytes += this_missed_bytes;427 missed_opportunity_bytes += this_missed_bytes;
429 std.debug.warn("Missed opportunity ({Bi:2}): {}\n", this_missed_bytes, path_kv.key);428 std.debug.warn("Missed opportunity ({Bi:2}): {}\n", .{this_missed_bytes, path_kv.key});
430 } else break;429 } else break;
431 }430 }
432 }431 }
...@@ -440,13 +439,11 @@ pub fn main() !void {...@@ -440,13 +439,11 @@ pub fn main() !void {
440 .specific => |a| @tagName(a),439 .specific => |a| @tagName(a),
441 else => @tagName(dest_target.arch),440 else => @tagName(dest_target.arch),
442 };441 };
443 const out_subpath = try std.fmt.allocPrint(442 const out_subpath = try std.fmt.allocPrint(allocator, "{}-{}-{}", .{
444 allocator,
445 "{}-{}-{}",
446 arch_name,443 arch_name,
447 @tagName(dest_target.os),444 @tagName(dest_target.os),
448 @tagName(dest_target.abi),445 @tagName(dest_target.abi),
449 );446 });
450 const full_path = try std.fs.path.join(allocator, [_][]const u8{ out_dir, out_subpath, path_kv.key });447 const full_path = try std.fs.path.join(allocator, [_][]const u8{ out_dir, out_subpath, path_kv.key });
451 try std.fs.makePath(allocator, std.fs.path.dirname(full_path).?);448 try std.fs.makePath(allocator, std.fs.path.dirname(full_path).?);
452 try std.io.writeFile(full_path, contents.bytes);449 try std.io.writeFile(full_path, contents.bytes);
...@@ -455,10 +452,10 @@ pub fn main() !void {...@@ -455,10 +452,10 @@ pub fn main() !void {
455}452}
456453
457fn usageAndExit(arg0: []const u8) noreturn {454fn usageAndExit(arg0: []const u8) noreturn {
458 std.debug.warn("Usage: {} [--search-path <dir>] --out <dir> --abi <name>\n", arg0);455 std.debug.warn("Usage: {} [--search-path <dir>] --out <dir> --abi <name>\n", .{arg0});
459 std.debug.warn("--search-path can be used any number of times.\n");456 std.debug.warn("--search-path can be used any number of times.\n", .{});
460 std.debug.warn(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n");457 std.debug.warn(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{});
461 std.debug.warn("--out is a dir that will be created, and populated with the results\n");458 std.debug.warn("--out is a dir that will be created, and populated with the results\n", .{});
462 std.debug.warn("--abi is either musl or glibc\n");459 std.debug.warn("--abi is either musl or glibc\n", .{});
463 std.process.exit(1);460 std.process.exit(1);
464}461}
tools/update_glibc.zig+6-6
...@@ -155,7 +155,7 @@ pub fn main() !void {...@@ -155,7 +155,7 @@ pub fn main() !void {
155 const fn_set = &target_funcs_gop.kv.value.list;155 const fn_set = &target_funcs_gop.kv.value.list;
156156
157 for (lib_names) |lib_name, lib_name_index| {157 for (lib_names) |lib_name, lib_name_index| {
158 const basename = try fmt.allocPrint(allocator, "lib{}.abilist", lib_name);158 const basename = try fmt.allocPrint(allocator, "lib{}.abilist", .{lib_name});
159 const abi_list_filename = blk: {159 const abi_list_filename = blk: {
160 if (abi_list.targets[0].abi == .gnuabi64 and std.mem.eql(u8, lib_name, "c")) {160 if (abi_list.targets[0].abi == .gnuabi64 and std.mem.eql(u8, lib_name, "c")) {
161 break :blk try fs.path.join(allocator, [_][]const u8{ prefix, abi_list.path, "n64", basename });161 break :blk try fs.path.join(allocator, [_][]const u8{ prefix, abi_list.path, "n64", basename });
...@@ -177,7 +177,7 @@ pub fn main() !void {...@@ -177,7 +177,7 @@ pub fn main() !void {
177 break :blk try fs.path.join(allocator, [_][]const u8{ prefix, abi_list.path, basename });177 break :blk try fs.path.join(allocator, [_][]const u8{ prefix, abi_list.path, basename });
178 };178 };
179 const contents = std.io.readFileAlloc(allocator, abi_list_filename) catch |err| {179 const contents = std.io.readFileAlloc(allocator, abi_list_filename) catch |err| {
180 std.debug.warn("unable to open {}: {}\n", abi_list_filename, err);180 std.debug.warn("unable to open {}: {}\n", .{abi_list_filename, err});
181 std.process.exit(1);181 std.process.exit(1);
182 };182 };
183 var lines_it = std.mem.tokenize(contents, "\n");183 var lines_it = std.mem.tokenize(contents, "\n");
...@@ -235,7 +235,7 @@ pub fn main() !void {...@@ -235,7 +235,7 @@ pub fn main() !void {
235 const vers_txt = &buffered.stream;235 const vers_txt = &buffered.stream;
236 for (global_ver_list) |name, i| {236 for (global_ver_list) |name, i| {
237 _ = global_ver_set.put(name, i) catch unreachable;237 _ = global_ver_set.put(name, i) catch unreachable;
238 try vers_txt.print("{}\n", name);238 try vers_txt.print("{}\n", .{name});
239 }239 }
240 try buffered.flush();240 try buffered.flush();
241 }241 }
...@@ -248,7 +248,7 @@ pub fn main() !void {...@@ -248,7 +248,7 @@ pub fn main() !void {
248 for (global_fn_list) |name, i| {248 for (global_fn_list) |name, i| {
249 const kv = global_fn_set.get(name).?;249 const kv = global_fn_set.get(name).?;
250 kv.value.index = i;250 kv.value.index = i;
251 try fns_txt.print("{} {}\n", name, kv.value.lib);251 try fns_txt.print("{} {}\n", .{name, kv.value.lib});
252 }252 }
253 try buffered.flush();253 try buffered.flush();
254 }254 }
...@@ -282,7 +282,7 @@ pub fn main() !void {...@@ -282,7 +282,7 @@ pub fn main() !void {
282 const fn_vers_list = &target_functions.get(@ptrToInt(abi_list)).?.value.fn_vers_list;282 const fn_vers_list = &target_functions.get(@ptrToInt(abi_list)).?.value.fn_vers_list;
283 for (abi_list.targets) |target, it_i| {283 for (abi_list.targets) |target, it_i| {
284 if (it_i != 0) try abilist_txt.writeByte(' ');284 if (it_i != 0) try abilist_txt.writeByte(' ');
285 try abilist_txt.print("{}-linux-{}", @tagName(target.arch), @tagName(target.abi));285 try abilist_txt.print("{}-linux-{}", .{@tagName(target.arch), @tagName(target.abi)});
286 }286 }
287 try abilist_txt.writeByte('\n');287 try abilist_txt.writeByte('\n');
288 // next, each line implicitly corresponds to a function288 // next, each line implicitly corresponds to a function
...@@ -293,7 +293,7 @@ pub fn main() !void {...@@ -293,7 +293,7 @@ pub fn main() !void {
293 };293 };
294 for (kv.value.toSliceConst()) |ver_index, it_i| {294 for (kv.value.toSliceConst()) |ver_index, it_i| {
295 if (it_i != 0) try abilist_txt.writeByte(' ');295 if (it_i != 0) try abilist_txt.writeByte(' ');
296 try abilist_txt.print("{d}", ver_index);296 try abilist_txt.print("{d}", .{ver_index});
297 }297 }
298 try abilist_txt.writeByte('\n');298 try abilist_txt.writeByte('\n');
299 }299 }