authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2026-09-01 02:21:28+02:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-09-01 02:21:28+02:00
log36dd7e9c375d73e73a1717a451943579a4694c2e
treeba750654873c7937ef9ac94b69d422d77f5d8377
parent8bb70dbc3f0bb7a33c7fde534ca1661f169c0989

Change usages of fmt.bufPrint* to mem.print* (#36263)

This PR doesn't touch usages inside `lib/compiler/aro` Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36263 Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>

59 files changed, 118 insertions(+), 118 deletions(-)

doc/langref/test_slices.zig+2-2
......@@ -1,7 +1,7 @@
11const std = @import("std");
22const expectEqual = std.testing.expectEqual;
33const expectEqualStrings = std.testing.expectEqualStrings;
4const fmt = std.fmt;
4const mem = std.mem;
55
66test "using slices for strings" {
77 // Zig has no concept of strings. String literals are const pointers
......@@ -18,7 +18,7 @@ test "using slices for strings" {
1818 _ = &start;
1919 const all_together_slice = all_together[start..];
2020 // String concatenation example.
21 const hello_world = try fmt.bufPrint(all_together_slice, "{s} {s}", .{ hello, world });
21 const hello_world = try mem.print(all_together_slice, "{s} {s}", .{ hello, world });
2222
2323 // Generally, you can use UTF-8 and not worry about whether something is a
2424 // string. If you don't need to deal with individual characters, no need
lib/build-web/main.zig+2-2
......@@ -56,7 +56,7 @@ fn logFn(
5656 const level_txt = comptime message_level.asText();
5757 const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): ";
5858 var buf: [500]u8 = undefined;
59 const line = std.fmt.bufPrint(&buf, level_txt ++ prefix2 ++ format, args) catch l: {
59 const line = std.mem.print(&buf, level_txt ++ prefix2 ++ format, args) catch l: {
6060 buf[buf.len - 3 ..][0..3].* = "...".*;
6161 break :l &buf;
6262 };
......@@ -116,7 +116,7 @@ pub fn Slice(T: type) type {
116116
117117pub fn fatal(comptime format: []const u8, args: anytype) noreturn {
118118 var buf: [500]u8 = undefined;
119 const line = std.fmt.bufPrint(&buf, format, args) catch l: {
119 const line = std.mem.print(&buf, format, args) catch l: {
120120 buf[buf.len - 3 ..][0..3].* = "...".*;
121121 break :l &buf;
122122 };
lib/compiler/Maker.zig+1-1
......@@ -959,7 +959,7 @@ pub fn main(init: process.Init.Minimal) !void {
959959 // trigger a rebuild on all steps with modified inputs, as well as their
960960 // recursive dependants.
961961 var caption_buf: [std.Progress.Node.max_name_len]u8 = undefined;
962 const caption = std.fmt.bufPrint(&caption_buf, "watching {d} directories, {d} processes", .{
962 const caption = std.mem.print(&caption_buf, "watching {d} directories, {d} processes", .{
963963 w.dir_count, countSubProcesses(&maker),
964964 }) catch &caption_buf;
965965 var debouncing_node = main_progress_node.start(caption, 0);
lib/compiler/Maker/Fetch.zig+2-2
......@@ -362,7 +362,7 @@ pub const JobQueue = struct {
362362 var dest_sub_path_buf: ["p/".len + Package.Hash.max_len + ".tar.gz".len]u8 = undefined;
363363 const dest_path: Path = .{
364364 .root_dir = jq.global_cache,
365 .sub_path = std.fmt.bufPrint(&dest_sub_path_buf, "p/{s}.tar.gz", .{pkg_hash_slice}) catch unreachable,
365 .sub_path = std.mem.print(&dest_sub_path_buf, "p/{s}.tar.gz", .{pkg_hash_slice}) catch unreachable,
366366 };
367367
368368 const gpa = jq.http_client.allocator;
......@@ -843,7 +843,7 @@ pub fn computedPackageHash(f: *const Fetch) Package.Hash {
843843 if (f.have_manifest) {
844844 const man = &f.manifest;
845845 var version_buffer: [32]u8 = undefined;
846 const version: []const u8 = std.fmt.bufPrint(&version_buffer, "{f}", .{man.version}) catch &version_buffer;
846 const version: []const u8 = std.mem.print(&version_buffer, "{f}", .{man.version}) catch &version_buffer;
847847 return .init(f.computed_hash.digest, man.name, version, man.id, saturated_size);
848848 }
849849 // In the future build.zig.zon fields will be added to allow overriding these values
lib/compiler/Maker/Fetch/git.zig+1-1
......@@ -1008,7 +1008,7 @@ pub const Session = struct {
10081008 }
10091009 for (wants) |want| {
10101010 var buf: [Packet.max_data_length]u8 = undefined;
1011 const arg = std.fmt.bufPrint(&buf, "want {s}\n", .{want}) catch unreachable;
1011 const arg = std.mem.print(&buf, "want {s}\n", .{want}) catch unreachable;
10121012 try Packet.write(.{ .data = arg }, &body);
10131013 }
10141014 try Packet.write(.{ .data = "done\n" }, &body);
lib/compiler/Maker/Package.zig+1-1
......@@ -130,7 +130,7 @@ pub const Hash = struct {
130130 }
131131 var bin_digest: [Algo.digest_length]u8 = undefined;
132132 Algo.hash(sub_path, &bin_digest, .{});
133 _ = std.fmt.bufPrint(result.bytes[i..], "{x}", .{&bin_digest}) catch unreachable;
133 _ = std.mem.print(result.bytes[i..], "{x}", .{&bin_digest}) catch unreachable;
134134 return result;
135135 }
136136
lib/compiler/Maker/Step/Compile.zig+1-1
......@@ -892,7 +892,7 @@ fn lowerZigArgs(
892892 var args_hash: [Sha256.digest_length]u8 = undefined;
893893 Sha256.hash(args, &args_hash, .{});
894894 var args_hex_hash: [Sha256.digest_length * 2]u8 = undefined;
895 _ = std.fmt.bufPrint(&args_hex_hash, "{x}", .{&args_hash}) catch unreachable;
895 _ = std.mem.print(&args_hex_hash, "{x}", .{&args_hash}) catch unreachable;
896896
897897 const args_file = "args" ++ Dir.path.sep_str ++ args_hex_hash;
898898 local_cache_root.handle.access(io, args_file, .{}) catch {
lib/compiler/Maker/Step/Run.zig+1-1
......@@ -971,7 +971,7 @@ const FuzzTestRunner = struct {
971971 i += 1;
972972 }) {
973973 const name_prefix = "f" ++ Dir.path.sep_str ++ "in";
974 in_name = std.fmt.bufPrint(&in_name_buf, name_prefix ++ "{x}", .{i}) catch unreachable;
974 in_name = std.mem.print(&in_name_buf, name_prefix ++ "{x}", .{i}) catch unreachable;
975975 in_f = cache_root.handle.openFile(io, in_name, .{
976976 .lock = .exclusive,
977977 .lock_nonblocking = true,
lib/compiler/Maker/Watch.zig+1-1
......@@ -145,7 +145,7 @@ const Os = switch (builtin.os.tag) {
145145 fn getDirHandle(gpa: Allocator, path: std.Build.Cache.Path, mount_id: *MountId) !FileHandle {
146146 var file_handle_buffer: [@sizeOf(std.os.linux.file_handle) + 128]u8 align(@alignOf(std.os.linux.file_handle)) = undefined;
147147 var buf: [std.fs.max_path_bytes]u8 = undefined;
148 const adjusted_path = if (path.sub_path.len == 0) "./" else std.fmt.bufPrint(&buf, "{s}/", .{
148 const adjusted_path = if (path.sub_path.len == 0) "./" else std.mem.print(&buf, "{s}/", .{
149149 path.sub_path,
150150 }) catch return error.NameTooLong;
151151 const stack_ptr: *std.os.linux.file_handle = @ptrCast(&file_handle_buffer);
lib/compiler/objcopy.zig+1-1
......@@ -615,7 +615,7 @@ const HexWriter = struct {
615615 const payload_bytes = self.getPayloadBytes();
616616 assert(payload_bytes.len <= max_payload_len);
617617
618 const line = try std.fmt.bufPrint(&outbuf, ":{0X:0>2}{1X:0>4}{2X:0>2}{3X}{4X:0>2}" ++ linesep, .{
618 const line = try std.mem.print(&outbuf, ":{0X:0>2}{1X:0>4}{2X:0>2}{3X}{4X:0>2}" ++ linesep, .{
619619 @as(u8, @intCast(payload_bytes.len)),
620620 self.address,
621621 @backingInt(self.payload),
lib/compiler/resinator/cvtres.zig+1-1
......@@ -883,7 +883,7 @@ const ResourceTree = struct {
883883 std.mem.writeInt(u32, name_buf[0..4], 0, .little);
884884 std.mem.writeInt(u32, name_buf[4..8], string_table_offset, .little);
885885 } else {
886 const name_slice = std.fmt.bufPrint(&name_buf, "$R{X:0>6}", .{relocation.data_offset}) catch unreachable;
886 const name_slice = std.mem.print(&name_buf, "$R{X:0>6}", .{relocation.data_offset}) catch unreachable;
887887 std.debug.assert(name_slice.len == 8);
888888 }
889889
lib/compiler/translate-c/MacroTranslator.zig+1-1
......@@ -583,7 +583,7 @@ fn escapeUnprintables(mt: *MacroTranslator) ![]const u8 {
583583 const formatter = std.ascii.hexEscape(zigified, .lower);
584584 const encoded_size = @as(usize, @intCast(std.fmt.count("{f}", .{formatter})));
585585 const output = try mt.t.arena.alloc(u8, encoded_size);
586 return std.fmt.bufPrint(output, "{f}", .{formatter}) catch |err| switch (err) {
586 return std.mem.print(output, "{f}", .{formatter}) catch |err| switch (err) {
587587 error.NoSpaceLeft => unreachable,
588588 else => |e| return e,
589589 };
lib/docs/wasm/main.zig+1-1
......@@ -48,7 +48,7 @@ fn logFn(
4848) void {
4949 const prefix = if (scope == .default) "" else @tagName(scope) ++ ": ";
5050 var buf: [500]u8 = undefined;
51 const line = std.fmt.bufPrint(&buf, prefix ++ format, args) catch l: {
51 const line = std.mem.print(&buf, prefix ++ format, args) catch l: {
5252 buf[buf.len - 3 ..][0..3].* = "...".*;
5353 break :l &buf;
5454 };
lib/fuzzer.zig+3-3
......@@ -242,7 +242,7 @@ const Executable = struct {
242242 /// Asserts `buf[0..2]` is "in"
243243 fn inputFileName(buf: *[10]u8, i: u32) []u8 {
244244 assert(buf[0..2].* == "in".*);
245 const hex = std.fmt.bufPrint(buf[2..], "{x}", .{i}) catch unreachable;
245 const hex = std.mem.print(buf[2..], "{x}", .{i}) catch unreachable;
246246 return buf[0 .. 2 + hex.len];
247247 }
248248
......@@ -763,7 +763,7 @@ const Fuzzer = struct {
763763 const input_f = while (true) {
764764 var name_buf: [10]u8 = undefined;
765765 name_buf[0..2].* = "in".*;
766 const hex = std.fmt.bufPrint(name_buf[2..], "{x}", .{input_i}) catch unreachable;
766 const hex = std.mem.print(name_buf[2..], "{x}", .{input_i}) catch unreachable;
767767 const name = name_buf[0 .. 2 + hex.len];
768768
769769 if (exec.cache_f.createFile(io, name, .{
......@@ -998,7 +998,7 @@ const Fuzzer = struct {
998998 }
999999
10001000 pub fn inputName(n: *CorpusFileName, i: u32) []u8 {
1001 const hex = std.fmt.bufPrint(n.buf[Test.dirname_len + 1 ..][0..8], "{x}", .{i}) catch unreachable;
1001 const hex = std.mem.print(n.buf[Test.dirname_len + 1 ..][0..8], "{x}", .{i}) catch unreachable;
10021002 return n.buf[0 .. Test.dirname_len + 1 + hex.len];
10031003 }
10041004 };
lib/std/Build/Cache/Path.zig+9-9
......@@ -61,7 +61,7 @@ pub fn joinStringZ(p: Path, gpa: Allocator, sub_path: []const u8) Allocator.Erro
6161pub fn openFile(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.OpenFileOptions) !Io.File {
6262 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
6363 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
64 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
64 break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
6565 p.sub_path, sub_path,
6666 }) catch return error.NameTooLong;
6767 };
......@@ -76,7 +76,7 @@ pub fn openDir(
7676) Io.Dir.OpenError!Io.Dir {
7777 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
7878 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
79 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
79 break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
8080 p.sub_path, sub_path,
8181 }) catch return error.NameTooLong;
8282 };
......@@ -86,7 +86,7 @@ pub fn openDir(
8686pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.CreateDirPathOpenOptions) !Io.Dir {
8787 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
8888 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
89 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
89 break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
9090 p.sub_path, sub_path,
9191 }) catch return error.NameTooLong;
9292 };
......@@ -96,7 +96,7 @@ pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.Cre
9696pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat {
9797 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
9898 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
99 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
99 break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
100100 p.sub_path, sub_path,
101101 }) catch return error.NameTooLong;
102102 };
......@@ -111,7 +111,7 @@ pub fn atomicFile(
111111 buf: *[Io.Dir.max_path_bytes]u8,
112112) !Io.File.Atomic {
113113 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
114 break :p std.fmt.bufPrint(buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
114 break :p std.mem.print(buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
115115 p.sub_path, sub_path,
116116 }) catch return error.NameTooLong;
117117 };
......@@ -121,7 +121,7 @@ pub fn atomicFile(
121121pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions) !void {
122122 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
123123 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
124 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
124 break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
125125 p.sub_path, sub_path,
126126 }) catch return error.NameTooLong;
127127 };
......@@ -131,7 +131,7 @@ pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions
131131pub fn createDirPath(p: Path, io: Io, sub_path: []const u8) !void {
132132 var buf: [Io.Dir.max_path_bytes]u8 = undefined;
133133 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
134 break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
134 break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{
135135 p.sub_path, sub_path,
136136 }) catch return error.NameTooLong;
137137 };
......@@ -139,11 +139,11 @@ pub fn createDirPath(p: Path, io: Io, sub_path: []const u8) !void {
139139}
140140
141141pub fn toString(p: Path, allocator: Allocator) Allocator.Error![]u8 {
142 return std.fmt.allocPrint(allocator, "{f}", .{p});
142 return allocator.print("{f}", .{p});
143143}
144144
145145pub fn toStringZ(p: Path, allocator: Allocator) Allocator.Error![:0]u8 {
146 return std.fmt.allocPrintSentinel(allocator, "{f}", .{p}, 0);
146 return allocator.printSentinel("{f}", .{p}, 0);
147147}
148148
149149pub fn fmtEscapeString(path: Path) std.fmt.Alt(Path, formatEscapeString) {
lib/std/Io/Threaded.zig+5-5
......@@ -7067,7 +7067,7 @@ fn realPathPosix(fd: posix.fd_t, out_buffer: []u8) File.RealPathError!usize {
70677067 .linux, .serenity, .illumos => {
70687068 var procfs_buf: ["/proc/self/path/-2147483648\x00".len]u8 = undefined;
70697069 const template = if (native_os == .illumos) "/proc/self/path/{d}" else "/proc/self/fd/{d}";
7070 const proc_path = std.fmt.bufPrintSentinel(&procfs_buf, template, .{fd}, 0) catch unreachable;
7070 const proc_path = std.mem.printSentinel(&procfs_buf, template, .{fd}, 0) catch unreachable;
70717071 const syscall: Syscall = try .start();
70727072 while (true) {
70737073 const rc = posix.system.readlink(proc_path, out_buffer.ptr, out_buffer.len);
......@@ -7155,7 +7155,7 @@ fn fileHardLink(
71557155 error.FileNotFound => {
71567156 if (options.follow_symlinks) return error.FileNotFound;
71577157 var proc_buf: ["/proc/self/fd/-2147483648\x00".len]u8 = undefined;
7158 const proc_path = std.fmt.bufPrintSentinel(&proc_buf, "/proc/self/fd/{d}", .{file.handle}, 0) catch
7158 const proc_path = std.mem.printSentinel(&proc_buf, "/proc/self/fd/{d}", .{file.handle}, 0) catch
71597159 unreachable;
71607160 return linkat(posix.AT.FDCWD, proc_path, new_dir.handle, new_sub_path_posix, posix.AT.SYMLINK_FOLLOW);
71617161 },
......@@ -8633,7 +8633,7 @@ fn fchmodatFallback(
86338633 return error.OperationUnsupported;
86348634
86358635 var procfs_buf: ["/proc/self/fd/-2147483648\x00".len]u8 = undefined;
8636 const proc_path = std.fmt.bufPrintSentinel(&procfs_buf, "/proc/self/fd/{d}", .{path_fd}, 0) catch unreachable;
8636 const proc_path = std.mem.printSentinel(&procfs_buf, "/proc/self/fd/{d}", .{path_fd}, 0) catch unreachable;
86378637 const syscall: Syscall = try .start();
86388638 while (true) {
86398639 switch (posix.errno(posix.system.chmod(proc_path, mode))) {
......@@ -10633,7 +10633,7 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) process.Execut
1063310633 var it = std.mem.tokenizeScalar(u8, PATH, ':');
1063410634 it: while (it.next()) |dir| {
1063510635 var resolved_path_buf: [std.c.PATH_MAX]u8 = undefined;
10636 const resolved_path = std.fmt.bufPrintSentinel(&resolved_path_buf, "{s}/{s}", .{
10636 const resolved_path = std.mem.printSentinel(&resolved_path_buf, "{s}/{s}", .{
1063710637 dir, argv0,
1063810638 }, 0) catch continue;
1063910639
......@@ -14002,7 +14002,7 @@ fn netLookupFallible(
1400214002 const name_c = name_buffer[0..name.len :0];
1400314003
1400414004 var port_buffer: [8]u8 = undefined;
14005 const port_c = std.fmt.bufPrintSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable;
14005 const port_c = std.mem.printSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable;
1400614006
1400714007 const family: i32 = if (options.family) |f| switch (f) {
1400814008 .ip4 => posix.AF.INET,
lib/std/Io/Uring.zig+1-1
......@@ -5793,7 +5793,7 @@ fn realPath(
57935793) File.RealPathError!usize {
57945794 _ = ev;
57955795 var procfs_buf: [std.fmt.count("/proc/self/fd/{d}\x00", .{std.math.minInt(fd_t)})]u8 = undefined;
5796 const proc_path = std.fmt.bufPrintSentinel(&procfs_buf, "/proc/self/fd/{d}", .{fd}, 0) catch
5796 const proc_path = std.mem.printSentinel(&procfs_buf, "/proc/self/fd/{d}", .{fd}, 0) catch
57975797 unreachable;
57985798 while (true) {
57995799 try sync.cancel_region.await(.nothing);
lib/std/Io/net.zig+1-1
......@@ -1504,7 +1504,7 @@ fn testIp6ParseTransform(expected: []const u8, input: []const u8) !void {
15041504 },
15051505 };
15061506 var buffer: [100]u8 = undefined;
1507 const result = try std.fmt.bufPrint(&buffer, "{f}", .{ua});
1507 const result = try std.mem.print(&buffer, "{f}", .{ua});
15081508 try std.testing.expectEqualStrings(expected, result);
15091509}
15101510
lib/std/Io/net/test.zig+2-2
......@@ -65,7 +65,7 @@ test "parse and render IPv6 addresses" {
6565fn testParseAndRenderIp6Address(input: []const u8, expected_output: []const u8) !void {
6666 var buffer: [100]u8 = undefined;
6767 const parsed = net.Ip6Address.Unresolved.parse(input);
68 const actual_printed = try std.fmt.bufPrint(&buffer, "{f}", .{parsed.success});
68 const actual_printed = try std.mem.print(&buffer, "{f}", .{parsed.success});
6969 try testing.expectEqualStrings(expected_output, actual_printed);
7070}
7171
......@@ -115,7 +115,7 @@ test "parse and render IPv4 addresses" {
115115fn testIp4ParseAndRender(text: []const u8) !void {
116116 var buffer: [18]u8 = undefined;
117117 const addr = try net.IpAddress.parseIp4(text, 0);
118 const rendered = try std.fmt.bufPrint(&buffer, "{f}", .{addr});
118 const rendered = try std.mem.print(&buffer, "{f}", .{addr});
119119 const without_port = rendered[0 .. rendered.len - 2];
120120 try testing.expectEqualStrings(text, without_port);
121121}
lib/std/Progress.zig+6-6
......@@ -308,7 +308,7 @@ pub const Node = struct {
308308
309309 pub fn startFmt(node: Node, estimated_total_items: usize, comptime format: []const u8, args: anytype) Node {
310310 var buffer: [max_name_len]u8 = undefined;
311 const name = std.fmt.bufPrint(&buffer, format, args) catch &buffer;
311 const name = std.mem.print(&buffer, format, args) catch &buffer;
312312 return Node.start(node, name, estimated_total_items);
313313 }
314314
......@@ -1355,7 +1355,7 @@ fn computeRedraw(io: Io, serialized_buffer: *Serialized.Buffer) !struct { []u8,
13551355 i += progress_pulsing.len;
13561356 } else {
13571357 const percent = @as(u64, completed_items) * 100 / estimated_total;
1358 if (std.fmt.bufPrint(buf[i..], @"progress_normal {d}", .{percent})) |b| {
1358 if (std.mem.print(buf[i..], @"progress_normal {d}", .{percent})) |b| {
13591359 i += b.len;
13601360 } else |_| {}
13611361 }
......@@ -1374,7 +1374,7 @@ fn computeRedraw(io: Io, serialized_buffer: *Serialized.Buffer) !struct { []u8,
13741374 i += progress_pulsing_error.len;
13751375 } else {
13761376 const percent = @as(u64, completed_items) * 100 / estimated_total;
1377 if (std.fmt.bufPrint(buf[i..], @"progress_error {d}", .{percent})) |b| {
1377 if (std.mem.print(buf[i..], @"progress_error {d}", .{percent})) |b| {
13781378 i += b.len;
13791379 } else |_| {}
13801380 }
......@@ -1475,16 +1475,16 @@ fn computeNode(
14751475 if (!is_empty_root) {
14761476 if (name.len != 0 or estimated_total > 0) {
14771477 if (estimated_total > 0) {
1478 if (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total })) |b| {
1478 if (std.mem.print(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total })) |b| {
14791479 i += b.len;
14801480 } else |_| {}
14811481 } else if (completed_items != 0) {
1482 if (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items})) |b| {
1482 if (std.mem.print(buf[i..], "[{d}] ", .{completed_items})) |b| {
14831483 i += b.len;
14841484 } else |_| {}
14851485 }
14861486 if (name.len != 0) {
1487 if (std.fmt.bufPrint(buf[i..], "{s}", .{name})) |b| {
1487 if (std.mem.print(buf[i..], "{s}", .{name})) |b| {
14881488 i += b.len;
14891489 } else |_| {}
14901490 }
lib/std/Target.zig+1-1
......@@ -2437,7 +2437,7 @@ pub const DynamicLinker = struct {
24372437
24382438 /// Asserts that the length is less than or equal to 255 bytes.
24392439 pub fn setFmt(dl: *DynamicLinker, comptime fmt_str: []const u8, args: anytype) !void {
2440 dl.len = @intCast((try std.fmt.bufPrint(&dl.buffer, fmt_str, args)).len);
2440 dl.len = @intCast((try std.mem.print(&dl.buffer, fmt_str, args)).len);
24412441 }
24422442
24432443 pub fn eql(lhs: DynamicLinker, rhs: DynamicLinker) bool {
lib/std/Thread.zig+4-4
......@@ -47,7 +47,7 @@ pub const SetNameError = error{
4747 Unsupported,
4848 Unexpected,
4949 InvalidWtf8,
50} || posix.PrctlError || Io.File.Writer.Error || Io.File.OpenError || std.fmt.BufPrintError;
50} || posix.PrctlError || Io.File.Writer.Error || Io.File.OpenError || std.mem.PrintError;
5151
5252pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void {
5353 if (name.len > max_name_len) return error.NameTooLong;
......@@ -75,7 +75,7 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void {
7575 }
7676 } else {
7777 var buf: [32]u8 = undefined;
78 const path = try std.fmt.bufPrint(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()});
78 const path = try std.mem.print(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()});
7979
8080 const file = try Io.Dir.cwd().openFile(io, path, .{ .mode = .write_only });
8181 defer file.close(io);
......@@ -152,7 +152,7 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void {
152152pub const GetNameError = error{
153153 Unsupported,
154154 Unexpected,
155} || posix.PrctlError || posix.ReadError || Io.File.OpenError || std.fmt.BufPrintError;
155} || posix.PrctlError || posix.ReadError || Io.File.OpenError || std.mem.PrintError;
156156
157157/// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/).
158158/// On other platforms, the result is an opaque sequence of bytes with no particular encoding.
......@@ -176,7 +176,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
176176 }
177177 } else {
178178 var buf: [32]u8 = undefined;
179 const path = try std.fmt.bufPrint(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()});
179 const path = try std.mem.print(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()});
180180
181181 const io = std.Options.debug_io;
182182
lib/std/Uri.zig+2-2
......@@ -41,7 +41,7 @@ pub const Component = union(enum) {
4141 return switch (component) {
4242 .raw => |raw| raw,
4343 .percent_encoded => |percent_encoded| if (std.mem.findScalar(u8, percent_encoded, '%')) |_|
44 try std.fmt.bufPrint(buffer, "{f}", .{std.fmt.alt(component, .formatRaw)})
44 try std.mem.print(buffer, "{f}", .{std.fmt.alt(component, .formatRaw)})
4545 else
4646 percent_encoded,
4747 };
......@@ -52,7 +52,7 @@ pub const Component = union(enum) {
5252 return switch (component) {
5353 .raw => |raw| raw,
5454 .percent_encoded => |percent_encoded| if (std.mem.findScalar(u8, percent_encoded, '%')) |_|
55 try std.fmt.allocPrint(arena, "{f}", .{std.fmt.alt(component, .formatRaw)})
55 try arena.print("{f}", .{std.fmt.alt(component, .formatRaw)})
5656 else
5757 percent_encoded,
5858 };
lib/std/crypto/25519/curve25519.zig+2-2
......@@ -129,9 +129,9 @@ test "curve25519" {
129129 const p = try Curve25519.basePoint.clampedMul(s);
130130 try p.rejectIdentity();
131131 var buf: [128]u8 = undefined;
132 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&p.toBytes()}), "E6F2A4D1C28EE5C7AD0329268255A468AD407D2672824C0C0EB30EA6EF450145");
132 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&p.toBytes()}), "E6F2A4D1C28EE5C7AD0329268255A468AD407D2672824C0C0EB30EA6EF450145");
133133 const q = try p.clampedMul(s);
134 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&q.toBytes()}), "3614E119FFE55EC55B87D6B19971A9F4CBC78EFE80BEC55B96392BABCC712537");
134 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&q.toBytes()}), "3614E119FFE55EC55B87D6B19971A9F4CBC78EFE80BEC55B96392BABCC712537");
135135
136136 try Curve25519.rejectNonCanonical(s);
137137 s[31] |= 0x80;
lib/std/crypto/25519/ed25519.zig+3-3
......@@ -585,8 +585,8 @@ test "key pair creation" {
585585 _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166");
586586 const key_pair = try Ed25519.KeyPair.generateDeterministic(seed);
587587 var buf: [256]u8 = undefined;
588 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&key_pair.secret_key.toBytes()}), "8052030376D47112BE7F73ED7A019293DD12AD910B654455798B4667D73DE1662D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083");
589 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&key_pair.public_key.toBytes()}), "2D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083");
588 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&key_pair.secret_key.toBytes()}), "8052030376D47112BE7F73ED7A019293DD12AD910B654455798B4667D73DE1662D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083");
589 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&key_pair.public_key.toBytes()}), "2D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083");
590590}
591591
592592test "signature" {
......@@ -596,7 +596,7 @@ test "signature" {
596596
597597 const sig = try key_pair.sign("test", null);
598598 var buf: [128]u8 = undefined;
599 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&sig.toBytes()}), "10A442B4A80CC4225B154F43BEF28D2472CA80221951262EB8E0DF9091575E2687CC486E77263C3418C757522D54F84B0359236ABBBD4ACD20DC297FDCA66808");
599 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&sig.toBytes()}), "10A442B4A80CC4225B154F43BEF28D2472CA80221951262EB8E0DF9091575E2687CC486E77263C3418C757522D54F84B0359236ABBBD4ACD20DC297FDCA66808");
600600 try sig.verify("test", key_pair.public_key);
601601 try std.testing.expectError(error.SignatureVerificationFailed, sig.verify("TEST", key_pair.public_key));
602602}
lib/std/crypto/25519/edwards25519.zig+1-1
......@@ -543,7 +543,7 @@ test "packing/unpacking" {
543543 var b = Edwards25519.basePoint;
544544 const pk = try b.mul(s);
545545 var buf: [128]u8 = undefined;
546 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&pk.toBytes()}), "074BC7E0FCBD587FDBC0969444245FADC562809C8F6E97E949AF62484B5B81A6");
546 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&pk.toBytes()}), "074BC7E0FCBD587FDBC0969444245FADC562809C8F6E97E949AF62484B5B81A6");
547547
548548 const small_order_ss: [7][32]u8 = .{
549549 .{
lib/std/crypto/25519/ristretto255.zig+4-4
......@@ -175,21 +175,21 @@ pub const Ristretto255 = struct {
175175test "ristretto255" {
176176 const p = Ristretto255.basePoint;
177177 var buf: [256]u8 = undefined;
178 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&p.toBytes()}), "E2F2AE0A6ABC4E71A884A961C500515F58E30B6AA582DD8DB6A65945E08D2D76");
178 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&p.toBytes()}), "E2F2AE0A6ABC4E71A884A961C500515F58E30B6AA582DD8DB6A65945E08D2D76");
179179
180180 var r: [Ristretto255.encoded_length]u8 = undefined;
181181 _ = try fmt.hexToBytes(r[0..], "6a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b919");
182182 var q = try Ristretto255.fromBytes(r);
183183 q = q.dbl().add(p);
184 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&q.toBytes()}), "E882B131016B52C1D3337080187CF768423EFCCBB517BB495AB812C4160FF44E");
184 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&q.toBytes()}), "E882B131016B52C1D3337080187CF768423EFCCBB517BB495AB812C4160FF44E");
185185
186186 const s = [_]u8{15} ++ @as([31]u8, @splat(0));
187187 const w = try p.mul(s);
188 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&w.toBytes()}), "E0C418F7C8D9C4CDD7395B93EA124F3AD99021BB681DFC3302A9D99A2E53E64E");
188 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&w.toBytes()}), "E0C418F7C8D9C4CDD7395B93EA124F3AD99021BB681DFC3302A9D99A2E53E64E");
189189
190190 try std.testing.expect(p.dbl().dbl().dbl().dbl().equivalent(w.add(p)));
191191
192192 const h = @as([32]u8, @splat(69)) ++ @as([32]u8, @splat(42));
193193 const ph = Ristretto255.fromUniform(h);
194 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&ph.toBytes()}), "DCCA54E037A4311EFBEEF413ACD21D35276518970B7A61DC88F8587B493D5E19");
194 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&ph.toBytes()}), "DCCA54E037A4311EFBEEF413ACD21D35276518970B7A61DC88F8587B493D5E19");
195195}
lib/std/crypto/25519/scalar.zig+3-3
......@@ -850,10 +850,10 @@ test "scalar25519" {
850850 var y = x.toBytes();
851851 try rejectNonCanonical(y);
852852 var buf: [128]u8 = undefined;
853 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&y}), "1E979B917937F3DE71D18077F961F6CEFF01030405060708010203040506070F");
853 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&y}), "1E979B917937F3DE71D18077F961F6CEFF01030405060708010203040506070F");
854854
855855 const reduced = reduce(field_order_s);
856 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&reduced}), "0000000000000000000000000000000000000000000000000000000000000000");
856 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&reduced}), "0000000000000000000000000000000000000000000000000000000000000000");
857857}
858858
859859test "non-canonical scalar25519" {
......@@ -867,7 +867,7 @@ test "mulAdd overflow check" {
867867 const c: [32]u8 = @splat(0xff);
868868 const x = mulAdd(a, b, c);
869869 var buf: [128]u8 = undefined;
870 try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&x}), "D14DF91389432C25AD60FF9791B9FD1D67BEF517D273ECCE3D9A307C1B419903");
870 try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&x}), "D14DF91389432C25AD60FF9791B9FD1D67BEF517D273ECCE3D9A307C1B419903");
871871}
872872
873873test "scalar field inversion" {
lib/std/crypto/bcrypt.zig+1-1
......@@ -635,7 +635,7 @@ const crypt_format = struct {
635635 _ = Codec.Encoder.encode(&ct_str, dk[0..]);
636636
637637 var s_buf: [hash_length]u8 = undefined;
638 const s = fmt.bufPrint(
638 const s = mem.print(
639639 s_buf[0..],
640640 "{s}b${d}{d}${s}{s}",
641641 .{ prefix, params.rounds_log / 10, params.rounds_log % 10, salt_str, ct_str },
lib/std/crypto/chacha20.zig+2-2
......@@ -1145,7 +1145,7 @@ test "xchacha20" {
11451145 var c: [m.len]u8 = undefined;
11461146 XChaCha20IETF.xor(c[0..], m[0..], 0, key, nonce);
11471147 var buf: [2 * c.len]u8 = undefined;
1148 try testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&c}), "E0A1BCF939654AFDBDC1746EC49832647C19D891F0D1A81FC0C1703B4514BDEA584B512F6908C2C5E9DD18D5CBC1805DE5803FE3B9CA5F193FB8359E91FAB0C3BB40309A292EB1CF49685C65C4A3ADF4F11DB0CD2B6B67FBC174BC2E860E8F769FD3565BBFAD1C845E05A0FED9BE167C240D");
1148 try testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&c}), "E0A1BCF939654AFDBDC1746EC49832647C19D891F0D1A81FC0C1703B4514BDEA584B512F6908C2C5E9DD18D5CBC1805DE5803FE3B9CA5F193FB8359E91FAB0C3BB40309A292EB1CF49685C65C4A3ADF4F11DB0CD2B6B67FBC174BC2E860E8F769FD3565BBFAD1C845E05A0FED9BE167C240D");
11491149 }
11501150 {
11511151 const ad = "Additional data";
......@@ -1154,7 +1154,7 @@ test "xchacha20" {
11541154 var out: [m.len]u8 = undefined;
11551155 try XChaCha20Poly1305.decrypt(out[0..], c[0..m.len], c[m.len..].*, ad, nonce, key);
11561156 var buf: [2 * c.len]u8 = undefined;
1157 try testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&c}), "994D2DD32333F48E53650C02C7A2ABB8E018B0836D7175AEC779F52E961780768F815C58F1AA52D211498DB89B9216763F569C9433A6BBFCEFB4D4A49387A4C5207FBB3B5A92B5941294DF30588C6740D39DC16FA1F0E634F7246CF7CDCB978E44347D89381B7A74EB7084F754B90BDE9AAF5A94B8F2A85EFD0B50692AE2D425E234");
1157 try testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&c}), "994D2DD32333F48E53650C02C7A2ABB8E018B0836D7175AEC779F52E961780768F815C58F1AA52D211498DB89B9216763F569C9433A6BBFCEFB4D4A49387A4C5207FBB3B5A92B5941294DF30588C6740D39DC16FA1F0E634F7246CF7CDCB978E44347D89381B7A74EB7084F754B90BDE9AAF5A94B8F2A85EFD0B50692AE2D425E234");
11581158 try testing.expectEqualSlices(u8, out[0..], m);
11591159 c[0] +%= 1;
11601160 try testing.expectError(error.AuthenticationFailed, XChaCha20Poly1305.decrypt(out[0..], c[0..m.len], c[m.len..].*, ad, nonce, key));
lib/std/crypto/ml_kem.zig+1-1
......@@ -1701,7 +1701,7 @@ fn testNistKat(mode: type, hash: []const u8) !void {
17011701 var out: [32]u8 = undefined;
17021702 fw.hasher.final(&out);
17031703 var outHex: [64]u8 = undefined;
1704 _ = try std.fmt.bufPrint(&outHex, "{x}", .{&out});
1704 _ = try std.mem.print(&outHex, "{x}", .{&out});
17051705 try testing.expectEqualStrings(&outHex, hash);
17061706}
17071707
lib/std/fs/test.zig+2-2
......@@ -529,7 +529,7 @@ test "Dir.Iterator many entries" {
529529 var i: usize = 0;
530530 var buf: [4]u8 = undefined; // Enough to store "1024".
531531 while (i < num) : (i += 1) {
532 const name = try std.fmt.bufPrint(&buf, "{}", .{i});
532 const name = try std.mem.print(&buf, "{}", .{i});
533533 const file = try tmp_dir.dir.createFile(io, name, .{});
534534 file.close(io);
535535 }
......@@ -551,7 +551,7 @@ test "Dir.Iterator many entries" {
551551
552552 i = 0;
553553 while (i < num) : (i += 1) {
554 const name = try std.fmt.bufPrint(&buf, "{}", .{i});
554 const name = try std.mem.print(&buf, "{}", .{i});
555555 try expect(contains(&entries, .{ .name = name, .kind = .file, .inode = 0 }));
556556 }
557557}
lib/std/http/test.zig+5-5
......@@ -344,7 +344,7 @@ test "Server.Request.respondStreaming non-chunked, unknown content-length" {
344344 var total: usize = 0;
345345 for (0..500) |i| {
346346 var buf: [30]u8 = undefined;
347 const line = try std.fmt.bufPrint(&buf, "{d}, ah ha ha!\n", .{i});
347 const line = try std.mem.print(&buf, "{d}, ah ha ha!\n", .{i});
348348 try expected_response.appendSlice(line);
349349 total += line.len;
350350 }
......@@ -1017,7 +1017,7 @@ fn echoTests(client: *http.Client, port: u16) !void {
10171017 try expect(client.http_proxy != null or client.connection_pool.free_len == 1);
10181018
10191019 { // send chunked request
1020 const uri = try std.Uri.parse(try std.fmt.bufPrint(
1020 const uri = try std.Uri.parse(try std.mem.print(
10211021 &location_buffer,
10221022 "http://127.0.0.1:{d}/echo-content",
10231023 .{port},
......@@ -1213,7 +1213,7 @@ test "redirect to different connection" {
12131213 defer stream.close(io);
12141214
12151215 var loc_buf: [50]u8 = undefined;
1216 const new_loc = try std.fmt.bufPrint(&loc_buf, "http://127.0.0.1:{d}/ok", .{
1216 const new_loc = try std.mem.print(&loc_buf, "http://127.0.0.1:{d}/ok", .{
12171217 global.other_port.?,
12181218 });
12191219
......@@ -1241,7 +1241,7 @@ test "redirect to different connection" {
12411241 defer client.deinit();
12421242
12431243 var loc_buf: [100]u8 = undefined;
1244 const location = try std.fmt.bufPrint(&loc_buf, "http://127.0.0.1:{d}/help", .{
1244 const location = try std.mem.print(&loc_buf, "http://127.0.0.1:{d}/help", .{
12451245 test_server_orig.port(),
12461246 });
12471247 const uri = try std.Uri.parse(location);
......@@ -1300,7 +1300,7 @@ test "boot failed connections from the pool" {
13001300 defer client.deinit();
13011301
13021302 var loc_buf: [100]u8 = undefined;
1303 const location = try std.fmt.bufPrint(&loc_buf, "http://127.0.0.1:{d}/", .{
1303 const location = try std.mem.print(&loc_buf, "http://127.0.0.1:{d}/", .{
13041304 test_server_orig.port(),
13051305 });
13061306 const uri = try std.Uri.parse(location);
lib/std/os/windows.zig+1-1
......@@ -5006,7 +5006,7 @@ pub const TEB = extern struct {
50065006};
50075007
50085008comptime {
5009 // XXX: Without this check we cannot use `std.Io.Writer` on 16-bit platforms. `std.fmt.bufPrint` will hit the unreachable in `PEB.GdiHandleBuffer` without this guard.
5009 // XXX: Without this check we cannot use `std.Io.Writer` on 16-bit platforms. `std.mem.print` will hit the unreachable in `PEB.GdiHandleBuffer` without this guard.
50105010 if (builtin.os.tag == .windows) {
50115011 // Offsets taken from WinDbg info and Geoff Chappell[1] (RIP)
50125012 // [1]: https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm
lib/std/process/Environ.zig+2-2
......@@ -466,7 +466,7 @@ pub const Map = struct {
466466 );
467467 i += "ZIG_PROGRESS=".len;
468468 var value_buf: [std.fmt.count("{d}", .{std.math.maxInt(usize)})]u8 = undefined;
469 const value = std.fmt.bufPrint(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable;
469 const value = std.mem.print(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable;
470470 for (block[i..][0..value.len], value) |*r, v| r.* = v;
471471 i += value.len;
472472 block[i] = 0;
......@@ -840,7 +840,7 @@ pub fn createWindowsBlock(
840840 @memcpy(block[i..][0..zig_progress_key.len], &zig_progress_key);
841841 i += zig_progress_key.len;
842842 var value_buf: [std.fmt.count("{d}", .{std.math.maxInt(usize)})]u8 = undefined;
843 const value = std.fmt.bufPrint(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable;
843 const value = std.mem.print(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable;
844844 for (block[i..][0..value.len], value) |*r, v| r.* = v;
845845 i += value.len;
846846 block[i] = 0;
lib/std/testing.zig+1-1
......@@ -656,7 +656,7 @@ test expectError {
656656pub fn expectFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void {
657657 if (@inComptime()) {
658658 var buffer: [std.fmt.count(template, args)]u8 = undefined;
659 return expectEqualStrings(expected, try std.fmt.bufPrint(&buffer, template, args));
659 return expectEqualStrings(expected, try std.mem.print(&buffer, template, args));
660660 }
661661 const actual = try std.fmt.allocPrint(allocator, template, args);
662662 defer allocator.free(actual);
lib/std/zig/WindowsSdk.zig+2-2
......@@ -513,7 +513,7 @@ pub const Installation = struct {
513513
514514 const version = version: {
515515 var buf: [Dir.max_path_bytes]u8 = undefined;
516 const sdk_lib_dir_path = std.fmt.bufPrint(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) {
516 const sdk_lib_dir_path = std.mem.print(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) {
517517 error.NoSpaceLeft => return error.PathTooLong,
518518 };
519519 if (!Dir.path.isAbsolute(sdk_lib_dir_path)) return error.InstallationNotFound;
......@@ -985,7 +985,7 @@ const MsvcLibDir = struct {
985985 io.random(std.mem.asBytes(&guid));
986986
987987 var guid_buf: [38]u8 = undefined;
988 const guid_str = std.fmt.bufPrint(&guid_buf, "{f}", .{guid}) catch unreachable;
988 const guid_str = std.mem.print(&guid_buf, "{f}", .{guid}) catch unreachable;
989989
990990 var buf: std.ArrayList(u16) = .initBuffer(&key_path_buf);
991991 buf.appendSliceAssumeCapacity(L("\\REGISTRY\\A\\"));
lib/std/zig/system/windows.zig+1-1
......@@ -74,7 +74,7 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
7474
7575 const max_cpu_buf = 4;
7676 var next_cpu_buf: [max_cpu_buf]u8 = undefined;
77 const next_cpu = try std.fmt.bufPrint(&next_cpu_buf, "{d}", .{core});
77 const next_cpu = try std.mem.print(&next_cpu_buf, "{d}", .{core});
7878
7979 var subkey: [max_cpu_buf + 1]u16 = undefined;
8080 const subkey_len = try std.unicode.utf8ToUtf16Le(&subkey, next_cpu);
src/Compilation.zig+1-1
......@@ -3821,7 +3821,7 @@ pub fn saveState(comp: *Compilation) !void {
38213821 }
38223822
38233823 var basename_buf: [255]u8 = undefined;
3824 const basename = std.fmt.bufPrint(&basename_buf, "{s}.zcs", .{
3824 const basename = std.mem.print(&basename_buf, "{s}.zcs", .{
38253825 comp.root_name,
38263826 }) catch o: {
38273827 basename_buf[basename_buf.len - 4 ..].* = ".zcs".*;
src/IncrementalDebugServer.zig+2-2
......@@ -405,10 +405,10 @@ fn parseAnalUnit(str: []const u8) ?AnalUnit {
405405}
406406fn printAnalUnit(unit: AnalUnit, buf: *[32]u8) []const u8 {
407407 const idx: u32 = switch (unit.unwrap()) {
408 .memoized_state => |stage| return std.fmt.bufPrint(buf, "memoized_state {s}", .{@tagName(stage)}) catch unreachable,
408 .memoized_state => |stage| return std.mem.print(buf, "memoized_state {s}", .{@tagName(stage)}) catch unreachable,
409409 inline else => |i| @backingInt(i),
410410 };
411 return std.fmt.bufPrint(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable;
411 return std.mem.print(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable;
412412}
413413
414414fn printType(ty: Type, zcu: *const Zcu, w: *Io.Writer) Io.Writer.Error!void {
src/InternPool.zig+1-1
......@@ -11384,7 +11384,7 @@ pub fn getOrPutStringFmt(
1138411384 const len: u32 = @intCast(std.fmt.count(format_z, args));
1138511385 const string_bytes = ip.getLocal(tid).getMutableStringBytes(gpa, io);
1138611386 const slice = try string_bytes.addManyAsSlice(len);
11387 assert((std.fmt.bufPrint(slice[0], format_z, args) catch unreachable).len == len);
11387 assert((std.mem.print(slice[0], format_z, args) catch unreachable).len == len);
1138811388 return ip.getOrPutTrailingString(gpa, io, tid, len, embedded_nulls);
1138911389}
1139011390
src/codegen/aarch64/Assemble.zig+2-2
......@@ -83,7 +83,7 @@ fn zonCast(comptime Result: type, zon_value: anytype, symbols: anytype) Result {
8383 .unsigned => std.math.maxInt(Symbol),
8484 }})
8585 ]u8 = undefined;
86 return std.meta.stringToEnum(Result, std.fmt.bufPrint(&buf, "{d}", .{symbol}) catch unreachable).?;
86 return std.meta.stringToEnum(Result, std.mem.print(&buf, "{d}", .{symbol}) catch unreachable).?;
8787 },
8888 else => return symbol,
8989 },
......@@ -256,7 +256,7 @@ fn nextToken(as: *Assemble, buf: *[token_buf_len]u8, comptime opts: struct {
256256 switch (modified_operand) {
257257 .register => |reg| {
258258 as.source = as.source[index + 1 ..];
259 return std.fmt.bufPrint(buf, "{f}", .{reg.fmt()}) catch unreachable;
259 return std.mem.print(buf, "{f}", .{reg.fmt()}) catch unreachable;
260260 },
261261 }
262262 } else continue :c invalid_syntax,
src/codegen/c.zig+2-2
......@@ -7467,7 +7467,7 @@ const StringLiteral = struct {
74677467 },
74687468 else => {
74697469 var buf: [4]u8 = undefined;
7470 const printed = std.fmt.bufPrint(&buf, "\\{o:0>3}", .{c}) catch unreachable;
7470 const printed = std.mem.print(&buf, "\\{o:0>3}", .{c}) catch unreachable;
74717471 try w.writeAll(printed);
74727472 return printed.len;
74737473 },
......@@ -7489,7 +7489,7 @@ const StringLiteral = struct {
74897489 } else {
74907490 if (!sl.first) try sl.w.writeByte(',');
74917491 var buf: [6]u8 = undefined;
7492 const printed = std.fmt.bufPrint(&buf, "'\\x{x}'", .{c}) catch unreachable;
7492 const printed = std.mem.print(&buf, "'\\x{x}'", .{c}) catch unreachable;
74937493 try sl.w.writeAll(printed);
74947494 sl.cur_len += printed.len;
74957495 sl.first = false;
src/codegen/x86_64/CodeGen.zig+1-1
......@@ -178194,7 +178194,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
178194178194 inline for (@typeInfo(encoder.Instruction.Mnemonic).@"enum".field_names) |mnem_name|
178195178195 max_mnem_len = @max(mnem_name.len, max_mnem_len);
178196178196 var intel_mnem_buf: [max_mnem_len + 1]u8 = undefined;
178197 const intel_mnem_str = std.fmt.bufPrint(&intel_mnem_buf, "{s}{c}", .{
178197 const intel_mnem_str = std.mem.print(&intel_mnem_buf, "{s}{c}", .{
178198178198 @tagName(mnem_tag),
178199178199 @as(u8, switch (mnem_size.size) {
178200178200 .byte => 'b',
src/libs/freebsd.zig+1-1
......@@ -975,7 +975,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
975975 }
976976
977977 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "stdthreads", etc.
978 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
978 const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
979979 try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
980980 try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
981981 }
src/libs/glibc.zig+1-1
......@@ -1124,7 +1124,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
11241124 }
11251125
11261126 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
1127 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
1127 const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
11281128 try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
11291129 try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
11301130 }
src/libs/mingw/Preprocessor.zig+2-2
......@@ -92,9 +92,9 @@ fn addTokenAssumeCapacity(pp: *Preprocessor, tok: Token) void {
9292
9393fn defineBuiltins(pp: *Preprocessor) !void {
9494 var buf: [5]u8 = undefined;
95 var val = std.fmt.bufPrint(&buf, "{d}", .{pp.target.cTypeByteSize(.longdouble).?}) catch unreachable;
95 var val = std.mem.print(&buf, "{d}", .{pp.target.cTypeByteSize(.longdouble).?}) catch unreachable;
9696 try pp.defineBuiltinValue("__SIZEOF_LONG_DOUBLE__", val, .pp_num);
97 val = std.fmt.bufPrint(&buf, "{d}", .{pp.target.cTypeByteSize(.double).?}) catch unreachable;
97 val = std.mem.print(&buf, "{d}", .{pp.target.cTypeByteSize(.double).?}) catch unreachable;
9898 try pp.defineBuiltinValue("__SIZEOF_DOUBLE__", val, .pp_num);
9999
100100 if (pp.target.abi.isGnu()) {
src/libs/netbsd.zig+1-1
......@@ -636,7 +636,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
636636 }
637637
638638 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
639 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
639 const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
640640 try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
641641 try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
642642 }
src/libs/openbsd.zig+1-1
......@@ -557,7 +557,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
557557 }
558558
559559 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
560 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
560 const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
561561 try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
562562 try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
563563 }
src/link/Coff.zig+3-3
......@@ -5994,7 +5994,7 @@ fn resolve(coff: *Coff, tid: Zcu.PerThread.Id) !bool {
59945994 };
59955995 var name: [std.Progress.Node.max_name_len]u8 = undefined;
59965996 const sub_prog_node = coff.synth_prog_node.start(
5997 std.fmt.bufPrint(&name, "lazy {s} for {f}", .{
5997 std.mem.print(&name, "lazy {s} for {f}", .{
59985998 kind,
59995999 Type.fromInterned(lmr.lazySymbol(coff).ty).fmt(pt),
60006000 }) catch &name,
......@@ -6132,7 +6132,7 @@ fn idleProgNode(
61326132 inline .pseudo_section, .object_section => |smi| smi.name(coff).toSlice(coff),
61336133 .input_section => |isi| {
61346134 const ioi = isi.input(coff);
6135 break :name std.fmt.bufPrint(&name, "{f}{f} {s}", .{
6135 break :name std.mem.print(&name, "{f}{f} {s}", .{
61366136 ioi.path(coff).fmtEscapeString(),
61376137 fmtMemberNameString(ioi.memberName(coff)),
61386138 coff.getNode(isi.symbol(coff).node(coff).parent(&coff.mf).unwrap().?).object_section.name(coff).toSlice(coff),
......@@ -6143,7 +6143,7 @@ fn idleProgNode(
61436143 const ip = &coff.base.comp.zcu.?.intern_pool;
61446144 break :name ip.getNav(nmi.navIndex(coff)).fqn.toSlice(ip);
61456145 },
6146 .uav => |umi| std.fmt.bufPrint(&name, "{f}", .{
6146 .uav => |umi| std.mem.print(&name, "{f}", .{
61476147 Value.fromInterned(umi.uavValue(coff)).fmtValue(.{
61486148 .zcu = coff.base.comp.zcu.?,
61496149 .tid = tid,
src/link/Dwarf.zig+3-3
......@@ -3834,7 +3834,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
38343834 .field);
38353835 {
38363836 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
3837 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{field_index}) catch unreachable;
3837 const field_name = std.mem.print(&field_name_buf, "{d}", .{field_index}) catch unreachable;
38383838 try wip_nav.strp(field_name);
38393839 }
38403840 try wip_nav.refType(field_type);
......@@ -4456,7 +4456,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
44564456 .tuple_index => |index| {
44574457 try wip_nav.abbrevCode(.access);
44584458 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
4459 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{index}) catch unreachable;
4459 const field_name = std.mem.print(&field_name_buf, "{d}", .{index}) catch unreachable;
44604460 try wip_nav.strp(field_name);
44614461 },
44624462 };
......@@ -4551,7 +4551,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co
45514551 continue);
45524552 {
45534553 var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined;
4554 const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{field_index}) catch unreachable;
4554 const field_name = std.mem.print(&field_name_buf, "{d}", .{field_index}) catch unreachable;
45554555 try wip_nav.strp(field_name);
45564556 }
45574557 const field_value: Value = .fromInterned(switch (aggregate.storage) {
src/link/Elf/ZigObject.zig+1-1
......@@ -1026,7 +1026,7 @@ pub fn lowerUav(
10261026 };
10271027
10281028 var name_buf: [32]u8 = undefined;
1029 const name = std.fmt.bufPrint(&name_buf, "__anon_{d}", .{
1029 const name = std.mem.print(&name_buf, "__anon_{d}", .{
10301030 @backingInt(uav),
10311031 }) catch unreachable;
10321032 const sym_index = self.lowerConst(
src/link/Elf2.zig+5-5
......@@ -3026,7 +3026,7 @@ fn lazySymbolInner(elf: *Elf, lazy: link.File.LazySymbol) Error!link.File.Symbol
30263026 };
30273027 const node = try shndx.get(elf).ni.addFloatingChild(&elf.mf, gpa, .{});
30283028 var name_buf: [64]u8 = undefined;
3029 const name = std.fmt.bufPrint(
3029 const name = std.mem.print(
30303030 &name_buf,
30313031 "__lazy_{t}_{d}",
30323032 .{ lazy.kind, @backingInt(lazy.ty) },
......@@ -5361,7 +5361,7 @@ fn uavMapIndex(
53615361 .alignment = resolved_align,
53625362 });
53635363 var name_buf: [32]u8 = undefined;
5364 const name = std.fmt.bufPrint(
5364 const name = std.mem.print(
53655365 &name_buf,
53665366 "__anon_{d}",
53675367 .{@backingInt(uav_val)},
......@@ -7916,13 +7916,13 @@ fn idleProgNode(
79167916 return prog_node.start(name: switch (node) {
79177917 else => |tag| @tagName(tag),
79187918 .section => |shndx| shndx.name(elf).slice(elf),
7919 .archive_input_member => |ii| std.fmt.bufPrint(&name, "{f}{f}", .{
7919 .archive_input_member => |ii| std.mem.print(&name, "{f}{f}", .{
79207920 ii.path(elf).fmtEscapeString(),
79217921 fmtMemberString(ii.member(elf)),
79227922 }) catch &name,
79237923 .input_section => |isi| {
79247924 const ii = isi.input(elf);
7925 break :name std.fmt.bufPrint(&name, "{f}{f} {s}", .{
7925 break :name std.mem.print(&name, "{f}{f} {s}", .{
79267926 ii.path(elf).fmtEscapeString(),
79277927 fmtMemberString(ii.member(elf)),
79287928 elf.getNode(isi.node(elf).parent(&elf.mf).unwrap().?).section.name(elf).slice(elf),
......@@ -7932,7 +7932,7 @@ fn idleProgNode(
79327932 const ip = &elf.base.comp.zcu.?.intern_pool;
79337933 break :name ip.getNav(nmi.navIndex(elf)).fqn.toSlice(ip);
79347934 },
7935 .uav => |umi| std.fmt.bufPrint(&name, "{f}", .{
7935 .uav => |umi| std.mem.print(&name, "{f}", .{
79367936 Value.fromInterned(umi.uavValue(elf)).fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }),
79377937 }) catch &name,
79387938 }, 0);
src/link/MachO/Dylib.zig+2-2
......@@ -844,7 +844,7 @@ pub const Id = struct {
844844 allocator.free(id.name);
845845 }
846846
847 pub const ParseError = fmt.ParseIntError || fmt.BufPrintError;
847 pub const ParseError = fmt.ParseIntError || mem.PrintError;
848848
849849 pub fn parseCurrentVersion(id: *Id, version: anytype) ParseError!void {
850850 id.current_version = try parseVersion(version);
......@@ -865,7 +865,7 @@ pub const Id = struct {
865865 },
866866 .float => |float| {
867867 var buf: [256]u8 = undefined;
868 break :blk try fmt.bufPrint(&buf, "{d}", .{float});
868 break :blk try mem.print(&buf, "{d}", .{float});
869869 },
870870 .string => |string| {
871871 break :blk string;
src/link/MachO/ZigObject.zig+1-1
......@@ -720,7 +720,7 @@ pub fn lowerUav(
720720 }
721721
722722 var name_buf: [32]u8 = undefined;
723 const name = std.fmt.bufPrint(&name_buf, "__anon_{d}", .{
723 const name = std.mem.print(&name_buf, "__anon_{d}", .{
724724 @backingInt(uav),
725725 }) catch unreachable;
726726 const sym_index = self.lowerConst(
src/link/Wasm.zig+3-3
......@@ -1374,7 +1374,7 @@ pub const GlobalImport = extern struct {
13741374 .__tls_base => @tagName(Unpacked.__tls_base),
13751375 .__tls_size => @tagName(Unpacked.__tls_size),
13761376 .object_global => |i| i.name(wasm).slice(wasm),
1377 inline .uav_obj, .uav_exe => |i| std.fmt.bufPrint(
1377 inline .uav_obj, .uav_exe => |i| std.mem.print(
13781378 buf,
13791379 "__anon_{d}",
13801380 .{@backingInt(i.key(wasm).*)},
......@@ -1997,7 +1997,7 @@ pub const ObjectDataImport = extern struct {
19971997 .__heap_base => @tagName(.__heap_base),
19981998 .__heap_end => @tagName(.__heap_end),
19991999 .__wasm_first_page_end => @tagName(.__wasm_first_page_end),
2000 inline .uav_exe, .uav_obj => |i| std.fmt.bufPrint(
2000 inline .uav_exe, .uav_obj => |i| std.mem.print(
20012001 buf,
20022002 "__anon_{d}",
20032003 .{@backingInt(i.key(wasm).*)},
......@@ -4348,7 +4348,7 @@ pub fn internString(wasm: *Wasm, bytes: []const u8) Allocator.Error!String {
43484348// TODO implement instead by appending to string_bytes
43494349pub fn internStringFmt(wasm: *Wasm, comptime format: []const u8, args: anytype) Allocator.Error!String {
43504350 var buffer: [32]u8 = undefined;
4351 const slice = std.fmt.bufPrint(&buffer, format, args) catch unreachable;
4351 const slice = std.mem.print(&buffer, format, args) catch unreachable;
43524352 return internString(wasm, slice);
43534353}
43544354
src/link/Wasm/Flush.zig+2-2
......@@ -1706,14 +1706,14 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
17061706 var id: [16]u8 = undefined;
17071707 std.crypto.hash.sha3.TurboShake128(null).hash(binary_bytes.items, &id, .{});
17081708 var uuid: [36]u8 = undefined;
1709 _ = try std.fmt.bufPrint(&uuid, "{x}-{x}-{x}-{x}-{x}", .{
1709 _ = try std.mem.print(&uuid, "{x}-{x}-{x}-{x}-{x}", .{
17101710 id[0..4], id[4..6], id[6..8], id[8..10], id[10..],
17111711 });
17121712 try emitBuildIdSection(gpa, binary_bytes, &uuid);
17131713 },
17141714 .hexstring => |hs| {
17151715 var buffer: [32 * 2]u8 = undefined;
1716 const str = std.fmt.bufPrint(&buffer, "{x}", .{hs.toSlice()}) catch unreachable;
1716 const str = std.mem.print(&buffer, "{x}", .{hs.toSlice()}) catch unreachable;
17171717 try emitBuildIdSection(gpa, binary_bytes, str);
17181718 },
17191719 else => |mode| {
src/tracy.zig+1-1
......@@ -23,7 +23,7 @@ const ___tracy_c_zone_context = extern struct {
2323
2424 pub inline fn addTextFmt(self: @This(), comptime fmt: []const u8, args: anytype) void {
2525 var buf: [512]u8 = undefined;
26 const slice = std.fmt.bufPrint(&buf, fmt, args) catch &buf;
26 const slice = std.mem.print(&buf, fmt, args) catch &buf;
2727 self.addText(slice);
2828 }
2929
test/standalone/emit_llvm_no_bin/main.zig+1-1
......@@ -2,5 +2,5 @@ const std = @import("std");
22
33export fn strFromFloatHelp(float: f64) void {
44 var buf: [400]u8 = undefined;
5 _ = std.fmt.bufPrint(&buf, "{d}", .{float}) catch unreachable;
5 _ = std.mem.print(&buf, "{d}", .{float}) catch unreachable;
66}