aboutsummaryrefslogtreecommitdiff
path: root/lib/std/special
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-12-08 22:53:51 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-12-08 22:53:51 -0500
commit8b2622cdd58cec697d9d1f8f49717b6ce7ee3e2e (patch)
tree3de817be4757dd1ad0bbdc0c7c3f863deb0f1d43 /lib/std/special
parent5874cb04bd544ca155d1489bb0bdf9397fa3b41c (diff)
downloadzig-8b2622cdd58cec697d9d1f8f49717b6ce7ee3e2e.tar.gz
zig-8b2622cdd58cec697d9d1f8f49717b6ce7ee3e2e.zip
std.fmt.format: tuple parameter instead of var args
Diffstat (limited to 'lib/std/special')
-rw-r--r--lib/std/special/build_runner.zig33
-rw-r--r--lib/std/special/init-exe/src/main.zig2
-rw-r--r--lib/std/special/start.zig4
-rw-r--r--lib/std/special/test_runner.zig14
4 files changed, 28 insertions, 25 deletions
diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig
index 27d3283a3c..03d1e8fe1d 100644
--- a/lib/std/special/build_runner.zig
+++ b/lib/std/special/build_runner.zig
@@ -26,15 +26,15 @@ pub fn main() !void {
_ = arg_it.skip();
const zig_exe = try unwrapArg(arg_it.next(allocator) orelse {
- warn("Expected first argument to be path to zig compiler\n");
+ warn("Expected first argument to be path to zig compiler\n", .{});
return error.InvalidArgs;
});
const build_root = try unwrapArg(arg_it.next(allocator) orelse {
- warn("Expected second argument to be build root directory path\n");
+ warn("Expected second argument to be build root directory path\n", .{});
return error.InvalidArgs;
});
const cache_root = try unwrapArg(arg_it.next(allocator) orelse {
- warn("Expected third argument to be cache root directory path\n");
+ warn("Expected third argument to be cache root directory path\n", .{});
return error.InvalidArgs;
});
@@ -51,7 +51,7 @@ pub fn main() !void {
if (mem.startsWith(u8, arg, "-D")) {
const option_contents = arg[2..];
if (option_contents.len == 0) {
- warn("Expected option name after '-D'\n\n");
+ warn("Expected option name after '-D'\n\n", .{});
return usageAndErr(builder, false, stderr_stream);
}
if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {
@@ -70,18 +70,18 @@ pub fn main() !void {
return usage(builder, false, stdout_stream);
} else if (mem.eql(u8, arg, "--prefix")) {
builder.install_prefix = try unwrapArg(arg_it.next(allocator) orelse {
- warn("Expected argument after --prefix\n\n");
+ warn("Expected argument after --prefix\n\n", .{});
return usageAndErr(builder, false, stderr_stream);
});
} else if (mem.eql(u8, arg, "--search-prefix")) {
const search_prefix = try unwrapArg(arg_it.next(allocator) orelse {
- warn("Expected argument after --search-prefix\n\n");
+ warn("Expected argument after --search-prefix\n\n", .{});
return usageAndErr(builder, false, stderr_stream);
});
builder.addSearchPrefix(search_prefix);
} else if (mem.eql(u8, arg, "--override-lib-dir")) {
builder.override_lib_dir = try unwrapArg(arg_it.next(allocator) orelse {
- warn("Expected argument after --override-lib-dir\n\n");
+ warn("Expected argument after --override-lib-dir\n\n", .{});
return usageAndErr(builder, false, stderr_stream);
});
} else if (mem.eql(u8, arg, "--verbose-tokenize")) {
@@ -99,7 +99,7 @@ pub fn main() !void {
} else if (mem.eql(u8, arg, "--verbose-cc")) {
builder.verbose_cc = true;
} else {
- warn("Unrecognized argument: {}\n\n", arg);
+ warn("Unrecognized argument: {}\n\n", .{arg});
return usageAndErr(builder, false, stderr_stream);
}
} else {
@@ -145,15 +145,15 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
\\
\\Steps:
\\
- , builder.zig_exe);
+ , .{builder.zig_exe});
const allocator = builder.allocator;
for (builder.top_level_steps.toSliceConst()) |top_level_step| {
const name = if (&top_level_step.step == builder.default_step)
- try fmt.allocPrint(allocator, "{} (default)", top_level_step.step.name)
+ try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
else
top_level_step.step.name;
- try out_stream.print(" {s:22} {}\n", name, top_level_step.description);
+ try out_stream.print(" {s:22} {}\n", .{ name, top_level_step.description });
}
try out_stream.write(
@@ -169,12 +169,15 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
);
if (builder.available_options_list.len == 0) {
- try out_stream.print(" (none)\n");
+ try out_stream.print(" (none)\n", .{});
} else {
for (builder.available_options_list.toSliceConst()) |option| {
- const name = try fmt.allocPrint(allocator, " -D{}=[{}]", option.name, Builder.typeIdName(option.type_id));
+ const name = try fmt.allocPrint(allocator, " -D{}=[{}]", .{
+ option.name,
+ Builder.typeIdName(option.type_id),
+ });
defer allocator.free(name);
- try out_stream.print("{s:24} {}\n", name, option.description);
+ try out_stream.print("{s:24} {}\n", .{ name, option.description });
}
}
@@ -204,7 +207,7 @@ const UnwrapArgError = error{OutOfMemory};
fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 {
return arg catch |err| {
- warn("Unable to parse command line: {}\n", err);
+ warn("Unable to parse command line: {}\n", .{err});
return err;
};
}
diff --git a/lib/std/special/init-exe/src/main.zig b/lib/std/special/init-exe/src/main.zig
index 128820d3ee..5f35540dc0 100644
--- a/lib/std/special/init-exe/src/main.zig
+++ b/lib/std/special/init-exe/src/main.zig
@@ -1,5 +1,5 @@
const std = @import("std");
pub fn main() anyerror!void {
- std.debug.warn("All your base are belong to us.\n");
+ std.debug.warn("All your base are belong to us.\n", .{});
}
diff --git a/lib/std/special/start.zig b/lib/std/special/start.zig
index d6c6350ff4..b5e4e2edab 100644
--- a/lib/std/special/start.zig
+++ b/lib/std/special/start.zig
@@ -217,7 +217,7 @@ inline fn initEventLoopAndCallMain() u8 {
if (std.event.Loop.instance) |loop| {
if (!@hasDecl(root, "event_loop")) {
loop.init() catch |err| {
- std.debug.warn("error: {}\n", @errorName(err));
+ std.debug.warn("error: {}\n", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace.*);
}
@@ -264,7 +264,7 @@ fn callMain() u8 {
},
.ErrorUnion => {
const result = root.main() catch |err| {
- std.debug.warn("error: {}\n", @errorName(err));
+ std.debug.warn("error: {}\n", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace.*);
}
diff --git a/lib/std/special/test_runner.zig b/lib/std/special/test_runner.zig
index 4dc8be0fec..7bb53774d3 100644
--- a/lib/std/special/test_runner.zig
+++ b/lib/std/special/test_runner.zig
@@ -16,28 +16,28 @@ pub fn main() anyerror!void {
var test_node = root_node.start(test_fn.name, null);
test_node.activate();
progress.refresh();
- if (progress.terminal == null) std.debug.warn("{}/{} {}...", i + 1, test_fn_list.len, test_fn.name);
+ if (progress.terminal == null) std.debug.warn("{}/{} {}...", .{ i + 1, test_fn_list.len, test_fn.name });
if (test_fn.func()) |_| {
ok_count += 1;
test_node.end();
- if (progress.terminal == null) std.debug.warn("OK\n");
+ if (progress.terminal == null) std.debug.warn("OK\n", .{});
} else |err| switch (err) {
error.SkipZigTest => {
skip_count += 1;
test_node.end();
- progress.log("{}...SKIP\n", test_fn.name);
- if (progress.terminal == null) std.debug.warn("SKIP\n");
+ progress.log("{}...SKIP\n", .{test_fn.name});
+ if (progress.terminal == null) std.debug.warn("SKIP\n", .{});
},
else => {
- progress.log("");
+ progress.log("", .{});
return err;
},
}
}
root_node.end();
if (ok_count == test_fn_list.len) {
- std.debug.warn("All {} tests passed.\n", ok_count);
+ std.debug.warn("All {} tests passed.\n", .{ok_count});
} else {
- std.debug.warn("{} passed; {} skipped.\n", ok_count, skip_count);
+ std.debug.warn("{} passed; {} skipped.\n", .{ ok_count, skip_count });
}
}