authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-03-06 09:47:42-06:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2020-03-12 10:41:09-05:00
log0059d9ee3e7298df03723d97adbea72ff142cacd
treed88f0722a4cf79afdf374189098bbf753f17cee2
parent4023ed56d4fd7b627aed73428b5fa4be4b7c05ad

Convert fmt.bufPrint / fmt.allocPrint


21 files changed, 56 insertions(+), 56 deletions(-)

lib/std/atomic/queue.zig+2-2
...@@ -348,7 +348,7 @@ test "std.atomic.Queue dump" {...@@ -348,7 +348,7 @@ test "std.atomic.Queue dump" {
348 fbs.reset();348 fbs.reset();
349 try queue.dumpToStream(fbs.outStream());349 try queue.dumpToStream(fbs.outStream());
350350
351 var expected = try std.fmt.bufPrint(expected_buffer[0..],351 var expected = try std.fmtstream.bufPrint(expected_buffer[0..],
352 \\head: 0x{x}=1352 \\head: 0x{x}=1
353 \\ (null)353 \\ (null)
354 \\tail: 0x{x}=1354 \\tail: 0x{x}=1
...@@ -368,7 +368,7 @@ test "std.atomic.Queue dump" {...@@ -368,7 +368,7 @@ test "std.atomic.Queue dump" {
368 fbs.reset();368 fbs.reset();
369 try queue.dumpToStream(fbs.outStream());369 try queue.dumpToStream(fbs.outStream());
370370
371 expected = try std.fmt.bufPrint(expected_buffer[0..],371 expected = try std.fmtstream.bufPrint(expected_buffer[0..],
372 \\head: 0x{x}=1372 \\head: 0x{x}=1
373 \\ 0x{x}=2373 \\ 0x{x}=2
374 \\ (null)374 \\ (null)
lib/std/net.zig+1-1
...@@ -438,7 +438,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*...@@ -438,7 +438,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
438 const name_c = try std.cstr.addNullByte(allocator, name);438 const name_c = try std.cstr.addNullByte(allocator, name);
439 defer allocator.free(name_c);439 defer allocator.free(name_c);
440440
441 const port_c = try std.fmt.allocPrint(allocator, "{}\x00", .{port});441 const port_c = try std.fmtstream.allocPrint(allocator, "{}\x00", .{port});
442 defer allocator.free(port_c);442 defer allocator.free(port_c);
443443
444 const hints = os.addrinfo{444 const hints = os.addrinfo{
lib/std/os.zig+1-1
...@@ -3049,7 +3049,7 @@ pub fn realpathC(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP...@@ -3049,7 +3049,7 @@ pub fn realpathC(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
3049 defer close(fd);3049 defer close(fd);
30503050
3051 var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;3051 var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
3052 const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;3052 const proc_path = std.fmtstream.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
30533053
3054 return readlinkC(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer);3054 return readlinkC(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer);
3055 }3055 }
lib/std/progress.zig+3-3
...@@ -130,11 +130,11 @@ pub const Progress = struct {...@@ -130,11 +130,11 @@ pub const Progress = struct {
130 var end: usize = 0;130 var end: usize = 0;
131 if (self.columns_written > 0) {131 if (self.columns_written > 0) {
132 // restore cursor position132 // restore cursor position
133 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;133 end += (std.fmtstream.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;
134 self.columns_written = 0;134 self.columns_written = 0;
135135
136 // clear rest of line136 // clear rest of line
137 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;137 end += (std.fmtstream.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
138 }138 }
139139
140 if (!self.done) {140 if (!self.done) {
...@@ -185,7 +185,7 @@ pub const Progress = struct {...@@ -185,7 +185,7 @@ pub const Progress = struct {
185 }185 }
186186
187 fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: var) void {187 fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: var) void {
188 if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| {188 if (std.fmtstream.bufPrint(self.output_buffer[end.*..], format, args)) |written| {
189 const amt = written.len;189 const amt = written.len;
190 end.* += amt;190 end.* += amt;
191 self.columns_written += amt;191 self.columns_written += amt;
lib/std/special/build_runner.zig+3-3
...@@ -2,7 +2,7 @@ const root = @import("@build");...@@ -2,7 +2,7 @@ const root = @import("@build");
2const std = @import("std");2const std = @import("std");
3const builtin = @import("builtin");3const builtin = @import("builtin");
4const io = std.io;4const io = std.io;
5const fmt = std.fmt;5const fmtstream = std.fmtstream;
6const Builder = std.build.Builder;6const Builder = std.build.Builder;
7const mem = std.mem;7const mem = std.mem;
8const process = std.process;8const process = std.process;
...@@ -153,7 +153,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {...@@ -153,7 +153,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
153 const allocator = builder.allocator;153 const allocator = builder.allocator;
154 for (builder.top_level_steps.toSliceConst()) |top_level_step| {154 for (builder.top_level_steps.toSliceConst()) |top_level_step| {
155 const name = if (&top_level_step.step == builder.default_step)155 const name = if (&top_level_step.step == builder.default_step)
156 try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})156 try fmtstream.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
157 else157 else
158 top_level_step.step.name;158 top_level_step.step.name;
159 try out_stream.print(" {s:22} {}\n", .{ name, top_level_step.description });159 try out_stream.print(" {s:22} {}\n", .{ name, top_level_step.description });
...@@ -175,7 +175,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {...@@ -175,7 +175,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
175 try out_stream.print(" (none)\n", .{});175 try out_stream.print(" (none)\n", .{});
176 } else {176 } else {
177 for (builder.available_options_list.toSliceConst()) |option| {177 for (builder.available_options_list.toSliceConst()) |option| {
178 const name = try fmt.allocPrint(allocator, " -D{}=[{}]", .{178 const name = try fmtstream.allocPrint(allocator, " -D{}=[{}]", .{
179 option.name,179 option.name,
180 Builder.typeIdName(option.type_id),180 Builder.typeIdName(option.type_id),
181 });181 });
lib/std/target.zig+2-2
...@@ -972,7 +972,7 @@ pub const Target = struct {...@@ -972,7 +972,7 @@ pub const Target = struct {
972 }972 }
973973
974 pub fn linuxTripleSimple(allocator: *mem.Allocator, cpu_arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![:0]u8 {974 pub fn linuxTripleSimple(allocator: *mem.Allocator, cpu_arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![:0]u8 {
975 return std.fmt.allocPrint0(allocator, "{}-{}-{}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) });975 return std.fmtstream.allocPrint0(allocator, "{}-{}-{}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) });
976 }976 }
977977
978 pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![:0]u8 {978 pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![:0]u8 {
...@@ -1158,7 +1158,7 @@ pub const Target = struct {...@@ -1158,7 +1158,7 @@ pub const Target = struct {
1158 var result: DynamicLinker = .{};1158 var result: DynamicLinker = .{};
1159 const S = struct {1159 const S = struct {
1160 fn print(r: *DynamicLinker, comptime fmt: []const u8, args: var) DynamicLinker {1160 fn print(r: *DynamicLinker, comptime fmt: []const u8, args: var) DynamicLinker {
1161 r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);1161 r.max_byte = @intCast(u8, (std.fmtstream.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);
1162 return r.*;1162 return r.*;
1163 }1163 }
1164 fn copy(r: *DynamicLinker, s: []const u8) DynamicLinker {1164 fn copy(r: *DynamicLinker, s: []const u8) DynamicLinker {
lib/std/zig/cross_target.zig+1-1
...@@ -573,7 +573,7 @@ pub const CrossTarget = struct {...@@ -573,7 +573,7 @@ pub const CrossTarget = struct {
573 .Dynamic => "",573 .Dynamic => "",
574 };574 };
575575
576 return std.fmt.allocPrint0(allocator, "{}-{}{}", .{ arch, os, static_suffix });576 return std.fmtstream.allocPrint0(allocator, "{}-{}{}", .{ arch, os, static_suffix });
577 }577 }
578578
579 pub const Executor = union(enum) {579 pub const Executor = union(enum) {
lib/std/zig/system.zig+3-3
...@@ -130,7 +130,7 @@ pub const NativePaths = struct {...@@ -130,7 +130,7 @@ pub const NativePaths = struct {
130 }130 }
131131
132 pub fn addIncludeDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {132 pub fn addIncludeDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
133 const item = try std.fmt.allocPrint0(self.include_dirs.allocator, fmt, args);133 const item = try std.fmtstream.allocPrint0(self.include_dirs.allocator, fmt, args);
134 errdefer self.include_dirs.allocator.free(item);134 errdefer self.include_dirs.allocator.free(item);
135 try self.include_dirs.append(item);135 try self.include_dirs.append(item);
136 }136 }
...@@ -140,7 +140,7 @@ pub const NativePaths = struct {...@@ -140,7 +140,7 @@ pub const NativePaths = struct {
140 }140 }
141141
142 pub fn addLibDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {142 pub fn addLibDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
143 const item = try std.fmt.allocPrint0(self.lib_dirs.allocator, fmt, args);143 const item = try std.fmtstream.allocPrint0(self.lib_dirs.allocator, fmt, args);
144 errdefer self.lib_dirs.allocator.free(item);144 errdefer self.lib_dirs.allocator.free(item);
145 try self.lib_dirs.append(item);145 try self.lib_dirs.append(item);
146 }146 }
...@@ -150,7 +150,7 @@ pub const NativePaths = struct {...@@ -150,7 +150,7 @@ pub const NativePaths = struct {
150 }150 }
151151
152 pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {152 pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
153 const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args);153 const item = try std.fmtstream.allocPrint0(self.warnings.allocator, fmt, args);
154 errdefer self.warnings.allocator.free(item);154 errdefer self.warnings.allocator.free(item);
155 try self.warnings.append(item);155 try self.warnings.append(item);
156 }156 }
src-self-hosted/compilation.zig+3-3
...@@ -1051,7 +1051,7 @@ pub const Compilation = struct {...@@ -1051,7 +1051,7 @@ pub const Compilation = struct {
1051 }1051 }
10521052
1053 fn addCompileError(self: *Compilation, tree_scope: *Scope.AstTree, span: Span, comptime fmt: []const u8, args: var) !void {1053 fn addCompileError(self: *Compilation, tree_scope: *Scope.AstTree, span: Span, comptime fmt: []const u8, args: var) !void {
1054 const text = try std.fmt.allocPrint(self.gpa(), fmt, args);1054 const text = try std.fmtstream.allocPrint(self.gpa(), fmt, args);
1055 errdefer self.gpa().free(text);1055 errdefer self.gpa().free(text);
10561056
1057 const msg = try Msg.createFromScope(self, tree_scope, span, text);1057 const msg = try Msg.createFromScope(self, tree_scope, span, text);
...@@ -1061,7 +1061,7 @@ pub const Compilation = struct {...@@ -1061,7 +1061,7 @@ pub const Compilation = struct {
1061 }1061 }
10621062
1063 fn addCompileErrorCli(self: *Compilation, realpath: []const u8, comptime fmt: []const u8, args: var) !void {1063 fn addCompileErrorCli(self: *Compilation, realpath: []const u8, comptime fmt: []const u8, args: var) !void {
1064 const text = try std.fmt.allocPrint(self.gpa(), fmt, args);1064 const text = try std.fmtstream.allocPrint(self.gpa(), fmt, args);
1065 errdefer self.gpa().free(text);1065 errdefer self.gpa().free(text);
10661066
1067 const msg = try Msg.createFromCli(self, realpath, text);1067 const msg = try Msg.createFromCli(self, realpath, text);
...@@ -1154,7 +1154,7 @@ pub const Compilation = struct {...@@ -1154,7 +1154,7 @@ pub const Compilation = struct {
1154 const tmp_dir = try self.getTmpDir();1154 const tmp_dir = try self.getTmpDir();
1155 const file_prefix = self.getRandomFileName();1155 const file_prefix = self.getRandomFileName();
11561156
1157 const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix });1157 const file_name = try std.fmtstream.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix });
1158 defer self.gpa().free(file_name);1158 defer self.gpa().free(file_name);
11591159
1160 const full_path = try fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] });1160 const full_path = try fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] });
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.fmtstream.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/libc_installation.zig+1-1
...@@ -543,7 +543,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {...@@ -543,7 +543,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 {
543 const allocator = args.allocator;543 const allocator = args.allocator;
544544
545 const cc_exe = std.os.getenvZ("CC") orelse default_cc_exe;545 const cc_exe = std.os.getenvZ("CC") orelse default_cc_exe;
546 const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={}", .{args.search_basename});546 const arg1 = try std.fmtstream.allocPrint(allocator, "-print-file-name={}", .{args.search_basename});
547 defer allocator.free(arg1);547 defer allocator.free(arg1);
548 const argv = [_][]const u8{ cc_exe, arg1 };548 const argv = [_][]const u8{ cc_exe, arg1 };
549549
src-self-hosted/link.zig+10-10
...@@ -296,13 +296,13 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {...@@ -296,13 +296,13 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {
296296
297 const is_library = ctx.comp.kind == .Lib;297 const is_library = ctx.comp.kind == .Lib;
298298
299 const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});299 const out_arg = try std.fmtstream.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});
300 try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr));300 try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr));
301301
302 if (ctx.comp.haveLibC()) {302 if (ctx.comp.haveLibC()) {
303 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.msvc_lib_dir.?})).ptr));303 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmtstream.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.msvc_lib_dir.?})).ptr));
304 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.kernel32_lib_dir.?})).ptr));304 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmtstream.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.kernel32_lib_dir.?})).ptr));
305 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.lib_dir.?})).ptr));305 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmtstream.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.lib_dir.?})).ptr));
306 }306 }
307307
308 if (ctx.link_in_crt) {308 if (ctx.link_in_crt) {
...@@ -310,20 +310,20 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {...@@ -310,20 +310,20 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {
310 const d_str = if (ctx.comp.build_mode == .Debug) "d" else "";310 const d_str = if (ctx.comp.build_mode == .Debug) "d" else "";
311311
312 if (ctx.comp.is_static) {312 if (ctx.comp.is_static) {
313 const cmt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str});313 const cmt_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str});
314 try ctx.args.append(@ptrCast([*:0]const u8, cmt_lib_name.ptr));314 try ctx.args.append(@ptrCast([*:0]const u8, cmt_lib_name.ptr));
315 } else {315 } else {
316 const msvcrt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str});316 const msvcrt_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str});
317 try ctx.args.append(@ptrCast([*:0]const u8, msvcrt_lib_name.ptr));317 try ctx.args.append(@ptrCast([*:0]const u8, msvcrt_lib_name.ptr));
318 }318 }
319319
320 const vcruntime_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{320 const vcruntime_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{
321 lib_str,321 lib_str,
322 d_str,322 d_str,
323 });323 });
324 try ctx.args.append(@ptrCast([*:0]const u8, vcruntime_lib_name.ptr));324 try ctx.args.append(@ptrCast([*:0]const u8, vcruntime_lib_name.ptr));
325325
326 const crt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str });326 const crt_lib_name = try std.fmtstream.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str });
327 try ctx.args.append(@ptrCast([*:0]const u8, crt_lib_name.ptr));327 try ctx.args.append(@ptrCast([*:0]const u8, crt_lib_name.ptr));
328328
329 // Visual C++ 2015 Conformance Changes329 // Visual C++ 2015 Conformance Changes
...@@ -383,7 +383,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {...@@ -383,7 +383,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
383 .IPhoneOS => try ctx.args.append("-iphoneos_version_min"),383 .IPhoneOS => try ctx.args.append("-iphoneos_version_min"),
384 .IPhoneOSSimulator => try ctx.args.append("-ios_simulator_version_min"),384 .IPhoneOSSimulator => try ctx.args.append("-ios_simulator_version_min"),
385 }385 }
386 const ver_str = try std.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{386 const ver_str = try std.fmtstream.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{
387 platform.major,387 platform.major,
388 platform.minor,388 platform.minor,
389 platform.micro,389 platform.micro,
...@@ -445,7 +445,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {...@@ -445,7 +445,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
445 try ctx.args.append("-lSystem");445 try ctx.args.append("-lSystem");
446 } else {446 } else {
447 if (mem.indexOfScalar(u8, lib.name, '/') == null) {447 if (mem.indexOfScalar(u8, lib.name, '/') == null) {
448 const arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name});448 const arg = try std.fmtstream.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name});
449 try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr));449 try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr));
450 } else {450 } else {
451 const arg = try std.cstr.addNullByte(&ctx.arena.allocator, lib.name);451 const arg = try std.cstr.addNullByte(&ctx.arena.allocator, lib.name);
src-self-hosted/print_targets.zig+1-1
...@@ -138,7 +138,7 @@ pub fn cmdTargets(...@@ -138,7 +138,7 @@ pub fn cmdTargets(
138 for (available_glibcs) |glibc| {138 for (available_glibcs) |glibc| {
139 try jws.arrayElem();139 try jws.arrayElem();
140140
141 const tmp = try std.fmt.allocPrint(allocator, "{}", .{glibc});141 const tmp = try std.fmtstream.allocPrint(allocator, "{}", .{glibc});
142 defer allocator.free(tmp);142 defer allocator.free(tmp);
143 try jws.emitString(tmp);143 try jws.emitString(tmp);
144 }144 }
src-self-hosted/test.zig+3-3
...@@ -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.fmtstream.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.fmtstream.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.fmtstream.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.cwd().makePath(dirname);122 try std.fs.cwd().makePath(dirname);
123 }123 }
src-self-hosted/type.zig+4-4
...@@ -581,7 +581,7 @@ pub const Type = struct {...@@ -581,7 +581,7 @@ pub const Type = struct {
581 errdefer comp.gpa().destroy(self);581 errdefer comp.gpa().destroy(self);
582582
583 const u_or_i = "ui"[@boolToInt(key.is_signed)];583 const u_or_i = "ui"[@boolToInt(key.is_signed)];
584 const name = try std.fmt.allocPrint(comp.gpa(), "{c}{}", .{ u_or_i, key.bit_count });584 const name = try std.fmtstream.allocPrint(comp.gpa(), "{c}{}", .{ u_or_i, key.bit_count });
585 errdefer comp.gpa().free(name);585 errdefer comp.gpa().free(name);
586586
587 self.base.init(comp, .Int, name);587 self.base.init(comp, .Int, name);
...@@ -764,13 +764,13 @@ pub const Type = struct {...@@ -764,13 +764,13 @@ pub const Type = struct {
764 .Non => "",764 .Non => "",
765 };765 };
766 const name = switch (self.key.alignment) {766 const name = switch (self.key.alignment) {
767 .Abi => try std.fmt.allocPrint(comp.gpa(), "{}{}{}{}", .{767 .Abi => try std.fmtstream.allocPrint(comp.gpa(), "{}{}{}{}", .{
768 size_str,768 size_str,
769 mut_str,769 mut_str,
770 vol_str,770 vol_str,
771 self.key.child_type.name,771 self.key.child_type.name,
772 }),772 }),
773 .Override => |alignment| try std.fmt.allocPrint(comp.gpa(), "{}align<{}> {}{}{}", .{773 .Override => |alignment| try std.fmtstream.allocPrint(comp.gpa(), "{}align<{}> {}{}{}", .{
774 size_str,774 size_str,
775 alignment,775 alignment,
776 mut_str,776 mut_str,
...@@ -845,7 +845,7 @@ pub const Type = struct {...@@ -845,7 +845,7 @@ pub const Type = struct {
845 };845 };
846 errdefer comp.gpa().destroy(self);846 errdefer comp.gpa().destroy(self);
847847
848 const name = try std.fmt.allocPrint(comp.gpa(), "[{}]{}", .{ key.len, key.elem_type.name });848 const name = try std.fmtstream.allocPrint(comp.gpa(), "[{}]{}", .{ key.len, key.elem_type.name });
849 errdefer comp.gpa().free(name);849 errdefer comp.gpa().free(name);
850850
851 self.base.init(comp, .Array, name);851 self.base.init(comp, .Array, name);
test/src/compare_output.zig+4-4
...@@ -4,7 +4,7 @@ const std = @import("std");...@@ -4,7 +4,7 @@ const std = @import("std");
4const builtin = std.builtin;4const builtin = std.builtin;
5const build = std.build;5const build = std.build;
6const ArrayList = std.ArrayList;6const ArrayList = std.ArrayList;
7const fmt = std.fmt;7const fmtstream = std.fmtstream;
8const mem = std.mem;8const mem = std.mem;
9const fs = std.fs;9const fs = std.fs;
10const warn = std.debug.warn;10const warn = std.debug.warn;
...@@ -97,7 +97,7 @@ pub const CompareOutputContext = struct {...@@ -97,7 +97,7 @@ pub const CompareOutputContext = struct {
9797
98 switch (case.special) {98 switch (case.special) {
99 Special.Asm => {99 Special.Asm => {
100 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", .{100 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "assemble-and-link {}", .{
101 case.name,101 case.name,
102 }) catch unreachable;102 }) catch unreachable;
103 if (self.test_filter) |filter| {103 if (self.test_filter) |filter| {
...@@ -116,7 +116,7 @@ pub const CompareOutputContext = struct {...@@ -116,7 +116,7 @@ pub const CompareOutputContext = struct {
116 },116 },
117 Special.None => {117 Special.None => {
118 for (self.modes) |mode| {118 for (self.modes) |mode| {
119 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{119 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "{} {} ({})", .{
120 "compare-output",120 "compare-output",
121 case.name,121 case.name,
122 @tagName(mode),122 @tagName(mode),
...@@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {...@@ -141,7 +141,7 @@ pub const CompareOutputContext = struct {
141 }141 }
142 },142 },
143 Special.RuntimeSafety => {143 Special.RuntimeSafety => {
144 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;144 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;
145 if (self.test_filter) |filter| {145 if (self.test_filter) |filter| {
146 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;146 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
147 }147 }
test/src/run_translated_c.zig+2-2
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3const std = @import("std");3const std = @import("std");
4const build = std.build;4const build = std.build;
5const ArrayList = std.ArrayList;5const ArrayList = std.ArrayList;
6const fmt = std.fmt;6const fmtstream = std.fmtstream;
7const mem = std.mem;7const mem = std.mem;
8const fs = std.fs;8const fs = std.fs;
9const warn = std.debug.warn;9const warn = std.debug.warn;
...@@ -76,7 +76,7 @@ pub const RunTranslatedCContext = struct {...@@ -76,7 +76,7 @@ pub const RunTranslatedCContext = struct {
76 pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {76 pub fn addCase(self: *RunTranslatedCContext, case: *const TestCase) void {
77 const b = self.b;77 const b = self.b;
7878
79 const annotated_case_name = fmt.allocPrint(self.b.allocator, "run-translated-c {}", .{case.name}) catch unreachable;79 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "run-translated-c {}", .{case.name}) catch unreachable;
80 if (self.test_filter) |filter| {80 if (self.test_filter) |filter| {
81 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;81 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
82 }82 }
test/src/translate_c.zig+2-2
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3const std = @import("std");3const std = @import("std");
4const build = std.build;4const build = std.build;
5const ArrayList = std.ArrayList;5const ArrayList = std.ArrayList;
6const fmt = std.fmt;6const fmtstream = std.fmtstream;
7const mem = std.mem;7const mem = std.mem;
8const fs = std.fs;8const fs = std.fs;
9const warn = std.debug.warn;9const warn = std.debug.warn;
...@@ -99,7 +99,7 @@ pub const TranslateCContext = struct {...@@ -99,7 +99,7 @@ pub const TranslateCContext = struct {
99 const b = self.b;99 const b = self.b;
100100
101 const translate_c_cmd = "translate-c";101 const translate_c_cmd = "translate-c";
102 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;102 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;
103 if (self.test_filter) |filter| {103 if (self.test_filter) |filter| {
104 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;104 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
105 }105 }
test/tests.zig+5-5
...@@ -8,7 +8,7 @@ const Buffer = std.Buffer;...@@ -8,7 +8,7 @@ const Buffer = std.Buffer;
8const io = std.io;8const io = std.io;
9const fs = std.fs;9const fs = std.fs;
10const mem = std.mem;10const mem = std.mem;
11const fmt = std.fmt;11const fmtstream = std.fmtstream;
12const ArrayList = std.ArrayList;12const ArrayList = std.ArrayList;
13const Mode = builtin.Mode;13const Mode = builtin.Mode;
14const LibExeObjStep = build.LibExeObjStep;14const LibExeObjStep = build.LibExeObjStep;
...@@ -484,7 +484,7 @@ pub const StackTracesContext = struct {...@@ -484,7 +484,7 @@ pub const StackTracesContext = struct {
484 const expect_for_mode = expect[@enumToInt(mode)];484 const expect_for_mode = expect[@enumToInt(mode)];
485 if (expect_for_mode.len == 0) continue;485 if (expect_for_mode.len == 0) continue;
486486
487 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{487 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "{} {} ({})", .{
488 "stack-trace",488 "stack-trace",
489 name,489 name,
490 @tagName(mode),490 @tagName(mode),
...@@ -943,7 +943,7 @@ pub const CompileErrorContext = struct {...@@ -943,7 +943,7 @@ pub const CompileErrorContext = struct {
943 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {943 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
944 const b = self.b;944 const b = self.b;
945945
946 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {}", .{946 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "compile-error {}", .{
947 case.name,947 case.name,
948 }) catch unreachable;948 }) catch unreachable;
949 if (self.test_filter) |filter| {949 if (self.test_filter) |filter| {
...@@ -1009,7 +1009,7 @@ pub const StandaloneContext = struct {...@@ -1009,7 +1009,7 @@ pub const StandaloneContext = struct {
1009 const b = self.b;1009 const b = self.b;
10101010
1011 for (self.modes) |mode| {1011 for (self.modes) |mode| {
1012 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", .{1012 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "build {} ({})", .{
1013 root_src,1013 root_src,
1014 @tagName(mode),1014 @tagName(mode),
1015 }) catch unreachable;1015 }) catch unreachable;
...@@ -1152,7 +1152,7 @@ pub const GenHContext = struct {...@@ -1152,7 +1152,7 @@ pub const GenHContext = struct {
1152 const b = self.b;1152 const b = self.b;
11531153
1154 const mode = builtin.Mode.Debug;1154 const mode = builtin.Mode.Debug;
1155 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;1155 const annotated_case_name = fmtstream.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
1156 if (self.test_filter) |filter| {1156 if (self.test_filter) |filter| {
1157 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;1157 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
1158 }1158 }
tools/process_headers.zig+2-2
...@@ -299,7 +299,7 @@ pub fn main() !void {...@@ -299,7 +299,7 @@ pub fn main() !void {
299 std.debug.warn("unrecognized C ABI: {}\n", .{abi_name});299 std.debug.warn("unrecognized C ABI: {}\n", .{abi_name});
300 usageAndExit(args[0]);300 usageAndExit(args[0]);
301 };301 };
302 const generic_name = try std.fmt.allocPrint(allocator, "generic-{}", .{abi_name});302 const generic_name = try std.fmtstream.allocPrint(allocator, "generic-{}", .{abi_name});
303303
304 // TODO compiler crashed when I wrote this the canonical way304 // TODO compiler crashed when I wrote this the canonical way
305 var libc_targets: []const LibCTarget = undefined;305 var libc_targets: []const LibCTarget = undefined;
...@@ -440,7 +440,7 @@ pub fn main() !void {...@@ -440,7 +440,7 @@ pub fn main() !void {
440 .specific => |a| @tagName(a),440 .specific => |a| @tagName(a),
441 else => @tagName(dest_target.arch),441 else => @tagName(dest_target.arch),
442 };442 };
443 const out_subpath = try std.fmt.allocPrint(allocator, "{}-{}-{}", .{443 const out_subpath = try std.fmtstream.allocPrint(allocator, "{}-{}-{}", .{
444 arch_name,444 arch_name,
445 @tagName(dest_target.os),445 @tagName(dest_target.os),
446 @tagName(dest_target.abi),446 @tagName(dest_target.abi),
tools/update_glibc.zig+2-2
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
2const fs = std.fs;2const fs = std.fs;
3const fmt = std.fmt;3const fmtstream = std.fmtstream;
4const assert = std.debug.assert;4const assert = std.debug.assert;
55
6// Example abilist path:6// Example abilist path:
...@@ -154,7 +154,7 @@ pub fn main() !void {...@@ -154,7 +154,7 @@ pub fn main() !void {
154 const fn_set = &target_funcs_gop.kv.value.list;154 const fn_set = &target_funcs_gop.kv.value.list;
155155
156 for (lib_names) |lib_name, lib_name_index| {156 for (lib_names) |lib_name, lib_name_index| {
157 const basename = try fmt.allocPrint(allocator, "lib{}.abilist", .{lib_name});157 const basename = try fmtstream.allocPrint(allocator, "lib{}.abilist", .{lib_name});
158 const abi_list_filename = blk: {158 const abi_list_filename = blk: {
159 if (abi_list.targets[0].abi == .gnuabi64 and std.mem.eql(u8, lib_name, "c")) {159 if (abi_list.targets[0].abi == .gnuabi64 and std.mem.eql(u8, lib_name, "c")) {
160 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "n64", basename });160 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "n64", basename });