authorgravatar for github@mjb.ioMichael Bradshaw <github@mjb.io> 2024-06-28 08:21:20-07:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-03 17:42:09+01:00
log21cad3e09f173154c4c0dc61dd05fe8dd0628dc3
tree716f87eacd02c591b4288fb70d3adf6daa7cac8c
parente1d4cf67caedfe20d2e0af9d3b518af1f0777191

Rename MAX_NAME_BYTES to max_name_bytes


5 files changed, 11 insertions(+), 8 deletions(-)

lib/compiler/aro/aro/Driver.zig+2-2
...@@ -730,8 +730,8 @@ fn processSource(...@@ -730,8 +730,8 @@ fn processSource(
730 defer obj.deinit();730 defer obj.deinit();
731731
732 // If it's used, name_buf will either hold a filename or `/tmp/<12 random bytes with base-64 encoding>.<extension>`732 // If it's used, name_buf will either hold a filename or `/tmp/<12 random bytes with base-64 encoding>.<extension>`
733 // both of which should fit into MAX_NAME_BYTES for all systems733 // both of which should fit into max_name_bytes for all systems
734 var name_buf: [std.fs.MAX_NAME_BYTES]u8 = undefined;734 var name_buf: [std.fs.max_name_bytes]u8 = undefined;
735735
736 const out_file_name = if (d.only_compile) blk: {736 const out_file_name = if (d.only_compile) blk: {
737 const fmt_template = "{s}{s}";737 const fmt_template = "{s}{s}";
lib/std/fs.zig+5-2
...@@ -72,7 +72,7 @@ pub const max_path_bytes = switch (native_os) {...@@ -72,7 +72,7 @@ pub const max_path_bytes = switch (native_os) {
72/// On Windows, `[]u8` file name components are encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).72/// On Windows, `[]u8` file name components are encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
73/// On WASI, file name components are encoded as valid UTF-8.73/// On WASI, file name components are encoded as valid UTF-8.
74/// On other platforms, `[]u8` components are an opaque sequence of bytes with no particular encoding.74/// On other platforms, `[]u8` components are an opaque sequence of bytes with no particular encoding.
75pub const MAX_NAME_BYTES = switch (native_os) {75pub const max_name_bytes = switch (native_os) {
76 .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .solaris, .illumos => posix.NAME_MAX,76 .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .solaris, .illumos => posix.NAME_MAX,
77 // Haiku's NAME_MAX includes the null terminator, so subtract one.77 // Haiku's NAME_MAX includes the null terminator, so subtract one.
78 .haiku => posix.NAME_MAX - 1,78 .haiku => posix.NAME_MAX - 1,
...@@ -81,7 +81,7 @@ pub const MAX_NAME_BYTES = switch (native_os) {...@@ -81,7 +81,7 @@ pub const MAX_NAME_BYTES = switch (native_os) {
81 // pair in the WTF-16LE, and we (over)account 3 bytes for it that way.81 // pair in the WTF-16LE, and we (over)account 3 bytes for it that way.
82 .windows => windows.NAME_MAX * 3,82 .windows => windows.NAME_MAX * 3,
83 // For WASI, the MAX_NAME will depend on the host OS, so it needs to be83 // For WASI, the MAX_NAME will depend on the host OS, so it needs to be
84 // as large as the largest MAX_NAME_BYTES (Windows) in order to work on any host OS.84 // as large as the largest max_name_bytes (Windows) in order to work on any host OS.
85 // TODO determine if this is a reasonable approach85 // TODO determine if this is a reasonable approach
86 .wasi => windows.NAME_MAX * 3,86 .wasi => windows.NAME_MAX * 3,
87 else => if (@hasDecl(root, "os") and @hasDecl(root.os, "NAME_MAX"))87 else => if (@hasDecl(root, "os") and @hasDecl(root.os, "NAME_MAX"))
...@@ -90,6 +90,9 @@ pub const MAX_NAME_BYTES = switch (native_os) {...@@ -90,6 +90,9 @@ pub const MAX_NAME_BYTES = switch (native_os) {
90 @compileError("NAME_MAX not implemented for " ++ @tagName(native_os)),90 @compileError("NAME_MAX not implemented for " ++ @tagName(native_os)),
91};91};
9292
93/// Deprecated: use `max_name_bytes`
94pub const MAX_NAME_BYTES = max_name_bytes;
95
93pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*;96pub const base64_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".*;
9497
95/// Base64 encoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem.98/// Base64 encoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem.
lib/std/fs/Dir.zig+1-1
...@@ -414,7 +414,7 @@ pub const Iterator = switch (native_os) {...@@ -414,7 +414,7 @@ pub const Iterator = switch (native_os) {
414 index: usize,414 index: usize,
415 end_index: usize,415 end_index: usize,
416 first_iter: bool,416 first_iter: bool,
417 name_data: [fs.MAX_NAME_BYTES]u8,417 name_data: [fs.max_name_bytes]u8,
418418
419 const Self = @This();419 const Self = @This();
420420
lib/std/fs/test.zig+2-2
...@@ -1269,11 +1269,11 @@ test "max file name component lengths" {...@@ -1269,11 +1269,11 @@ test "max file name component lengths" {
1269 } else if (native_os == .wasi) {1269 } else if (native_os == .wasi) {
1270 // On WASI, the maxed filename depends on the host OS, so in order for this test to1270 // On WASI, the maxed filename depends on the host OS, so in order for this test to
1271 // work on any host, we need to use a length that will work for all platforms1271 // work on any host, we need to use a length that will work for all platforms
1272 // (i.e. the minimum MAX_NAME_BYTES of all supported platforms).1272 // (i.e. the minimum max_name_bytes of all supported platforms).
1273 const maxed_wasi_filename = [_]u8{'1'} ** 255;1273 const maxed_wasi_filename = [_]u8{'1'} ** 255;
1274 try testFilenameLimits(tmp.dir, &maxed_wasi_filename);1274 try testFilenameLimits(tmp.dir, &maxed_wasi_filename);
1275 } else {1275 } else {
1276 const maxed_ascii_filename = [_]u8{'1'} ** std.fs.MAX_NAME_BYTES;1276 const maxed_ascii_filename = [_]u8{'1'} ** std.fs.max_name_bytes;
1277 try testFilenameLimits(tmp.dir, &maxed_ascii_filename);1277 try testFilenameLimits(tmp.dir, &maxed_ascii_filename);
1278 }1278 }
1279}1279}
lib/std/zig/WindowsSdk.zig+1-1
...@@ -750,7 +750,7 @@ const MsvcLibDir = struct {...@@ -750,7 +750,7 @@ const MsvcLibDir = struct {
750 var instances_dir = try findInstancesDir(allocator);750 var instances_dir = try findInstancesDir(allocator);
751 defer instances_dir.close();751 defer instances_dir.close();
752752
753 var state_subpath_buf: [std.fs.MAX_NAME_BYTES + 32]u8 = undefined;753 var state_subpath_buf: [std.fs.max_name_bytes + 32]u8 = undefined;
754 var latest_version_lib_dir = std.ArrayListUnmanaged(u8){};754 var latest_version_lib_dir = std.ArrayListUnmanaged(u8){};
755 errdefer latest_version_lib_dir.deinit(allocator);755 errdefer latest_version_lib_dir.deinit(allocator);
756756