diff --git a/doc/langref/test_slices.zig b/doc/langref/test_slices.zig index a5ac8cb9267065de3c73c5edf0326afeda6e890a..7ad41a81cbe81b4d6acf4198b1e78d4843af3ef2 100644 --- a/doc/langref/test_slices.zig +++ b/doc/langref/test_slices.zig @@ -1,7 +1,7 @@ const std = @import("std"); const expectEqual = std.testing.expectEqual; const expectEqualStrings = std.testing.expectEqualStrings; -const fmt = std.fmt; +const mem = std.mem; test "using slices for strings" { // Zig has no concept of strings. String literals are const pointers @@ -18,7 +18,7 @@ test "using slices for strings" { _ = &start; const all_together_slice = all_together[start..]; // String concatenation example. - const hello_world = try fmt.bufPrint(all_together_slice, "{s} {s}", .{ hello, world }); + const hello_world = try mem.print(all_together_slice, "{s} {s}", .{ hello, world }); // Generally, you can use UTF-8 and not worry about whether something is a // string. If you don't need to deal with individual characters, no need diff --git a/lib/build-web/main.zig b/lib/build-web/main.zig index 865404e3a41142b7011b09f1095c413e695a3c7b..3556d4e2da967e58331d8ea7e793d1053953761d 100644 --- a/lib/build-web/main.zig +++ b/lib/build-web/main.zig @@ -56,7 +56,7 @@ fn logFn( const level_txt = comptime message_level.asText(); const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; var buf: [500]u8 = undefined; - const line = std.fmt.bufPrint(&buf, level_txt ++ prefix2 ++ format, args) catch l: { + const line = std.mem.print(&buf, level_txt ++ prefix2 ++ format, args) catch l: { buf[buf.len - 3 ..][0..3].* = "...".*; break :l &buf; }; @@ -116,7 +116,7 @@ pub fn Slice(T: type) type { pub fn fatal(comptime format: []const u8, args: anytype) noreturn { var buf: [500]u8 = undefined; - const line = std.fmt.bufPrint(&buf, format, args) catch l: { + const line = std.mem.print(&buf, format, args) catch l: { buf[buf.len - 3 ..][0..3].* = "...".*; break :l &buf; }; diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 4d4577f2f179ce0b9af9390a19de77324ad8535f..55c88d1233decbf9b352087e2aa3a8d614158367 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -959,7 +959,7 @@ pub fn main(init: process.Init.Minimal) !void { // trigger a rebuild on all steps with modified inputs, as well as their // recursive dependants. var caption_buf: [std.Progress.Node.max_name_len]u8 = undefined; - const caption = std.fmt.bufPrint(&caption_buf, "watching {d} directories, {d} processes", .{ + const caption = std.mem.print(&caption_buf, "watching {d} directories, {d} processes", .{ w.dir_count, countSubProcesses(&maker), }) catch &caption_buf; var debouncing_node = main_progress_node.start(caption, 0); diff --git a/lib/compiler/Maker/Fetch.zig b/lib/compiler/Maker/Fetch.zig index f18071ad6ef100b58cc4952b4b603e3105898868..5d3e80e25ee3becf1b308aa4917fe6a5c92781b2 100644 --- a/lib/compiler/Maker/Fetch.zig +++ b/lib/compiler/Maker/Fetch.zig @@ -362,7 +362,7 @@ pub const JobQueue = struct { var dest_sub_path_buf: ["p/".len + Package.Hash.max_len + ".tar.gz".len]u8 = undefined; const dest_path: Path = .{ .root_dir = jq.global_cache, - .sub_path = std.fmt.bufPrint(&dest_sub_path_buf, "p/{s}.tar.gz", .{pkg_hash_slice}) catch unreachable, + .sub_path = std.mem.print(&dest_sub_path_buf, "p/{s}.tar.gz", .{pkg_hash_slice}) catch unreachable, }; const gpa = jq.http_client.allocator; @@ -843,7 +843,7 @@ pub fn computedPackageHash(f: *const Fetch) Package.Hash { if (f.have_manifest) { const man = &f.manifest; var version_buffer: [32]u8 = undefined; - const version: []const u8 = std.fmt.bufPrint(&version_buffer, "{f}", .{man.version}) catch &version_buffer; + const version: []const u8 = std.mem.print(&version_buffer, "{f}", .{man.version}) catch &version_buffer; return .init(f.computed_hash.digest, man.name, version, man.id, saturated_size); } // In the future build.zig.zon fields will be added to allow overriding these values diff --git a/lib/compiler/Maker/Fetch/git.zig b/lib/compiler/Maker/Fetch/git.zig index 89f5bb6d86f4ef592bb42bbe7584fb2e06863da4..d332dfb2650b54e7d439183a8f7f8c82622156a9 100644 --- a/lib/compiler/Maker/Fetch/git.zig +++ b/lib/compiler/Maker/Fetch/git.zig @@ -1008,7 +1008,7 @@ pub const Session = struct { } for (wants) |want| { var buf: [Packet.max_data_length]u8 = undefined; - const arg = std.fmt.bufPrint(&buf, "want {s}\n", .{want}) catch unreachable; + const arg = std.mem.print(&buf, "want {s}\n", .{want}) catch unreachable; try Packet.write(.{ .data = arg }, &body); } try Packet.write(.{ .data = "done\n" }, &body); diff --git a/lib/compiler/Maker/Package.zig b/lib/compiler/Maker/Package.zig index 7b48056f29121f5d5001fc17f5686812a4052bb5..8baef22f375f925534380176f618a470f988117e 100644 --- a/lib/compiler/Maker/Package.zig +++ b/lib/compiler/Maker/Package.zig @@ -130,7 +130,7 @@ pub const Hash = struct { } var bin_digest: [Algo.digest_length]u8 = undefined; Algo.hash(sub_path, &bin_digest, .{}); - _ = std.fmt.bufPrint(result.bytes[i..], "{x}", .{&bin_digest}) catch unreachable; + _ = std.mem.print(result.bytes[i..], "{x}", .{&bin_digest}) catch unreachable; return result; } diff --git a/lib/compiler/Maker/Step/Compile.zig b/lib/compiler/Maker/Step/Compile.zig index 806b2d0f358f8bc52ee8b5ba5a59c90125bd191e..da5b70b062f10be5560950bc4e7f55f1cf0be5cc 100644 --- a/lib/compiler/Maker/Step/Compile.zig +++ b/lib/compiler/Maker/Step/Compile.zig @@ -892,7 +892,7 @@ fn lowerZigArgs( var args_hash: [Sha256.digest_length]u8 = undefined; Sha256.hash(args, &args_hash, .{}); var args_hex_hash: [Sha256.digest_length * 2]u8 = undefined; - _ = std.fmt.bufPrint(&args_hex_hash, "{x}", .{&args_hash}) catch unreachable; + _ = std.mem.print(&args_hex_hash, "{x}", .{&args_hash}) catch unreachable; const args_file = "args" ++ Dir.path.sep_str ++ args_hex_hash; local_cache_root.handle.access(io, args_file, .{}) catch { diff --git a/lib/compiler/Maker/Step/Run.zig b/lib/compiler/Maker/Step/Run.zig index 85087be4d06ff29c71eabebd303e9ba6077dd1f9..7e97c300520404dde5df16eebbc13ddca947c7a3 100644 --- a/lib/compiler/Maker/Step/Run.zig +++ b/lib/compiler/Maker/Step/Run.zig @@ -971,7 +971,7 @@ const FuzzTestRunner = struct { i += 1; }) { const name_prefix = "f" ++ Dir.path.sep_str ++ "in"; - in_name = std.fmt.bufPrint(&in_name_buf, name_prefix ++ "{x}", .{i}) catch unreachable; + in_name = std.mem.print(&in_name_buf, name_prefix ++ "{x}", .{i}) catch unreachable; in_f = cache_root.handle.openFile(io, in_name, .{ .lock = .exclusive, .lock_nonblocking = true, diff --git a/lib/compiler/Maker/Watch.zig b/lib/compiler/Maker/Watch.zig index fe44e9c2055ba839e57128dd8ff668fa5ad5d72d..563c74a64e5edb1397e25c7a17b4ba9439d8d314 100644 --- a/lib/compiler/Maker/Watch.zig +++ b/lib/compiler/Maker/Watch.zig @@ -145,7 +145,7 @@ const Os = switch (builtin.os.tag) { fn getDirHandle(gpa: Allocator, path: std.Build.Cache.Path, mount_id: *MountId) !FileHandle { var file_handle_buffer: [@sizeOf(std.os.linux.file_handle) + 128]u8 align(@alignOf(std.os.linux.file_handle)) = undefined; var buf: [std.fs.max_path_bytes]u8 = undefined; - const adjusted_path = if (path.sub_path.len == 0) "./" else std.fmt.bufPrint(&buf, "{s}/", .{ + const adjusted_path = if (path.sub_path.len == 0) "./" else std.mem.print(&buf, "{s}/", .{ path.sub_path, }) catch return error.NameTooLong; const stack_ptr: *std.os.linux.file_handle = @ptrCast(&file_handle_buffer); diff --git a/lib/compiler/objcopy.zig b/lib/compiler/objcopy.zig index fcc55891aa430ee4d53170036a2f8f476b75def3..7ca09e6b48ed69685ecc73c5a0787b6fae7da885 100644 --- a/lib/compiler/objcopy.zig +++ b/lib/compiler/objcopy.zig @@ -615,7 +615,7 @@ const HexWriter = struct { const payload_bytes = self.getPayloadBytes(); assert(payload_bytes.len <= max_payload_len); - const line = try std.fmt.bufPrint(&outbuf, ":{0X:0>2}{1X:0>4}{2X:0>2}{3X}{4X:0>2}" ++ linesep, .{ + const line = try std.mem.print(&outbuf, ":{0X:0>2}{1X:0>4}{2X:0>2}{3X}{4X:0>2}" ++ linesep, .{ @as(u8, @intCast(payload_bytes.len)), self.address, @backingInt(self.payload), diff --git a/lib/compiler/resinator/cvtres.zig b/lib/compiler/resinator/cvtres.zig index 29d9e14ce8c0cfe4662d6f03cc4c67f8350da173..621150815caa0d36b6dd36d4da87e4b5888f5902 100644 --- a/lib/compiler/resinator/cvtres.zig +++ b/lib/compiler/resinator/cvtres.zig @@ -883,7 +883,7 @@ const ResourceTree = struct { std.mem.writeInt(u32, name_buf[0..4], 0, .little); std.mem.writeInt(u32, name_buf[4..8], string_table_offset, .little); } else { - const name_slice = std.fmt.bufPrint(&name_buf, "$R{X:0>6}", .{relocation.data_offset}) catch unreachable; + const name_slice = std.mem.print(&name_buf, "$R{X:0>6}", .{relocation.data_offset}) catch unreachable; std.debug.assert(name_slice.len == 8); } diff --git a/lib/compiler/translate-c/MacroTranslator.zig b/lib/compiler/translate-c/MacroTranslator.zig index 04b0e9cb3d84a0d78566470e94a7f1ca565ec8b5..3cb46133b6e4422fc2ed253265d3399b5c95ccf1 100644 --- a/lib/compiler/translate-c/MacroTranslator.zig +++ b/lib/compiler/translate-c/MacroTranslator.zig @@ -583,7 +583,7 @@ fn escapeUnprintables(mt: *MacroTranslator) ![]const u8 { const formatter = std.ascii.hexEscape(zigified, .lower); const encoded_size = @as(usize, @intCast(std.fmt.count("{f}", .{formatter}))); const output = try mt.t.arena.alloc(u8, encoded_size); - return std.fmt.bufPrint(output, "{f}", .{formatter}) catch |err| switch (err) { + return std.mem.print(output, "{f}", .{formatter}) catch |err| switch (err) { error.NoSpaceLeft => unreachable, else => |e| return e, }; diff --git a/lib/docs/wasm/main.zig b/lib/docs/wasm/main.zig index aba4d2ac4ff5568a9aa072291dc33869af0f1c63..78b0ece8f76a6e55c64a5c2a3332d12f308d3f6a 100644 --- a/lib/docs/wasm/main.zig +++ b/lib/docs/wasm/main.zig @@ -48,7 +48,7 @@ fn logFn( ) void { const prefix = if (scope == .default) "" else @tagName(scope) ++ ": "; var buf: [500]u8 = undefined; - const line = std.fmt.bufPrint(&buf, prefix ++ format, args) catch l: { + const line = std.mem.print(&buf, prefix ++ format, args) catch l: { buf[buf.len - 3 ..][0..3].* = "...".*; break :l &buf; }; diff --git a/lib/fuzzer.zig b/lib/fuzzer.zig index cf051dca8ec935688551a6da922634ae3e8320df..bc40abe5bd24e25a2f7d7b3748fb411fdd905a7c 100644 --- a/lib/fuzzer.zig +++ b/lib/fuzzer.zig @@ -242,7 +242,7 @@ const Executable = struct { /// Asserts `buf[0..2]` is "in" fn inputFileName(buf: *[10]u8, i: u32) []u8 { assert(buf[0..2].* == "in".*); - const hex = std.fmt.bufPrint(buf[2..], "{x}", .{i}) catch unreachable; + const hex = std.mem.print(buf[2..], "{x}", .{i}) catch unreachable; return buf[0 .. 2 + hex.len]; } @@ -763,7 +763,7 @@ const Fuzzer = struct { const input_f = while (true) { var name_buf: [10]u8 = undefined; name_buf[0..2].* = "in".*; - const hex = std.fmt.bufPrint(name_buf[2..], "{x}", .{input_i}) catch unreachable; + const hex = std.mem.print(name_buf[2..], "{x}", .{input_i}) catch unreachable; const name = name_buf[0 .. 2 + hex.len]; if (exec.cache_f.createFile(io, name, .{ @@ -998,7 +998,7 @@ const Fuzzer = struct { } pub fn inputName(n: *CorpusFileName, i: u32) []u8 { - const hex = std.fmt.bufPrint(n.buf[Test.dirname_len + 1 ..][0..8], "{x}", .{i}) catch unreachable; + const hex = std.mem.print(n.buf[Test.dirname_len + 1 ..][0..8], "{x}", .{i}) catch unreachable; return n.buf[0 .. Test.dirname_len + 1 + hex.len]; } }; diff --git a/lib/std/Build/Cache/Path.zig b/lib/std/Build/Cache/Path.zig index 9d9501013cc20f09b53dc3ad54e5b9124883776d..2292c95667a6048e4fce00dbf06797af0519dfe9 100644 --- a/lib/std/Build/Cache/Path.zig +++ b/lib/std/Build/Cache/Path.zig @@ -61,7 +61,7 @@ pub fn joinStringZ(p: Path, gpa: Allocator, sub_path: []const u8) Allocator.Erro pub fn openFile(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.OpenFileOptions) !Io.File { var buf: [Io.Dir.max_path_bytes]u8 = undefined; const joined_path = if (p.sub_path.len == 0) sub_path else p: { - break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ + break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ p.sub_path, sub_path, }) catch return error.NameTooLong; }; @@ -76,7 +76,7 @@ pub fn openDir( ) Io.Dir.OpenError!Io.Dir { var buf: [Io.Dir.max_path_bytes]u8 = undefined; const joined_path = if (p.sub_path.len == 0) sub_path else p: { - break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ + break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ p.sub_path, sub_path, }) catch return error.NameTooLong; }; @@ -86,7 +86,7 @@ pub fn openDir( pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.CreateDirPathOpenOptions) !Io.Dir { var buf: [Io.Dir.max_path_bytes]u8 = undefined; const joined_path = if (p.sub_path.len == 0) sub_path else p: { - break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ + break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ p.sub_path, sub_path, }) catch return error.NameTooLong; }; @@ -96,7 +96,7 @@ pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.Cre pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat { var buf: [Io.Dir.max_path_bytes]u8 = undefined; const joined_path = if (p.sub_path.len == 0) sub_path else p: { - break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ + break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ p.sub_path, sub_path, }) catch return error.NameTooLong; }; @@ -111,7 +111,7 @@ pub fn atomicFile( buf: *[Io.Dir.max_path_bytes]u8, ) !Io.File.Atomic { const joined_path = if (p.sub_path.len == 0) sub_path else p: { - break :p std.fmt.bufPrint(buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ + break :p std.mem.print(buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ p.sub_path, sub_path, }) catch return error.NameTooLong; }; @@ -121,7 +121,7 @@ pub fn atomicFile( pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions) !void { var buf: [Io.Dir.max_path_bytes]u8 = undefined; const joined_path = if (p.sub_path.len == 0) sub_path else p: { - break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ + break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ p.sub_path, sub_path, }) catch return error.NameTooLong; }; @@ -131,7 +131,7 @@ pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions pub fn createDirPath(p: Path, io: Io, sub_path: []const u8) !void { var buf: [Io.Dir.max_path_bytes]u8 = undefined; const joined_path = if (p.sub_path.len == 0) sub_path else p: { - break :p std.fmt.bufPrint(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ + break :p std.mem.print(&buf, "{s}" ++ Io.Dir.path.sep_str ++ "{s}", .{ p.sub_path, sub_path, }) catch return error.NameTooLong; }; @@ -139,11 +139,11 @@ pub fn createDirPath(p: Path, io: Io, sub_path: []const u8) !void { } pub fn toString(p: Path, allocator: Allocator) Allocator.Error![]u8 { - return std.fmt.allocPrint(allocator, "{f}", .{p}); + return allocator.print("{f}", .{p}); } pub fn toStringZ(p: Path, allocator: Allocator) Allocator.Error![:0]u8 { - return std.fmt.allocPrintSentinel(allocator, "{f}", .{p}, 0); + return allocator.printSentinel("{f}", .{p}, 0); } pub fn fmtEscapeString(path: Path) std.fmt.Alt(Path, formatEscapeString) { diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index f4d7aeca42e1006a49fed13993ba123180260a30..5b1e5ba3fa3cc5168467322a799220096ebba8a5 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -7067,7 +7067,7 @@ fn realPathPosix(fd: posix.fd_t, out_buffer: []u8) File.RealPathError!usize { .linux, .serenity, .illumos => { var procfs_buf: ["/proc/self/path/-2147483648\x00".len]u8 = undefined; const template = if (native_os == .illumos) "/proc/self/path/{d}" else "/proc/self/fd/{d}"; - const proc_path = std.fmt.bufPrintSentinel(&procfs_buf, template, .{fd}, 0) catch unreachable; + const proc_path = std.mem.printSentinel(&procfs_buf, template, .{fd}, 0) catch unreachable; const syscall: Syscall = try .start(); while (true) { const rc = posix.system.readlink(proc_path, out_buffer.ptr, out_buffer.len); @@ -7155,7 +7155,7 @@ fn fileHardLink( error.FileNotFound => { if (options.follow_symlinks) return error.FileNotFound; var proc_buf: ["/proc/self/fd/-2147483648\x00".len]u8 = undefined; - const proc_path = std.fmt.bufPrintSentinel(&proc_buf, "/proc/self/fd/{d}", .{file.handle}, 0) catch + const proc_path = std.mem.printSentinel(&proc_buf, "/proc/self/fd/{d}", .{file.handle}, 0) catch unreachable; return linkat(posix.AT.FDCWD, proc_path, new_dir.handle, new_sub_path_posix, posix.AT.SYMLINK_FOLLOW); }, @@ -8633,7 +8633,7 @@ fn fchmodatFallback( return error.OperationUnsupported; var procfs_buf: ["/proc/self/fd/-2147483648\x00".len]u8 = undefined; - const proc_path = std.fmt.bufPrintSentinel(&procfs_buf, "/proc/self/fd/{d}", .{path_fd}, 0) catch unreachable; + const proc_path = std.mem.printSentinel(&procfs_buf, "/proc/self/fd/{d}", .{path_fd}, 0) catch unreachable; const syscall: Syscall = try .start(); while (true) { switch (posix.errno(posix.system.chmod(proc_path, mode))) { @@ -10633,7 +10633,7 @@ fn processExecutablePath(userdata: ?*anyopaque, out_buffer: []u8) process.Execut var it = std.mem.tokenizeScalar(u8, PATH, ':'); it: while (it.next()) |dir| { var resolved_path_buf: [std.c.PATH_MAX]u8 = undefined; - const resolved_path = std.fmt.bufPrintSentinel(&resolved_path_buf, "{s}/{s}", .{ + const resolved_path = std.mem.printSentinel(&resolved_path_buf, "{s}/{s}", .{ dir, argv0, }, 0) catch continue; @@ -14002,7 +14002,7 @@ fn netLookupFallible( const name_c = name_buffer[0..name.len :0]; var port_buffer: [8]u8 = undefined; - const port_c = std.fmt.bufPrintSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable; + const port_c = std.mem.printSentinel(&port_buffer, "{d}", .{options.port}, 0) catch unreachable; const family: i32 = if (options.family) |f| switch (f) { .ip4 => posix.AF.INET, diff --git a/lib/std/Io/Uring.zig b/lib/std/Io/Uring.zig index 421376f4e9c4c55d7b93d7a1703d67b5d536e058..e86852bb5197fb3105dc5c294068cf4a361a77f0 100644 --- a/lib/std/Io/Uring.zig +++ b/lib/std/Io/Uring.zig @@ -5793,7 +5793,7 @@ fn realPath( ) File.RealPathError!usize { _ = ev; var procfs_buf: [std.fmt.count("/proc/self/fd/{d}\x00", .{std.math.minInt(fd_t)})]u8 = undefined; - const proc_path = std.fmt.bufPrintSentinel(&procfs_buf, "/proc/self/fd/{d}", .{fd}, 0) catch + const proc_path = std.mem.printSentinel(&procfs_buf, "/proc/self/fd/{d}", .{fd}, 0) catch unreachable; while (true) { try sync.cancel_region.await(.nothing); diff --git a/lib/std/Io/net.zig b/lib/std/Io/net.zig index 779ad28a8eaae233782bc4b7181cb566ebd1ffd6..ebaab6de90cc3ef610e0245fe952a90011d6c9f1 100644 --- a/lib/std/Io/net.zig +++ b/lib/std/Io/net.zig @@ -1504,7 +1504,7 @@ fn testIp6ParseTransform(expected: []const u8, input: []const u8) !void { }, }; var buffer: [100]u8 = undefined; - const result = try std.fmt.bufPrint(&buffer, "{f}", .{ua}); + const result = try std.mem.print(&buffer, "{f}", .{ua}); try std.testing.expectEqualStrings(expected, result); } diff --git a/lib/std/Io/net/test.zig b/lib/std/Io/net/test.zig index 038269b30b3d7dcf927038bd6719357569eddd53..45389715cd749e77fe4ff99b088b92b78968e262 100644 --- a/lib/std/Io/net/test.zig +++ b/lib/std/Io/net/test.zig @@ -65,7 +65,7 @@ test "parse and render IPv6 addresses" { fn testParseAndRenderIp6Address(input: []const u8, expected_output: []const u8) !void { var buffer: [100]u8 = undefined; const parsed = net.Ip6Address.Unresolved.parse(input); - const actual_printed = try std.fmt.bufPrint(&buffer, "{f}", .{parsed.success}); + const actual_printed = try std.mem.print(&buffer, "{f}", .{parsed.success}); try testing.expectEqualStrings(expected_output, actual_printed); } @@ -115,7 +115,7 @@ test "parse and render IPv4 addresses" { fn testIp4ParseAndRender(text: []const u8) !void { var buffer: [18]u8 = undefined; const addr = try net.IpAddress.parseIp4(text, 0); - const rendered = try std.fmt.bufPrint(&buffer, "{f}", .{addr}); + const rendered = try std.mem.print(&buffer, "{f}", .{addr}); const without_port = rendered[0 .. rendered.len - 2]; try testing.expectEqualStrings(text, without_port); } diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig index a5df9ade3683f62660f90e147b7bad0c4765ab2a..33eb33cf6515dfb1742173b61bc52df73fc8b1c1 100644 --- a/lib/std/Progress.zig +++ b/lib/std/Progress.zig @@ -308,7 +308,7 @@ pub const Node = struct { pub fn startFmt(node: Node, estimated_total_items: usize, comptime format: []const u8, args: anytype) Node { var buffer: [max_name_len]u8 = undefined; - const name = std.fmt.bufPrint(&buffer, format, args) catch &buffer; + const name = std.mem.print(&buffer, format, args) catch &buffer; return Node.start(node, name, estimated_total_items); } @@ -1355,7 +1355,7 @@ fn computeRedraw(io: Io, serialized_buffer: *Serialized.Buffer) !struct { []u8, i += progress_pulsing.len; } else { const percent = @as(u64, completed_items) * 100 / estimated_total; - if (std.fmt.bufPrint(buf[i..], @"progress_normal {d}", .{percent})) |b| { + if (std.mem.print(buf[i..], @"progress_normal {d}", .{percent})) |b| { i += b.len; } else |_| {} } @@ -1374,7 +1374,7 @@ fn computeRedraw(io: Io, serialized_buffer: *Serialized.Buffer) !struct { []u8, i += progress_pulsing_error.len; } else { const percent = @as(u64, completed_items) * 100 / estimated_total; - if (std.fmt.bufPrint(buf[i..], @"progress_error {d}", .{percent})) |b| { + if (std.mem.print(buf[i..], @"progress_error {d}", .{percent})) |b| { i += b.len; } else |_| {} } @@ -1475,16 +1475,16 @@ fn computeNode( if (!is_empty_root) { if (name.len != 0 or estimated_total > 0) { if (estimated_total > 0) { - if (std.fmt.bufPrint(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total })) |b| { + if (std.mem.print(buf[i..], "[{d}/{d}] ", .{ completed_items, estimated_total })) |b| { i += b.len; } else |_| {} } else if (completed_items != 0) { - if (std.fmt.bufPrint(buf[i..], "[{d}] ", .{completed_items})) |b| { + if (std.mem.print(buf[i..], "[{d}] ", .{completed_items})) |b| { i += b.len; } else |_| {} } if (name.len != 0) { - if (std.fmt.bufPrint(buf[i..], "{s}", .{name})) |b| { + if (std.mem.print(buf[i..], "{s}", .{name})) |b| { i += b.len; } else |_| {} } diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 62a6a61edafb4339db2e67ab5c62650f8ce26a27..6d9ffba84be193b15ad3149ae7914df4aaaea0f2 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -2437,7 +2437,7 @@ pub const DynamicLinker = struct { /// Asserts that the length is less than or equal to 255 bytes. pub fn setFmt(dl: *DynamicLinker, comptime fmt_str: []const u8, args: anytype) !void { - dl.len = @intCast((try std.fmt.bufPrint(&dl.buffer, fmt_str, args)).len); + dl.len = @intCast((try std.mem.print(&dl.buffer, fmt_str, args)).len); } pub fn eql(lhs: DynamicLinker, rhs: DynamicLinker) bool { diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 3c79bc68d4e9c09066d5b74a23a1dbf738a5258a..66a3662eedc92bae67d06cb9fac9625e8bde87ff 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -47,7 +47,7 @@ pub const SetNameError = error{ Unsupported, Unexpected, InvalidWtf8, -} || posix.PrctlError || Io.File.Writer.Error || Io.File.OpenError || std.fmt.BufPrintError; +} || posix.PrctlError || Io.File.Writer.Error || Io.File.OpenError || std.mem.PrintError; pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void { 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 { } } else { var buf: [32]u8 = undefined; - const path = try std.fmt.bufPrint(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()}); + const path = try std.mem.print(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()}); const file = try Io.Dir.cwd().openFile(io, path, .{ .mode = .write_only }); defer file.close(io); @@ -152,7 +152,7 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void { pub const GetNameError = error{ Unsupported, Unexpected, -} || posix.PrctlError || posix.ReadError || Io.File.OpenError || std.fmt.BufPrintError; +} || posix.PrctlError || posix.ReadError || Io.File.OpenError || std.mem.PrintError; /// On Windows, the result is encoded as [WTF-8](https://wtf-8.codeberg.page/). /// 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 } } else { var buf: [32]u8 = undefined; - const path = try std.fmt.bufPrint(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()}); + const path = try std.mem.print(&buf, "/proc/self/task/{d}/comm", .{self.getHandle()}); const io = std.Options.debug_io; diff --git a/lib/std/Uri.zig b/lib/std/Uri.zig index 6c4b1b2346e4cb955cecde24302bb4b15df4df18..2ba5b43538a52fa2a3e396da4cca63102299ab33 100644 --- a/lib/std/Uri.zig +++ b/lib/std/Uri.zig @@ -41,7 +41,7 @@ pub const Component = union(enum) { return switch (component) { .raw => |raw| raw, .percent_encoded => |percent_encoded| if (std.mem.findScalar(u8, percent_encoded, '%')) |_| - try std.fmt.bufPrint(buffer, "{f}", .{std.fmt.alt(component, .formatRaw)}) + try std.mem.print(buffer, "{f}", .{std.fmt.alt(component, .formatRaw)}) else percent_encoded, }; @@ -52,7 +52,7 @@ pub const Component = union(enum) { return switch (component) { .raw => |raw| raw, .percent_encoded => |percent_encoded| if (std.mem.findScalar(u8, percent_encoded, '%')) |_| - try std.fmt.allocPrint(arena, "{f}", .{std.fmt.alt(component, .formatRaw)}) + try arena.print("{f}", .{std.fmt.alt(component, .formatRaw)}) else percent_encoded, }; diff --git a/lib/std/crypto/25519/curve25519.zig b/lib/std/crypto/25519/curve25519.zig index bf6ed418bf4e4102789b5071be81821eb7ce7d06..293a0cefeaf4817b97ce28cff8b3b3018e1c012b 100644 --- a/lib/std/crypto/25519/curve25519.zig +++ b/lib/std/crypto/25519/curve25519.zig @@ -129,9 +129,9 @@ test "curve25519" { const p = try Curve25519.basePoint.clampedMul(s); try p.rejectIdentity(); var buf: [128]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&p.toBytes()}), "E6F2A4D1C28EE5C7AD0329268255A468AD407D2672824C0C0EB30EA6EF450145"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&p.toBytes()}), "E6F2A4D1C28EE5C7AD0329268255A468AD407D2672824C0C0EB30EA6EF450145"); const q = try p.clampedMul(s); - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&q.toBytes()}), "3614E119FFE55EC55B87D6B19971A9F4CBC78EFE80BEC55B96392BABCC712537"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&q.toBytes()}), "3614E119FFE55EC55B87D6B19971A9F4CBC78EFE80BEC55B96392BABCC712537"); try Curve25519.rejectNonCanonical(s); s[31] |= 0x80; diff --git a/lib/std/crypto/25519/ed25519.zig b/lib/std/crypto/25519/ed25519.zig index a224c70d903a14f0a5316f794dadd2e2dfed911c..38b9a50d989b281b56bd70b5e2a1d2fdfcaca6c3 100644 --- a/lib/std/crypto/25519/ed25519.zig +++ b/lib/std/crypto/25519/ed25519.zig @@ -585,8 +585,8 @@ test "key pair creation" { _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); const key_pair = try Ed25519.KeyPair.generateDeterministic(seed); var buf: [256]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&key_pair.secret_key.toBytes()}), "8052030376D47112BE7F73ED7A019293DD12AD910B654455798B4667D73DE1662D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083"); - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&key_pair.public_key.toBytes()}), "2D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&key_pair.secret_key.toBytes()}), "8052030376D47112BE7F73ED7A019293DD12AD910B654455798B4667D73DE1662D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&key_pair.public_key.toBytes()}), "2D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083"); } test "signature" { @@ -596,7 +596,7 @@ test "signature" { const sig = try key_pair.sign("test", null); var buf: [128]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&sig.toBytes()}), "10A442B4A80CC4225B154F43BEF28D2472CA80221951262EB8E0DF9091575E2687CC486E77263C3418C757522D54F84B0359236ABBBD4ACD20DC297FDCA66808"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&sig.toBytes()}), "10A442B4A80CC4225B154F43BEF28D2472CA80221951262EB8E0DF9091575E2687CC486E77263C3418C757522D54F84B0359236ABBBD4ACD20DC297FDCA66808"); try sig.verify("test", key_pair.public_key); try std.testing.expectError(error.SignatureVerificationFailed, sig.verify("TEST", key_pair.public_key)); } diff --git a/lib/std/crypto/25519/edwards25519.zig b/lib/std/crypto/25519/edwards25519.zig index 5ce1ee1153dfe1680d3d65bef1afec298f640281..a351b7db87880eb201c0889bcbb38f50b7221c5c 100644 --- a/lib/std/crypto/25519/edwards25519.zig +++ b/lib/std/crypto/25519/edwards25519.zig @@ -543,7 +543,7 @@ test "packing/unpacking" { var b = Edwards25519.basePoint; const pk = try b.mul(s); var buf: [128]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&pk.toBytes()}), "074BC7E0FCBD587FDBC0969444245FADC562809C8F6E97E949AF62484B5B81A6"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&pk.toBytes()}), "074BC7E0FCBD587FDBC0969444245FADC562809C8F6E97E949AF62484B5B81A6"); const small_order_ss: [7][32]u8 = .{ .{ diff --git a/lib/std/crypto/25519/ristretto255.zig b/lib/std/crypto/25519/ristretto255.zig index 8586685ebdd669f09388cb4a8761dd9ec055f95f..e69f806a62b9342d21994cadeab2c165e6197387 100644 --- a/lib/std/crypto/25519/ristretto255.zig +++ b/lib/std/crypto/25519/ristretto255.zig @@ -175,21 +175,21 @@ pub const Ristretto255 = struct { test "ristretto255" { const p = Ristretto255.basePoint; var buf: [256]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&p.toBytes()}), "E2F2AE0A6ABC4E71A884A961C500515F58E30B6AA582DD8DB6A65945E08D2D76"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&p.toBytes()}), "E2F2AE0A6ABC4E71A884A961C500515F58E30B6AA582DD8DB6A65945E08D2D76"); var r: [Ristretto255.encoded_length]u8 = undefined; _ = try fmt.hexToBytes(r[0..], "6a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b919"); var q = try Ristretto255.fromBytes(r); q = q.dbl().add(p); - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&q.toBytes()}), "E882B131016B52C1D3337080187CF768423EFCCBB517BB495AB812C4160FF44E"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&q.toBytes()}), "E882B131016B52C1D3337080187CF768423EFCCBB517BB495AB812C4160FF44E"); const s = [_]u8{15} ++ @as([31]u8, @splat(0)); const w = try p.mul(s); - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&w.toBytes()}), "E0C418F7C8D9C4CDD7395B93EA124F3AD99021BB681DFC3302A9D99A2E53E64E"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&w.toBytes()}), "E0C418F7C8D9C4CDD7395B93EA124F3AD99021BB681DFC3302A9D99A2E53E64E"); try std.testing.expect(p.dbl().dbl().dbl().dbl().equivalent(w.add(p))); const h = @as([32]u8, @splat(69)) ++ @as([32]u8, @splat(42)); const ph = Ristretto255.fromUniform(h); - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&ph.toBytes()}), "DCCA54E037A4311EFBEEF413ACD21D35276518970B7A61DC88F8587B493D5E19"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&ph.toBytes()}), "DCCA54E037A4311EFBEEF413ACD21D35276518970B7A61DC88F8587B493D5E19"); } diff --git a/lib/std/crypto/25519/scalar.zig b/lib/std/crypto/25519/scalar.zig index ba5335b8456a2c7065e247b22c507ee8cf8f7b1a..9e296257c1f863eebd062fa1a1737a4d4b32ed32 100644 --- a/lib/std/crypto/25519/scalar.zig +++ b/lib/std/crypto/25519/scalar.zig @@ -850,10 +850,10 @@ test "scalar25519" { var y = x.toBytes(); try rejectNonCanonical(y); var buf: [128]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&y}), "1E979B917937F3DE71D18077F961F6CEFF01030405060708010203040506070F"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&y}), "1E979B917937F3DE71D18077F961F6CEFF01030405060708010203040506070F"); const reduced = reduce(field_order_s); - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&reduced}), "0000000000000000000000000000000000000000000000000000000000000000"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&reduced}), "0000000000000000000000000000000000000000000000000000000000000000"); } test "non-canonical scalar25519" { @@ -867,7 +867,7 @@ test "mulAdd overflow check" { const c: [32]u8 = @splat(0xff); const x = mulAdd(a, b, c); var buf: [128]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&x}), "D14DF91389432C25AD60FF9791B9FD1D67BEF517D273ECCE3D9A307C1B419903"); + try std.testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&x}), "D14DF91389432C25AD60FF9791B9FD1D67BEF517D273ECCE3D9A307C1B419903"); } test "scalar field inversion" { diff --git a/lib/std/crypto/bcrypt.zig b/lib/std/crypto/bcrypt.zig index 55d00c1d279a1ecb30d1cd0125f940ca4b14f32c..6fa5f984734492c259b303f54960afdf5fbc131c 100644 --- a/lib/std/crypto/bcrypt.zig +++ b/lib/std/crypto/bcrypt.zig @@ -635,7 +635,7 @@ const crypt_format = struct { _ = Codec.Encoder.encode(&ct_str, dk[0..]); var s_buf: [hash_length]u8 = undefined; - const s = fmt.bufPrint( + const s = mem.print( s_buf[0..], "{s}b${d}{d}${s}{s}", .{ prefix, params.rounds_log / 10, params.rounds_log % 10, salt_str, ct_str }, diff --git a/lib/std/crypto/chacha20.zig b/lib/std/crypto/chacha20.zig index c14d944e1748780cdee7d1448e7a9cd399b0de1e..2da1bf5e2b99f3df6c08bbe04f6306ca35d43b32 100644 --- a/lib/std/crypto/chacha20.zig +++ b/lib/std/crypto/chacha20.zig @@ -1145,7 +1145,7 @@ test "xchacha20" { var c: [m.len]u8 = undefined; XChaCha20IETF.xor(c[0..], m[0..], 0, key, nonce); var buf: [2 * c.len]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&c}), "E0A1BCF939654AFDBDC1746EC49832647C19D891F0D1A81FC0C1703B4514BDEA584B512F6908C2C5E9DD18D5CBC1805DE5803FE3B9CA5F193FB8359E91FAB0C3BB40309A292EB1CF49685C65C4A3ADF4F11DB0CD2B6B67FBC174BC2E860E8F769FD3565BBFAD1C845E05A0FED9BE167C240D"); + try testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&c}), "E0A1BCF939654AFDBDC1746EC49832647C19D891F0D1A81FC0C1703B4514BDEA584B512F6908C2C5E9DD18D5CBC1805DE5803FE3B9CA5F193FB8359E91FAB0C3BB40309A292EB1CF49685C65C4A3ADF4F11DB0CD2B6B67FBC174BC2E860E8F769FD3565BBFAD1C845E05A0FED9BE167C240D"); } { const ad = "Additional data"; @@ -1154,7 +1154,7 @@ test "xchacha20" { var out: [m.len]u8 = undefined; try XChaCha20Poly1305.decrypt(out[0..], c[0..m.len], c[m.len..].*, ad, nonce, key); var buf: [2 * c.len]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&c}), "994D2DD32333F48E53650C02C7A2ABB8E018B0836D7175AEC779F52E961780768F815C58F1AA52D211498DB89B9216763F569C9433A6BBFCEFB4D4A49387A4C5207FBB3B5A92B5941294DF30588C6740D39DC16FA1F0E634F7246CF7CDCB978E44347D89381B7A74EB7084F754B90BDE9AAF5A94B8F2A85EFD0B50692AE2D425E234"); + try testing.expectEqualStrings(try std.mem.print(&buf, "{X}", .{&c}), "994D2DD32333F48E53650C02C7A2ABB8E018B0836D7175AEC779F52E961780768F815C58F1AA52D211498DB89B9216763F569C9433A6BBFCEFB4D4A49387A4C5207FBB3B5A92B5941294DF30588C6740D39DC16FA1F0E634F7246CF7CDCB978E44347D89381B7A74EB7084F754B90BDE9AAF5A94B8F2A85EFD0B50692AE2D425E234"); try testing.expectEqualSlices(u8, out[0..], m); c[0] +%= 1; try testing.expectError(error.AuthenticationFailed, XChaCha20Poly1305.decrypt(out[0..], c[0..m.len], c[m.len..].*, ad, nonce, key)); diff --git a/lib/std/crypto/ml_kem.zig b/lib/std/crypto/ml_kem.zig index 7105c043d8317e26d1552728c366559a64e6981f..f758576a2d45171018be2b2620a5292a2643be8e 100644 --- a/lib/std/crypto/ml_kem.zig +++ b/lib/std/crypto/ml_kem.zig @@ -1701,7 +1701,7 @@ fn testNistKat(mode: type, hash: []const u8) !void { var out: [32]u8 = undefined; fw.hasher.final(&out); var outHex: [64]u8 = undefined; - _ = try std.fmt.bufPrint(&outHex, "{x}", .{&out}); + _ = try std.mem.print(&outHex, "{x}", .{&out}); try testing.expectEqualStrings(&outHex, hash); } diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 9104a229b85c0839324deb34e536282e34a7baf9..b30da786b770ef75458387803be1e9aaaf1eb5ba 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -529,7 +529,7 @@ test "Dir.Iterator many entries" { var i: usize = 0; var buf: [4]u8 = undefined; // Enough to store "1024". while (i < num) : (i += 1) { - const name = try std.fmt.bufPrint(&buf, "{}", .{i}); + const name = try std.mem.print(&buf, "{}", .{i}); const file = try tmp_dir.dir.createFile(io, name, .{}); file.close(io); } @@ -551,7 +551,7 @@ test "Dir.Iterator many entries" { i = 0; while (i < num) : (i += 1) { - const name = try std.fmt.bufPrint(&buf, "{}", .{i}); + const name = try std.mem.print(&buf, "{}", .{i}); try expect(contains(&entries, .{ .name = name, .kind = .file, .inode = 0 })); } } diff --git a/lib/std/http/test.zig b/lib/std/http/test.zig index d0e28e61b5748c5eb6b46c8f6bef9329fb4e08e7..13f2fd1158b7adf89ac31152914f481cb45779f4 100644 --- a/lib/std/http/test.zig +++ b/lib/std/http/test.zig @@ -344,7 +344,7 @@ test "Server.Request.respondStreaming non-chunked, unknown content-length" { var total: usize = 0; for (0..500) |i| { var buf: [30]u8 = undefined; - const line = try std.fmt.bufPrint(&buf, "{d}, ah ha ha!\n", .{i}); + const line = try std.mem.print(&buf, "{d}, ah ha ha!\n", .{i}); try expected_response.appendSlice(line); total += line.len; } @@ -1017,7 +1017,7 @@ fn echoTests(client: *http.Client, port: u16) !void { try expect(client.http_proxy != null or client.connection_pool.free_len == 1); { // send chunked request - const uri = try std.Uri.parse(try std.fmt.bufPrint( + const uri = try std.Uri.parse(try std.mem.print( &location_buffer, "http://127.0.0.1:{d}/echo-content", .{port}, @@ -1213,7 +1213,7 @@ test "redirect to different connection" { defer stream.close(io); var loc_buf: [50]u8 = undefined; - const new_loc = try std.fmt.bufPrint(&loc_buf, "http://127.0.0.1:{d}/ok", .{ + const new_loc = try std.mem.print(&loc_buf, "http://127.0.0.1:{d}/ok", .{ global.other_port.?, }); @@ -1241,7 +1241,7 @@ test "redirect to different connection" { defer client.deinit(); var loc_buf: [100]u8 = undefined; - const location = try std.fmt.bufPrint(&loc_buf, "http://127.0.0.1:{d}/help", .{ + const location = try std.mem.print(&loc_buf, "http://127.0.0.1:{d}/help", .{ test_server_orig.port(), }); const uri = try std.Uri.parse(location); @@ -1300,7 +1300,7 @@ test "boot failed connections from the pool" { defer client.deinit(); var loc_buf: [100]u8 = undefined; - const location = try std.fmt.bufPrint(&loc_buf, "http://127.0.0.1:{d}/", .{ + const location = try std.mem.print(&loc_buf, "http://127.0.0.1:{d}/", .{ test_server_orig.port(), }); const uri = try std.Uri.parse(location); diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index ce570987c9283e87ff33a858007be693e9348c55..d7b4c61331b1d30eab3255183ca376a65a5f340c 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -5006,7 +5006,7 @@ pub const TEB = extern struct { }; comptime { - // 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. + // 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. if (builtin.os.tag == .windows) { // Offsets taken from WinDbg info and Geoff Chappell[1] (RIP) // [1]: https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm diff --git a/lib/std/process/Environ.zig b/lib/std/process/Environ.zig index a2b2f4110f499171a09ffb42c3d631f7e48faee7..157ee40a23ec15d4cf929023b879e64e6ddaae96 100644 --- a/lib/std/process/Environ.zig +++ b/lib/std/process/Environ.zig @@ -466,7 +466,7 @@ pub const Map = struct { ); i += "ZIG_PROGRESS=".len; var value_buf: [std.fmt.count("{d}", .{std.math.maxInt(usize)})]u8 = undefined; - const value = std.fmt.bufPrint(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable; + const value = std.mem.print(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable; for (block[i..][0..value.len], value) |*r, v| r.* = v; i += value.len; block[i] = 0; @@ -840,7 +840,7 @@ pub fn createWindowsBlock( @memcpy(block[i..][0..zig_progress_key.len], &zig_progress_key); i += zig_progress_key.len; var value_buf: [std.fmt.count("{d}", .{std.math.maxInt(usize)})]u8 = undefined; - const value = std.fmt.bufPrint(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable; + const value = std.mem.print(&value_buf, "{d}", .{@intFromPtr(handle)}) catch unreachable; for (block[i..][0..value.len], value) |*r, v| r.* = v; i += value.len; block[i] = 0; diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 0ee3617878d9aa6a580d30d82d7d5550e58c7bca..7c010cf4c5dd4c08e89604000f2a3d262f6f78ad 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -656,7 +656,7 @@ test expectError { pub fn expectFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void { if (@inComptime()) { var buffer: [std.fmt.count(template, args)]u8 = undefined; - return expectEqualStrings(expected, try std.fmt.bufPrint(&buffer, template, args)); + return expectEqualStrings(expected, try std.mem.print(&buffer, template, args)); } const actual = try std.fmt.allocPrint(allocator, template, args); defer allocator.free(actual); diff --git a/lib/std/zig/WindowsSdk.zig b/lib/std/zig/WindowsSdk.zig index 6b8afafd0892561e449f5bd6e40ca46d06d16cce..8a014f32eaac565990d69d42ed9017a234190870 100644 --- a/lib/std/zig/WindowsSdk.zig +++ b/lib/std/zig/WindowsSdk.zig @@ -513,7 +513,7 @@ pub const Installation = struct { const version = version: { var buf: [Dir.max_path_bytes]u8 = undefined; - const sdk_lib_dir_path = std.fmt.bufPrint(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) { + const sdk_lib_dir_path = std.mem.print(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) { error.NoSpaceLeft => return error.PathTooLong, }; if (!Dir.path.isAbsolute(sdk_lib_dir_path)) return error.InstallationNotFound; @@ -985,7 +985,7 @@ const MsvcLibDir = struct { io.random(std.mem.asBytes(&guid)); var guid_buf: [38]u8 = undefined; - const guid_str = std.fmt.bufPrint(&guid_buf, "{f}", .{guid}) catch unreachable; + const guid_str = std.mem.print(&guid_buf, "{f}", .{guid}) catch unreachable; var buf: std.ArrayList(u16) = .initBuffer(&key_path_buf); buf.appendSliceAssumeCapacity(L("\\REGISTRY\\A\\")); diff --git a/lib/std/zig/system/windows.zig b/lib/std/zig/system/windows.zig index 3f05ebb461f572271ec8312a9e66a3a1680d1f0c..ef07ed9d0f71e658198e65ff507a784ed601c021 100644 --- a/lib/std/zig/system/windows.zig +++ b/lib/std/zig/system/windows.zig @@ -74,7 +74,7 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void { const max_cpu_buf = 4; var next_cpu_buf: [max_cpu_buf]u8 = undefined; - const next_cpu = try std.fmt.bufPrint(&next_cpu_buf, "{d}", .{core}); + const next_cpu = try std.mem.print(&next_cpu_buf, "{d}", .{core}); var subkey: [max_cpu_buf + 1]u16 = undefined; const subkey_len = try std.unicode.utf8ToUtf16Le(&subkey, next_cpu); diff --git a/src/Compilation.zig b/src/Compilation.zig index d4d24e6640efd31032146b245c7a2bce64ba1fc1..a8b12da5e9fcccdcf34d1e6f42c34caf35c7c900 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3821,7 +3821,7 @@ pub fn saveState(comp: *Compilation) !void { } var basename_buf: [255]u8 = undefined; - const basename = std.fmt.bufPrint(&basename_buf, "{s}.zcs", .{ + const basename = std.mem.print(&basename_buf, "{s}.zcs", .{ comp.root_name, }) catch o: { basename_buf[basename_buf.len - 4 ..].* = ".zcs".*; diff --git a/src/IncrementalDebugServer.zig b/src/IncrementalDebugServer.zig index eac945285836813d0d9bc4fae8b549b3c15c76d3..c9302516c1fb433cc2a7bb4b11e61e3e86be9e7c 100644 --- a/src/IncrementalDebugServer.zig +++ b/src/IncrementalDebugServer.zig @@ -405,10 +405,10 @@ fn parseAnalUnit(str: []const u8) ?AnalUnit { } fn printAnalUnit(unit: AnalUnit, buf: *[32]u8) []const u8 { const idx: u32 = switch (unit.unwrap()) { - .memoized_state => |stage| return std.fmt.bufPrint(buf, "memoized_state {s}", .{@tagName(stage)}) catch unreachable, + .memoized_state => |stage| return std.mem.print(buf, "memoized_state {s}", .{@tagName(stage)}) catch unreachable, inline else => |i| @backingInt(i), }; - return std.fmt.bufPrint(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable; + return std.mem.print(buf, "{s} {d}", .{ @tagName(unit.unwrap()), idx }) catch unreachable; } fn printType(ty: Type, zcu: *const Zcu, w: *Io.Writer) Io.Writer.Error!void { diff --git a/src/InternPool.zig b/src/InternPool.zig index fd475c6391cab19462e5240b9cc70215b1ac3484..3451106fc2d00ab4be5642d729a7c15784b0d146 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -11384,7 +11384,7 @@ pub fn getOrPutStringFmt( const len: u32 = @intCast(std.fmt.count(format_z, args)); const string_bytes = ip.getLocal(tid).getMutableStringBytes(gpa, io); const slice = try string_bytes.addManyAsSlice(len); - assert((std.fmt.bufPrint(slice[0], format_z, args) catch unreachable).len == len); + assert((std.mem.print(slice[0], format_z, args) catch unreachable).len == len); return ip.getOrPutTrailingString(gpa, io, tid, len, embedded_nulls); } diff --git a/src/codegen/aarch64/Assemble.zig b/src/codegen/aarch64/Assemble.zig index 2d5cc913270f0259caa726e4073b34e1992fef8f..ec80072277625ee3f749d806534ec969587231fa 100644 --- a/src/codegen/aarch64/Assemble.zig +++ b/src/codegen/aarch64/Assemble.zig @@ -83,7 +83,7 @@ fn zonCast(comptime Result: type, zon_value: anytype, symbols: anytype) Result { .unsigned => std.math.maxInt(Symbol), }}) ]u8 = undefined; - return std.meta.stringToEnum(Result, std.fmt.bufPrint(&buf, "{d}", .{symbol}) catch unreachable).?; + return std.meta.stringToEnum(Result, std.mem.print(&buf, "{d}", .{symbol}) catch unreachable).?; }, else => return symbol, }, @@ -256,7 +256,7 @@ fn nextToken(as: *Assemble, buf: *[token_buf_len]u8, comptime opts: struct { switch (modified_operand) { .register => |reg| { as.source = as.source[index + 1 ..]; - return std.fmt.bufPrint(buf, "{f}", .{reg.fmt()}) catch unreachable; + return std.mem.print(buf, "{f}", .{reg.fmt()}) catch unreachable; }, } } else continue :c invalid_syntax, diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 93598ba8ca644be3f899b9131260ab4e3ad028f2..f4d724d4d6f766bb58818c0c33dbba915c7f2251 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -7467,7 +7467,7 @@ const StringLiteral = struct { }, else => { var buf: [4]u8 = undefined; - const printed = std.fmt.bufPrint(&buf, "\\{o:0>3}", .{c}) catch unreachable; + const printed = std.mem.print(&buf, "\\{o:0>3}", .{c}) catch unreachable; try w.writeAll(printed); return printed.len; }, @@ -7489,7 +7489,7 @@ const StringLiteral = struct { } else { if (!sl.first) try sl.w.writeByte(','); var buf: [6]u8 = undefined; - const printed = std.fmt.bufPrint(&buf, "'\\x{x}'", .{c}) catch unreachable; + const printed = std.mem.print(&buf, "'\\x{x}'", .{c}) catch unreachable; try sl.w.writeAll(printed); sl.cur_len += printed.len; sl.first = false; diff --git a/src/codegen/x86_64/CodeGen.zig b/src/codegen/x86_64/CodeGen.zig index 410e2a878c767b55a85740a4576af8c3f4e9e8d8..506a5a6a0ddfd66e30bec64676fef2ba266ec99e 100644 --- a/src/codegen/x86_64/CodeGen.zig +++ b/src/codegen/x86_64/CodeGen.zig @@ -178194,7 +178194,7 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void { inline for (@typeInfo(encoder.Instruction.Mnemonic).@"enum".field_names) |mnem_name| max_mnem_len = @max(mnem_name.len, max_mnem_len); var intel_mnem_buf: [max_mnem_len + 1]u8 = undefined; - const intel_mnem_str = std.fmt.bufPrint(&intel_mnem_buf, "{s}{c}", .{ + const intel_mnem_str = std.mem.print(&intel_mnem_buf, "{s}{c}", .{ @tagName(mnem_tag), @as(u8, switch (mnem_size.size) { .byte => 'b', diff --git a/src/libs/freebsd.zig b/src/libs/freebsd.zig index 6fb4b804525700fa7f4ce9a4f3c21363ae295fa9..d7b53387347e27ab502c13282dc99f8c75763df4 100644 --- a/src/libs/freebsd.zig +++ b/src/libs/freebsd.zig @@ -975,7 +975,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye } var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "stdthreads", etc. - const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; + const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items }); try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node); } diff --git a/src/libs/glibc.zig b/src/libs/glibc.zig index 7c20c33a0335fcab4b01e7da5c37c4d673e899b2..ebc36af06304aa28b760477167ce0b04570abac3 100644 --- a/src/libs/glibc.zig +++ b/src/libs/glibc.zig @@ -1124,7 +1124,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye } var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc. - const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; + const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items }); try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node); } diff --git a/src/libs/mingw/Preprocessor.zig b/src/libs/mingw/Preprocessor.zig index f10cb33d39853efb6455e74937a75a7c34296cca..57e1e660171754ae44ebb1dfb4514059d4faf21b 100644 --- a/src/libs/mingw/Preprocessor.zig +++ b/src/libs/mingw/Preprocessor.zig @@ -92,9 +92,9 @@ fn addTokenAssumeCapacity(pp: *Preprocessor, tok: Token) void { fn defineBuiltins(pp: *Preprocessor) !void { var buf: [5]u8 = undefined; - var val = std.fmt.bufPrint(&buf, "{d}", .{pp.target.cTypeByteSize(.longdouble).?}) catch unreachable; + var val = std.mem.print(&buf, "{d}", .{pp.target.cTypeByteSize(.longdouble).?}) catch unreachable; try pp.defineBuiltinValue("__SIZEOF_LONG_DOUBLE__", val, .pp_num); - val = std.fmt.bufPrint(&buf, "{d}", .{pp.target.cTypeByteSize(.double).?}) catch unreachable; + val = std.mem.print(&buf, "{d}", .{pp.target.cTypeByteSize(.double).?}) catch unreachable; try pp.defineBuiltinValue("__SIZEOF_DOUBLE__", val, .pp_num); if (pp.target.abi.isGnu()) { diff --git a/src/libs/netbsd.zig b/src/libs/netbsd.zig index 3d7c94ce4974bb8f9fb926cad43ca99c1919cfc7..b0fd269b22279b860426781e41a21e5297989c75 100644 --- a/src/libs/netbsd.zig +++ b/src/libs/netbsd.zig @@ -636,7 +636,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye } var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc. - const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; + const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items }); try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node); } diff --git a/src/libs/openbsd.zig b/src/libs/openbsd.zig index 2e0159b677de2ff86d57ac27e130c63f341e898f..ba65dd46943a10fc8e61f2216e6762debf549e4a 100644 --- a/src/libs/openbsd.zig +++ b/src/libs/openbsd.zig @@ -557,7 +557,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye } var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc. - const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; + const asm_file_basename = std.mem.print(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable; try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items }); try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node); } diff --git a/src/link/Coff.zig b/src/link/Coff.zig index b7045cac54bb00945e2b9a6458d422151aca54ff..91ee0ab5bda97079f456ac74bf68c3d9d4868493 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -5994,7 +5994,7 @@ fn resolve(coff: *Coff, tid: Zcu.PerThread.Id) !bool { }; var name: [std.Progress.Node.max_name_len]u8 = undefined; const sub_prog_node = coff.synth_prog_node.start( - std.fmt.bufPrint(&name, "lazy {s} for {f}", .{ + std.mem.print(&name, "lazy {s} for {f}", .{ kind, Type.fromInterned(lmr.lazySymbol(coff).ty).fmt(pt), }) catch &name, @@ -6132,7 +6132,7 @@ fn idleProgNode( inline .pseudo_section, .object_section => |smi| smi.name(coff).toSlice(coff), .input_section => |isi| { const ioi = isi.input(coff); - break :name std.fmt.bufPrint(&name, "{f}{f} {s}", .{ + break :name std.mem.print(&name, "{f}{f} {s}", .{ ioi.path(coff).fmtEscapeString(), fmtMemberNameString(ioi.memberName(coff)), coff.getNode(isi.symbol(coff).node(coff).parent(&coff.mf).unwrap().?).object_section.name(coff).toSlice(coff), @@ -6143,7 +6143,7 @@ fn idleProgNode( const ip = &coff.base.comp.zcu.?.intern_pool; break :name ip.getNav(nmi.navIndex(coff)).fqn.toSlice(ip); }, - .uav => |umi| std.fmt.bufPrint(&name, "{f}", .{ + .uav => |umi| std.mem.print(&name, "{f}", .{ Value.fromInterned(umi.uavValue(coff)).fmtValue(.{ .zcu = coff.base.comp.zcu.?, .tid = tid, diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index a73874ea0259b566444233452028d36ec99479e3..78f3287d8e014e3fb37f51fd7fc2355b2ccbbeef 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -3834,7 +3834,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co .field); { var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined; - const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{field_index}) catch unreachable; + const field_name = std.mem.print(&field_name_buf, "{d}", .{field_index}) catch unreachable; try wip_nav.strp(field_name); } try wip_nav.refType(field_type); @@ -4456,7 +4456,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co .tuple_index => |index| { try wip_nav.abbrevCode(.access); var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined; - const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{index}) catch unreachable; + const field_name = std.mem.print(&field_name_buf, "{d}", .{index}) catch unreachable; try wip_nav.strp(field_name); }, }; @@ -4551,7 +4551,7 @@ fn updateConstInner(dwarf: *Dwarf, pt: Zcu.PerThread, debug_const_index: link.Co continue); { var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined; - const field_name = std.fmt.bufPrint(&field_name_buf, "{d}", .{field_index}) catch unreachable; + const field_name = std.mem.print(&field_name_buf, "{d}", .{field_index}) catch unreachable; try wip_nav.strp(field_name); } const field_value: Value = .fromInterned(switch (aggregate.storage) { diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index 50c1060e386a47f13eb177c7539535c642658416..2ba12bcef1972cd8295ddee3e95bd6a5998e9907 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -1026,7 +1026,7 @@ pub fn lowerUav( }; var name_buf: [32]u8 = undefined; - const name = std.fmt.bufPrint(&name_buf, "__anon_{d}", .{ + const name = std.mem.print(&name_buf, "__anon_{d}", .{ @backingInt(uav), }) catch unreachable; const sym_index = self.lowerConst( diff --git a/src/link/Elf2.zig b/src/link/Elf2.zig index 4e0bdee194736cdff8716ab0ebdf764637a76b4a..61d9c81f9cd3da43219e24ebf9581540a920894b 100644 --- a/src/link/Elf2.zig +++ b/src/link/Elf2.zig @@ -3026,7 +3026,7 @@ fn lazySymbolInner(elf: *Elf, lazy: link.File.LazySymbol) Error!link.File.Symbol }; const node = try shndx.get(elf).ni.addFloatingChild(&elf.mf, gpa, .{}); var name_buf: [64]u8 = undefined; - const name = std.fmt.bufPrint( + const name = std.mem.print( &name_buf, "__lazy_{t}_{d}", .{ lazy.kind, @backingInt(lazy.ty) }, @@ -5361,7 +5361,7 @@ fn uavMapIndex( .alignment = resolved_align, }); var name_buf: [32]u8 = undefined; - const name = std.fmt.bufPrint( + const name = std.mem.print( &name_buf, "__anon_{d}", .{@backingInt(uav_val)}, @@ -7916,13 +7916,13 @@ fn idleProgNode( return prog_node.start(name: switch (node) { else => |tag| @tagName(tag), .section => |shndx| shndx.name(elf).slice(elf), - .archive_input_member => |ii| std.fmt.bufPrint(&name, "{f}{f}", .{ + .archive_input_member => |ii| std.mem.print(&name, "{f}{f}", .{ ii.path(elf).fmtEscapeString(), fmtMemberString(ii.member(elf)), }) catch &name, .input_section => |isi| { const ii = isi.input(elf); - break :name std.fmt.bufPrint(&name, "{f}{f} {s}", .{ + break :name std.mem.print(&name, "{f}{f} {s}", .{ ii.path(elf).fmtEscapeString(), fmtMemberString(ii.member(elf)), elf.getNode(isi.node(elf).parent(&elf.mf).unwrap().?).section.name(elf).slice(elf), @@ -7932,7 +7932,7 @@ fn idleProgNode( const ip = &elf.base.comp.zcu.?.intern_pool; break :name ip.getNav(nmi.navIndex(elf)).fqn.toSlice(ip); }, - .uav => |umi| std.fmt.bufPrint(&name, "{f}", .{ + .uav => |umi| std.mem.print(&name, "{f}", .{ Value.fromInterned(umi.uavValue(elf)).fmtValue(.{ .zcu = elf.base.comp.zcu.?, .tid = tid }), }) catch &name, }, 0); diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig index 3125cd538d01636f3c181c48282c354de53f388a..40d9d4e13e03714754d88f67e32f220f499bbc37 100644 --- a/src/link/MachO/Dylib.zig +++ b/src/link/MachO/Dylib.zig @@ -844,7 +844,7 @@ pub const Id = struct { allocator.free(id.name); } - pub const ParseError = fmt.ParseIntError || fmt.BufPrintError; + pub const ParseError = fmt.ParseIntError || mem.PrintError; pub fn parseCurrentVersion(id: *Id, version: anytype) ParseError!void { id.current_version = try parseVersion(version); @@ -865,7 +865,7 @@ pub const Id = struct { }, .float => |float| { var buf: [256]u8 = undefined; - break :blk try fmt.bufPrint(&buf, "{d}", .{float}); + break :blk try mem.print(&buf, "{d}", .{float}); }, .string => |string| { break :blk string; diff --git a/src/link/MachO/ZigObject.zig b/src/link/MachO/ZigObject.zig index bce67375a27e72c8a0db3be6d73518c2a704dc78..0ff8358077b1c7a7d636a3164bdfe4d677cdcd97 100644 --- a/src/link/MachO/ZigObject.zig +++ b/src/link/MachO/ZigObject.zig @@ -720,7 +720,7 @@ pub fn lowerUav( } var name_buf: [32]u8 = undefined; - const name = std.fmt.bufPrint(&name_buf, "__anon_{d}", .{ + const name = std.mem.print(&name_buf, "__anon_{d}", .{ @backingInt(uav), }) catch unreachable; const sym_index = self.lowerConst( diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index c0aa2f1ea4f9a6c957c1d46799fe21dc56d0b0e2..42111676dc8081af73ecea74ffe55fa6c5f426c2 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -1374,7 +1374,7 @@ pub const GlobalImport = extern struct { .__tls_base => @tagName(Unpacked.__tls_base), .__tls_size => @tagName(Unpacked.__tls_size), .object_global => |i| i.name(wasm).slice(wasm), - inline .uav_obj, .uav_exe => |i| std.fmt.bufPrint( + inline .uav_obj, .uav_exe => |i| std.mem.print( buf, "__anon_{d}", .{@backingInt(i.key(wasm).*)}, @@ -1997,7 +1997,7 @@ pub const ObjectDataImport = extern struct { .__heap_base => @tagName(.__heap_base), .__heap_end => @tagName(.__heap_end), .__wasm_first_page_end => @tagName(.__wasm_first_page_end), - inline .uav_exe, .uav_obj => |i| std.fmt.bufPrint( + inline .uav_exe, .uav_obj => |i| std.mem.print( buf, "__anon_{d}", .{@backingInt(i.key(wasm).*)}, @@ -4348,7 +4348,7 @@ pub fn internString(wasm: *Wasm, bytes: []const u8) Allocator.Error!String { // TODO implement instead by appending to string_bytes pub fn internStringFmt(wasm: *Wasm, comptime format: []const u8, args: anytype) Allocator.Error!String { var buffer: [32]u8 = undefined; - const slice = std.fmt.bufPrint(&buffer, format, args) catch unreachable; + const slice = std.mem.print(&buffer, format, args) catch unreachable; return internString(wasm, slice); } diff --git a/src/link/Wasm/Flush.zig b/src/link/Wasm/Flush.zig index 7f18b297730f166451eb8826c1d222079ed4ccc6..413d6fd1ce27a6bdf96e95ac613e9b762f6096b8 100644 --- a/src/link/Wasm/Flush.zig +++ b/src/link/Wasm/Flush.zig @@ -1706,14 +1706,14 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { var id: [16]u8 = undefined; std.crypto.hash.sha3.TurboShake128(null).hash(binary_bytes.items, &id, .{}); var uuid: [36]u8 = undefined; - _ = try std.fmt.bufPrint(&uuid, "{x}-{x}-{x}-{x}-{x}", .{ + _ = try std.mem.print(&uuid, "{x}-{x}-{x}-{x}-{x}", .{ id[0..4], id[4..6], id[6..8], id[8..10], id[10..], }); try emitBuildIdSection(gpa, binary_bytes, &uuid); }, .hexstring => |hs| { var buffer: [32 * 2]u8 = undefined; - const str = std.fmt.bufPrint(&buffer, "{x}", .{hs.toSlice()}) catch unreachable; + const str = std.mem.print(&buffer, "{x}", .{hs.toSlice()}) catch unreachable; try emitBuildIdSection(gpa, binary_bytes, str); }, else => |mode| { diff --git a/src/tracy.zig b/src/tracy.zig index ae3ca4ef9d505b6bf419d86644c86b2bff2717b4..4761261edea0a7773020d0160cd7e8bb698c4edd 100644 --- a/src/tracy.zig +++ b/src/tracy.zig @@ -23,7 +23,7 @@ const ___tracy_c_zone_context = extern struct { pub inline fn addTextFmt(self: @This(), comptime fmt: []const u8, args: anytype) void { var buf: [512]u8 = undefined; - const slice = std.fmt.bufPrint(&buf, fmt, args) catch &buf; + const slice = std.mem.print(&buf, fmt, args) catch &buf; self.addText(slice); } diff --git a/test/standalone/emit_llvm_no_bin/main.zig b/test/standalone/emit_llvm_no_bin/main.zig index 47f67515c7d770be2a2b09ba8596e99c0249aa95..9a345938f72f0619f87aaf4cd76f24d6a10218b2 100644 --- a/test/standalone/emit_llvm_no_bin/main.zig +++ b/test/standalone/emit_llvm_no_bin/main.zig @@ -2,5 +2,5 @@ const std = @import("std"); export fn strFromFloatHelp(float: f64) void { var buf: [400]u8 = undefined; - _ = std.fmt.bufPrint(&buf, "{d}", .{float}) catch unreachable; + _ = std.mem.print(&buf, "{d}", .{float}) catch unreachable; }