| author | |
| committer | |
| log | 76fb2b685b202ea665b850338e353c7816f5b2bb |
| tree | 16b4b39db7541febd2b4bf92c041239bdd45f144 |
| parent | 4aa15440c7a12bcc6bc0cd589ade02295549d48c |
Deprecated aliases that are now compile errors:
- `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`)
- `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`)
- `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`)
- `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`)
- `std.unicode`
+ `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`)
+ `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`)
- `std.zig.CrossTarget` (moved to `std.Target.Query`)
Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are:
- `std.rand` (renamed to `std.Random`)
- `std.TailQueue` (renamed to `std.DoublyLinkedList`)
- `std.ChildProcess` (renamed/moved to `std.process.Child`)
This is not exhaustive. Deprecated aliases that I didn't touch:
+ `std.io.*`
+ `std.Build.*`
+ `std.builtin.Mode`
+ `std.zig.c_translation.CIntLiteralRadix`
+ anything in `src/`47 files changed, 136 insertions(+), 150 deletions(-)
build.zig+2-2| ... | ... | @@ -15,7 +15,7 @@ const stack_size = 32 * 1024 * 1024; |
| 15 | 15 | pub fn build(b: *std.Build) !void { |
| 16 | 16 | const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false; |
| 17 | 17 | const target = t: { |
| 18 | var default_target: std.zig.CrossTarget = .{}; | |
| 18 | var default_target: std.Target.Query = .{}; | |
| 19 | 19 | default_target.ofmt = b.option(std.Target.ObjectFormat, "ofmt", "Object format to target") orelse if (only_c) .c else null; |
| 20 | 20 | break :t b.standardTargetOptions(.{ .default_target = default_target }); |
| 21 | 21 | }; |
| ... | ... | @@ -559,7 +559,7 @@ pub fn build(b: *std.Build) !void { |
| 559 | 559 | fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { |
| 560 | 560 | const semver = try std.SemanticVersion.parse(version); |
| 561 | 561 | |
| 562 | var target_query: std.zig.CrossTarget = .{ | |
| 562 | var target_query: std.Target.Query = .{ | |
| 563 | 563 | .cpu_arch = .wasm32, |
| 564 | 564 | .os_tag = .wasi, |
| 565 | 565 | }; |
lib/compiler/aro/aro/Driver.zig+1-1| ... | ... | @@ -792,7 +792,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) !void |
| 792 | 792 | var argv = std.ArrayList([]const u8).init(d.comp.gpa); |
| 793 | 793 | defer argv.deinit(); |
| 794 | 794 | |
| 795 | var linker_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 795 | var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 796 | 796 | const linker_path = try tc.getLinkerPath(&linker_path_buf); |
| 797 | 797 | try argv.append(linker_path); |
| 798 | 798 |
lib/compiler/aro/aro/Driver/Filesystem.zig+2-2| ... | ... | @@ -46,7 +46,7 @@ fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool { |
| 46 | 46 | |
| 47 | 47 | fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool { |
| 48 | 48 | @setCold(true); |
| 49 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 49 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 50 | 50 | var fib = std.heap.FixedBufferAllocator.init(&buf); |
| 51 | 51 | const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false; |
| 52 | 52 | for (entries) |entry| { |
| ... | ... | @@ -181,7 +181,7 @@ pub const Filesystem = union(enum) { |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | pub fn joinedExists(fs: Filesystem, parts: []const []const u8) bool { |
| 184 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 184 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 185 | 185 | var fib = std.heap.FixedBufferAllocator.init(&buf); |
| 186 | 186 | const joined = std.fs.path.join(fib.allocator(), parts) catch return false; |
| 187 | 187 | return fs.exists(joined); |
lib/compiler/aro/aro/Driver/GCCDetector.zig+2-2| ... | ... | @@ -397,7 +397,7 @@ fn collectLibDirsAndTriples( |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | pub fn discover(self: *GCCDetector, tc: *Toolchain) !void { |
| 400 | var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 400 | var path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 401 | 401 | var fib = std.heap.FixedBufferAllocator.init(&path_buf); |
| 402 | 402 | |
| 403 | 403 | const target = tc.getTarget(); |
| ... | ... | @@ -589,7 +589,7 @@ fn scanLibDirForGCCTriple( |
| 589 | 589 | gcc_dir_exists: bool, |
| 590 | 590 | gcc_cross_dir_exists: bool, |
| 591 | 591 | ) !void { |
| 592 | var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 592 | var path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 593 | 593 | var fib = std.heap.FixedBufferAllocator.init(&path_buf); |
| 594 | 594 | for (0..2) |i| { |
| 595 | 595 | if (i == 0 and !gcc_dir_exists) continue; |
lib/compiler/aro/aro/Toolchain.zig+3-3| ... | ... | @@ -221,7 +221,7 @@ pub fn addFilePathLibArgs(tc: *const Toolchain, argv: *std.ArrayList([]const u8) |
| 221 | 221 | /// If not found there, just use `name` |
| 222 | 222 | /// Writes the result to `buf` and returns a slice of it |
| 223 | 223 | fn getProgramPath(tc: *const Toolchain, name: []const u8, buf: []u8) []const u8 { |
| 224 | var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 224 | var path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 225 | 225 | var fib = std.heap.FixedBufferAllocator.init(&path_buf); |
| 226 | 226 | |
| 227 | 227 | var tool_specific_buf: [64]u8 = undefined; |
| ... | ... | @@ -251,7 +251,7 @@ pub fn getSysroot(tc: *const Toolchain) []const u8 { |
| 251 | 251 | /// Search for `name` in a variety of places |
| 252 | 252 | /// TODO: cache results based on `name` so we're not repeatedly allocating the same strings? |
| 253 | 253 | pub fn getFilePath(tc: *const Toolchain, name: []const u8) ![]const u8 { |
| 254 | var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 254 | var path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 255 | 255 | var fib = std.heap.FixedBufferAllocator.init(&path_buf); |
| 256 | 256 | const allocator = fib.allocator(); |
| 257 | 257 | |
| ... | ... | @@ -304,7 +304,7 @@ const PathKind = enum { |
| 304 | 304 | /// Join `components` into a path. If the path exists, dupe it into the toolchain arena and |
| 305 | 305 | /// add it to the specified path list. |
| 306 | 306 | pub fn addPathIfExists(tc: *Toolchain, components: []const []const u8, dest_kind: PathKind) !void { |
| 307 | var path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 307 | var path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 308 | 308 | var fib = std.heap.FixedBufferAllocator.init(&path_buf); |
| 309 | 309 | |
| 310 | 310 | const candidate = try std.fs.path.join(fib.allocator(), components); |
lib/compiler/aro/aro/Value.zig+1-1| ... | ... | @@ -706,7 +706,7 @@ pub fn printString(bytes: []const u8, ty: Type, comp: *const Compilation, w: any |
| 706 | 706 | switch (size) { |
| 707 | 707 | inline .@"1", .@"2" => |sz| { |
| 708 | 708 | const data_slice: []const sz.Type() = @alignCast(std.mem.bytesAsSlice(sz.Type(), without_null)); |
| 709 | const formatter = if (sz == .@"1") std.zig.fmtEscapes(data_slice) else std.unicode.fmtUtf16le(data_slice); | |
| 709 | const formatter = if (sz == .@"1") std.zig.fmtEscapes(data_slice) else std.unicode.fmtUtf16Le(data_slice); | |
| 710 | 710 | try w.print("\"{}\"", .{formatter}); |
| 711 | 711 | }, |
| 712 | 712 | .@"4" => { |
lib/compiler/aro/aro/toolchains/Linux.zig+1-1| ... | ... | @@ -478,7 +478,7 @@ test Linux { |
| 478 | 478 | var argv = std.ArrayList([]const u8).init(driver.comp.gpa); |
| 479 | 479 | defer argv.deinit(); |
| 480 | 480 | |
| 481 | var linker_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 481 | var linker_path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 482 | 482 | const linker_path = try toolchain.getLinkerPath(&linker_path_buf); |
| 483 | 483 | try argv.append(linker_path); |
| 484 | 484 |
lib/compiler/resinator/cli.zig+1-1| ... | ... | @@ -846,7 +846,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn |
| 846 | 846 | arg_i += 1; |
| 847 | 847 | break :next_arg; |
| 848 | 848 | }; |
| 849 | var tokenizer = std.mem.tokenize(u8, value.slice, "="); | |
| 849 | var tokenizer = std.mem.tokenizeScalar(u8, value.slice, '='); | |
| 850 | 850 | // guaranteed to exist since an empty value.slice would invoke |
| 851 | 851 | // the 'missing symbol to define' branch above |
| 852 | 852 | const symbol = tokenizer.next().?; |
lib/compiler/resinator/compile.zig+1-1| ... | ... | @@ -3405,7 +3405,7 @@ test "StringTable" { |
| 3405 | 3405 | } |
| 3406 | 3406 | break :ids buf; |
| 3407 | 3407 | }; |
| 3408 | var prng = std.rand.DefaultPrng.init(0); | |
| 3408 | var prng = std.Random.DefaultPrng.init(0); | |
| 3409 | 3409 | var random = prng.random(); |
| 3410 | 3410 | random.shuffle(u16, &ids); |
| 3411 | 3411 |
lib/compiler/resinator/source_mapping.zig+1-1| ... | ... | @@ -214,7 +214,7 @@ pub fn handleLineEnd(allocator: Allocator, post_processed_line_number: usize, ma |
| 214 | 214 | // TODO: Might want to provide diagnostics on invalid line commands instead of just returning |
| 215 | 215 | pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current_mapping: *CurrentMapping) error{OutOfMemory}!void { |
| 216 | 216 | // TODO: Are there other whitespace characters that should be included? |
| 217 | var tokenizer = std.mem.tokenize(u8, line_command, " \t"); | |
| 217 | var tokenizer = std.mem.tokenizeAny(u8, line_command, " \t"); | |
| 218 | 218 | const line_directive = tokenizer.next() orelse return; // #line |
| 219 | 219 | if (!std.mem.eql(u8, line_directive, "#line")) return; |
| 220 | 220 | const linenum_str = tokenizer.next() orelse return; |
lib/docs/wasm/main.zig+1-1| ... | ... | @@ -1212,7 +1212,7 @@ fn unindent(s: []const u8, indent: usize) []const u8 { |
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | fn appendUnindented(out: *std.ArrayListUnmanaged(u8), s: []const u8, indent: usize) !void { |
| 1215 | var it = std.mem.split(u8, s, "\n"); | |
| 1215 | var it = std.mem.splitScalar(u8, s, '\n'); | |
| 1216 | 1216 | var is_first_line = true; |
| 1217 | 1217 | while (it.next()) |line| { |
| 1218 | 1218 | if (is_first_line) { |
lib/docs/wasm/markdown.zig+1-1| ... | ... | @@ -1112,7 +1112,7 @@ fn testRender(input: []const u8, expected: []const u8) !void { |
| 1112 | 1112 | var parser = try Parser.init(testing.allocator); |
| 1113 | 1113 | defer parser.deinit(); |
| 1114 | 1114 | |
| 1115 | var lines = std.mem.split(u8, input, "\n"); | |
| 1115 | var lines = std.mem.splitScalar(u8, input, '\n'); | |
| 1116 | 1116 | while (lines.next()) |line| { |
| 1117 | 1117 | try parser.feedLine(line); |
| 1118 | 1118 | } |
lib/std/Build/Cache/Path.zig+6-6| ... | ... | @@ -49,7 +49,7 @@ pub fn openFile( |
| 49 | 49 | sub_path: []const u8, |
| 50 | 50 | flags: fs.File.OpenFlags, |
| 51 | 51 | ) !fs.File { |
| 52 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 52 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 53 | 53 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| 54 | 54 | break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{ |
| 55 | 55 | p.sub_path, sub_path, |
| ... | ... | @@ -59,7 +59,7 @@ pub fn openFile( |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | pub fn makeOpenPath(p: Path, sub_path: []const u8, opts: fs.OpenDirOptions) !fs.Dir { |
| 62 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 62 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 63 | 63 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| 64 | 64 | break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{ |
| 65 | 65 | p.sub_path, sub_path, |
| ... | ... | @@ -69,7 +69,7 @@ pub fn makeOpenPath(p: Path, sub_path: []const u8, opts: fs.OpenDirOptions) !fs. |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | pub fn statFile(p: Path, sub_path: []const u8) !fs.Dir.Stat { |
| 72 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 72 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 73 | 73 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| 74 | 74 | break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{ |
| 75 | 75 | p.sub_path, sub_path, |
| ... | ... | @@ -82,7 +82,7 @@ pub fn atomicFile( |
| 82 | 82 | p: Path, |
| 83 | 83 | sub_path: []const u8, |
| 84 | 84 | options: fs.Dir.AtomicFileOptions, |
| 85 | buf: *[fs.MAX_PATH_BYTES]u8, | |
| 85 | buf: *[fs.max_path_bytes]u8, | |
| 86 | 86 | ) !fs.AtomicFile { |
| 87 | 87 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| 88 | 88 | break :p std.fmt.bufPrint(buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{ |
| ... | ... | @@ -93,7 +93,7 @@ pub fn atomicFile( |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | pub fn access(p: Path, sub_path: []const u8, flags: fs.File.OpenFlags) !void { |
| 96 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 96 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 97 | 97 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| 98 | 98 | break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{ |
| 99 | 99 | p.sub_path, sub_path, |
| ... | ... | @@ -103,7 +103,7 @@ pub fn access(p: Path, sub_path: []const u8, flags: fs.File.OpenFlags) !void { |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | pub fn makePath(p: Path, sub_path: []const u8) !void { |
| 106 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 106 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 107 | 107 | const joined_path = if (p.sub_path.len == 0) sub_path else p: { |
| 108 | 108 | break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{ |
| 109 | 109 | p.sub_path, sub_path, |
lib/std/Random.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ const math = std.math; |
| 9 | 9 | const mem = std.mem; |
| 10 | 10 | const assert = std.debug.assert; |
| 11 | 11 | const maxInt = std.math.maxInt; |
| 12 | pub const Random = @This(); // Remove pub when `std.rand` namespace is removed. | |
| 12 | const Random = @This(); | |
| 13 | 13 | |
| 14 | 14 | /// Fast unbiased random numbers. |
| 15 | 15 | pub const DefaultPrng = Xoshiro256; |
lib/std/debug.zig+1-1| ... | ... | @@ -1298,7 +1298,7 @@ pub fn readElfDebugInfo( |
| 1298 | 1298 | if (readElfDebugInfo(allocator, path, null, separate_debug_crc, &sections, mapped_mem)) |debug_info| return debug_info else |_| {} |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | var cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1301 | var cwd_buf: [fs.max_path_bytes]u8 = undefined; | |
| 1302 | 1302 | const cwd_path = posix.realpath(".", &cwd_buf) catch break :blk; |
| 1303 | 1303 | |
| 1304 | 1304 | // <global debug directory>/<absolute folder of current binary>/<gnu_debuglink> |
lib/std/fs.zig+18-19| ... | ... | @@ -35,8 +35,7 @@ pub const realpathW = posix.realpathW; |
| 35 | 35 | pub const getAppDataDir = @import("fs/get_app_data_dir.zig").getAppDataDir; |
| 36 | 36 | pub const GetAppDataDirError = @import("fs/get_app_data_dir.zig").GetAppDataDirError; |
| 37 | 37 | |
| 38 | /// Deprecated: use `max_path_bytes`. | |
| 39 | pub const MAX_PATH_BYTES = max_path_bytes; | |
| 38 | pub const MAX_PATH_BYTES = @compileError("deprecated; renamed to max_path_bytes"); | |
| 40 | 39 | |
| 41 | 40 | /// The maximum length of a file path that the operating system will accept. |
| 42 | 41 | /// |
| ... | ... | @@ -417,20 +416,20 @@ pub fn deleteTreeAbsolute(absolute_path: []const u8) !void { |
| 417 | 416 | /// On Windows, `pathname` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/). |
| 418 | 417 | /// On WASI, `pathname` should be encoded as valid UTF-8. |
| 419 | 418 | /// On other platforms, `pathname` is an opaque sequence of bytes with no particular encoding. |
| 420 | pub fn readLinkAbsolute(pathname: []const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 { | |
| 419 | pub fn readLinkAbsolute(pathname: []const u8, buffer: *[max_path_bytes]u8) ![]u8 { | |
| 421 | 420 | assert(path.isAbsolute(pathname)); |
| 422 | 421 | return posix.readlink(pathname, buffer); |
| 423 | 422 | } |
| 424 | 423 | |
| 425 | 424 | /// Windows-only. Same as `readlinkW`, except the path parameter is null-terminated, WTF16 |
| 426 | 425 | /// encoded. |
| 427 | pub fn readlinkAbsoluteW(pathname_w: [*:0]const u16, buffer: *[MAX_PATH_BYTES]u8) ![]u8 { | |
| 426 | pub fn readlinkAbsoluteW(pathname_w: [*:0]const u16, buffer: *[max_path_bytes]u8) ![]u8 { | |
| 428 | 427 | assert(path.isAbsoluteWindowsW(pathname_w)); |
| 429 | 428 | return posix.readlinkW(pathname_w, buffer); |
| 430 | 429 | } |
| 431 | 430 | |
| 432 | 431 | /// Same as `readLink`, except the path parameter is null-terminated. |
| 433 | pub fn readLinkAbsoluteZ(pathname_c: [*:0]const u8, buffer: *[MAX_PATH_BYTES]u8) ![]u8 { | |
| 432 | pub fn readLinkAbsoluteZ(pathname_c: [*:0]const u8, buffer: *[max_path_bytes]u8) ![]u8 { | |
| 434 | 433 | assert(path.isAbsoluteZ(pathname_c)); |
| 435 | 434 | return posix.readlinkZ(pathname_c, buffer); |
| 436 | 435 | } |
| ... | ... | @@ -504,9 +503,9 @@ pub fn openSelfExe(flags: File.OpenFlags) OpenSelfExeError!File { |
| 504 | 503 | const prefixed_path_w = try windows.wToPrefixedFileW(null, image_path_name); |
| 505 | 504 | return cwd().openFileW(prefixed_path_w.span(), flags); |
| 506 | 505 | } |
| 507 | // Use of MAX_PATH_BYTES here is valid as the resulting path is immediately | |
| 506 | // Use of max_path_bytes here is valid as the resulting path is immediately | |
| 508 | 507 | // opened with no modification. |
| 509 | var buf: [MAX_PATH_BYTES]u8 = undefined; | |
| 508 | var buf: [max_path_bytes]u8 = undefined; | |
| 510 | 509 | const self_exe_path = try selfExePath(&buf); |
| 511 | 510 | buf[self_exe_path.len] = 0; |
| 512 | 511 | return openFileAbsoluteZ(buf[0..self_exe_path.len :0].ptr, flags); |
| ... | ... | @@ -554,14 +553,14 @@ pub const SelfExePathError = error{ |
| 554 | 553 | /// `selfExePath` except allocates the result on the heap. |
| 555 | 554 | /// Caller owns returned memory. |
| 556 | 555 | pub fn selfExePathAlloc(allocator: Allocator) ![]u8 { |
| 557 | // Use of MAX_PATH_BYTES here is justified as, at least on one tested Linux | |
| 556 | // Use of max_path_bytes here is justified as, at least on one tested Linux | |
| 558 | 557 | // system, readlink will completely fail to return a result larger than |
| 559 | 558 | // PATH_MAX even if given a sufficiently large buffer. This makes it |
| 560 | 559 | // fundamentally impossible to get the selfExePath of a program running in |
| 561 | 560 | // a very deeply nested directory chain in this way. |
| 562 | 561 | // TODO(#4812): Investigate other systems and whether it is possible to get |
| 563 | 562 | // this path by trying larger and larger buffers until one succeeds. |
| 564 | var buf: [MAX_PATH_BYTES]u8 = undefined; | |
| 563 | var buf: [max_path_bytes]u8 = undefined; | |
| 565 | 564 | return allocator.dupe(u8, try selfExePath(&buf)); |
| 566 | 565 | } |
| 567 | 566 | |
| ... | ... | @@ -581,12 +580,12 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 581 | 580 | if (is_darwin) { |
| 582 | 581 | // Note that _NSGetExecutablePath() will return "a path" to |
| 583 | 582 | // the executable not a "real path" to the executable. |
| 584 | var symlink_path_buf: [MAX_PATH_BYTES:0]u8 = undefined; | |
| 585 | var u32_len: u32 = MAX_PATH_BYTES + 1; // include the sentinel | |
| 583 | var symlink_path_buf: [max_path_bytes:0]u8 = undefined; | |
| 584 | var u32_len: u32 = max_path_bytes + 1; // include the sentinel | |
| 586 | 585 | const rc = std.c._NSGetExecutablePath(&symlink_path_buf, &u32_len); |
| 587 | 586 | if (rc != 0) return error.NameTooLong; |
| 588 | 587 | |
| 589 | var real_path_buf: [MAX_PATH_BYTES]u8 = undefined; | |
| 588 | var real_path_buf: [max_path_bytes]u8 = undefined; | |
| 590 | 589 | const real_path = std.posix.realpathZ(&symlink_path_buf, &real_path_buf) catch |err| switch (err) { |
| 591 | 590 | error.InvalidWtf8 => unreachable, // Windows-only |
| 592 | 591 | error.NetworkNotFound => unreachable, // Windows-only |
| ... | ... | @@ -634,7 +633,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 634 | 633 | const argv0 = mem.span(std.os.argv[0]); |
| 635 | 634 | if (mem.indexOf(u8, argv0, "/") != null) { |
| 636 | 635 | // argv[0] is a path (relative or absolute): use realpath(3) directly |
| 637 | var real_path_buf: [MAX_PATH_BYTES]u8 = undefined; | |
| 636 | var real_path_buf: [max_path_bytes]u8 = undefined; | |
| 638 | 637 | const real_path = posix.realpathZ(std.os.argv[0], &real_path_buf) catch |err| switch (err) { |
| 639 | 638 | error.InvalidWtf8 => unreachable, // Windows-only |
| 640 | 639 | error.NetworkNotFound => unreachable, // Windows-only |
| ... | ... | @@ -650,13 +649,13 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 650 | 649 | const PATH = posix.getenvZ("PATH") orelse return error.FileNotFound; |
| 651 | 650 | var path_it = mem.tokenizeScalar(u8, PATH, path.delimiter); |
| 652 | 651 | while (path_it.next()) |a_path| { |
| 653 | var resolved_path_buf: [MAX_PATH_BYTES - 1:0]u8 = undefined; | |
| 652 | var resolved_path_buf: [max_path_bytes - 1:0]u8 = undefined; | |
| 654 | 653 | const resolved_path = std.fmt.bufPrintZ(&resolved_path_buf, "{s}/{s}", .{ |
| 655 | 654 | a_path, |
| 656 | 655 | std.os.argv[0], |
| 657 | 656 | }) catch continue; |
| 658 | 657 | |
| 659 | var real_path_buf: [MAX_PATH_BYTES]u8 = undefined; | |
| 658 | var real_path_buf: [max_path_bytes]u8 = undefined; | |
| 660 | 659 | if (posix.realpathZ(resolved_path, &real_path_buf)) |real_path| { |
| 661 | 660 | // found a file, and hope it is the right file |
| 662 | 661 | if (real_path.len > out_buffer.len) |
| ... | ... | @@ -689,14 +688,14 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 689 | 688 | /// `selfExeDirPath` except allocates the result on the heap. |
| 690 | 689 | /// Caller owns returned memory. |
| 691 | 690 | pub fn selfExeDirPathAlloc(allocator: Allocator) ![]u8 { |
| 692 | // Use of MAX_PATH_BYTES here is justified as, at least on one tested Linux | |
| 691 | // Use of max_path_bytes here is justified as, at least on one tested Linux | |
| 693 | 692 | // system, readlink will completely fail to return a result larger than |
| 694 | 693 | // PATH_MAX even if given a sufficiently large buffer. This makes it |
| 695 | 694 | // fundamentally impossible to get the selfExeDirPath of a program running |
| 696 | 695 | // in a very deeply nested directory chain in this way. |
| 697 | 696 | // TODO(#4812): Investigate other systems and whether it is possible to get |
| 698 | 697 | // this path by trying larger and larger buffers until one succeeds. |
| 699 | var buf: [MAX_PATH_BYTES]u8 = undefined; | |
| 698 | var buf: [max_path_bytes]u8 = undefined; | |
| 700 | 699 | return allocator.dupe(u8, try selfExeDirPath(&buf)); |
| 701 | 700 | } |
| 702 | 701 | |
| ... | ... | @@ -716,13 +715,13 @@ pub fn selfExeDirPath(out_buffer: []u8) SelfExePathError![]const u8 { |
| 716 | 715 | /// On other platforms, the result is an opaque sequence of bytes with no particular encoding. |
| 717 | 716 | /// See also `Dir.realpath`. |
| 718 | 717 | pub fn realpathAlloc(allocator: Allocator, pathname: []const u8) ![]u8 { |
| 719 | // Use of MAX_PATH_BYTES here is valid as the realpath function does not | |
| 718 | // Use of max_path_bytes here is valid as the realpath function does not | |
| 720 | 719 | // have a variant that takes an arbitrary-size buffer. |
| 721 | 720 | // TODO(#4812): Consider reimplementing realpath or using the POSIX.1-2008 |
| 722 | 721 | // NULL out parameter (GNU's canonicalize_file_name) to handle overelong |
| 723 | 722 | // paths. musl supports passing NULL but restricts the output to PATH_MAX |
| 724 | 723 | // anyway. |
| 725 | var buf: [MAX_PATH_BYTES]u8 = undefined; | |
| 724 | var buf: [max_path_bytes]u8 = undefined; | |
| 726 | 725 | return allocator.dupe(u8, try posix.realpath(pathname, &buf)); |
| 727 | 726 | } |
| 728 | 727 |
lib/std/fs/Dir.zig+6-6| ... | ... | @@ -1309,7 +1309,7 @@ pub fn realpathZ(self: Dir, pathname: [*:0]const u8, out_buffer: []u8) RealPathE |
| 1309 | 1309 | }; |
| 1310 | 1310 | defer posix.close(fd); |
| 1311 | 1311 | |
| 1312 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1312 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 1313 | 1313 | const out_path = try std.os.getFdPath(fd, &buffer); |
| 1314 | 1314 | |
| 1315 | 1315 | if (out_path.len > out_buffer.len) { |
| ... | ... | @@ -1347,7 +1347,7 @@ pub fn realpathW(self: Dir, pathname: []const u16, out_buffer: []u8) RealPathErr |
| 1347 | 1347 | |
| 1348 | 1348 | var wide_buf: [w.PATH_MAX_WIDE]u16 = undefined; |
| 1349 | 1349 | const wide_slice = try w.GetFinalPathNameByHandle(h_file, .{}, &wide_buf); |
| 1350 | var big_out_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1350 | var big_out_buf: [fs.max_path_bytes]u8 = undefined; | |
| 1351 | 1351 | const end_index = std.unicode.wtf16LeToWtf8(&big_out_buf, wide_slice); |
| 1352 | 1352 | if (end_index > out_buffer.len) |
| 1353 | 1353 | return error.NameTooLong; |
| ... | ... | @@ -1361,13 +1361,13 @@ pub const RealPathAllocError = RealPathError || Allocator.Error; |
| 1361 | 1361 | /// Same as `Dir.realpath` except caller must free the returned memory. |
| 1362 | 1362 | /// See also `Dir.realpath`. |
| 1363 | 1363 | pub fn realpathAlloc(self: Dir, allocator: Allocator, pathname: []const u8) RealPathAllocError![]u8 { |
| 1364 | // Use of MAX_PATH_BYTES here is valid as the realpath function does not | |
| 1364 | // Use of max_path_bytes here is valid as the realpath function does not | |
| 1365 | 1365 | // have a variant that takes an arbitrary-size buffer. |
| 1366 | 1366 | // TODO(#4812): Consider reimplementing realpath or using the POSIX.1-2008 |
| 1367 | 1367 | // NULL out parameter (GNU's canonicalize_file_name) to handle overelong |
| 1368 | 1368 | // paths. musl supports passing NULL but restricts the output to PATH_MAX |
| 1369 | 1369 | // anyway. |
| 1370 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1370 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 1371 | 1371 | return allocator.dupe(u8, try self.realpath(pathname, buf[0..])); |
| 1372 | 1372 | } |
| 1373 | 1373 | |
| ... | ... | @@ -2192,10 +2192,10 @@ fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint |
| 2192 | 2192 | var cleanup_dir = true; |
| 2193 | 2193 | defer if (cleanup_dir) dir.close(); |
| 2194 | 2194 | |
| 2195 | // Valid use of MAX_PATH_BYTES because dir_name_buf will only | |
| 2195 | // Valid use of max_path_bytes because dir_name_buf will only | |
| 2196 | 2196 | // ever store a single path component that was returned from the |
| 2197 | 2197 | // filesystem. |
| 2198 | var dir_name_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 2198 | var dir_name_buf: [fs.max_path_bytes]u8 = undefined; | |
| 2199 | 2199 | var dir_name: []const u8 = sub_path; |
| 2200 | 2200 | |
| 2201 | 2201 | // Here we must avoid recursion, in order to provide O(1) memory guarantee of this function. |
lib/std/fs/get_app_data_dir.zig+1-1| ... | ... | @@ -42,7 +42,7 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi |
| 42 | 42 | return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname }); |
| 43 | 43 | }, |
| 44 | 44 | .haiku => { |
| 45 | var dir_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 45 | var dir_path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 46 | 46 | const rc = std.c.find_directory(.B_USER_SETTINGS_DIRECTORY, -1, true, &dir_path_buf, dir_path_buf.len); |
| 47 | 47 | const settings_dir = try allocator.dupeZ(u8, mem.sliceTo(&dir_path_buf, 0)); |
| 48 | 48 | defer allocator.free(settings_dir); |
lib/std/fs/test.zig+7-7| ... | ... | @@ -43,7 +43,7 @@ const PathType = enum { |
| 43 | 43 | fn transform(allocator: mem.Allocator, dir: Dir, relative_path: [:0]const u8) TransformError![:0]const u8 { |
| 44 | 44 | // The final path may not actually exist which would cause realpath to fail. |
| 45 | 45 | // So instead, we get the path of the dir and join it with the relative path. |
| 46 | var fd_path_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 46 | var fd_path_buf: [fs.max_path_bytes]u8 = undefined; | |
| 47 | 47 | const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf); |
| 48 | 48 | return fs.path.joinZ(allocator, &.{ dir_path, relative_path }); |
| 49 | 49 | } |
| ... | ... | @@ -52,7 +52,7 @@ const PathType = enum { |
| 52 | 52 | fn transform(allocator: mem.Allocator, dir: Dir, relative_path: [:0]const u8) TransformError![:0]const u8 { |
| 53 | 53 | // Any drive absolute path (C:\foo) can be converted into a UNC path by |
| 54 | 54 | // using '127.0.0.1' as the server name and '<drive letter>$' as the share name. |
| 55 | var fd_path_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 55 | var fd_path_buf: [fs.max_path_bytes]u8 = undefined; | |
| 56 | 56 | const dir_path = try std.os.getFdPath(dir.fd, &fd_path_buf); |
| 57 | 57 | const windows_path_type = windows.getUnprefixedPathType(u8, dir_path); |
| 58 | 58 | switch (windows_path_type) { |
| ... | ... | @@ -206,13 +206,13 @@ test "Dir.readLink" { |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | fn testReadLink(dir: Dir, target_path: []const u8, symlink_path: []const u8) !void { |
| 209 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 209 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 210 | 210 | const actual = try dir.readLink(symlink_path, buffer[0..]); |
| 211 | 211 | try testing.expectEqualStrings(target_path, actual); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | fn testReadLinkAbsolute(target_path: []const u8, symlink_path: []const u8) !void { |
| 215 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 215 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 216 | 216 | const given = try fs.readLinkAbsolute(symlink_path, buffer[0..]); |
| 217 | 217 | try testing.expectEqualStrings(target_path, given); |
| 218 | 218 | } |
| ... | ... | @@ -611,7 +611,7 @@ test "Dir.realpath smoke test" { |
| 611 | 611 | const allocator = ctx.arena.allocator(); |
| 612 | 612 | const test_file_path = try ctx.transformPath("test_file"); |
| 613 | 613 | const test_dir_path = try ctx.transformPath("test_dir"); |
| 614 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 614 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 615 | 615 | |
| 616 | 616 | // FileNotFound if the path doesn't exist |
| 617 | 617 | try testing.expectError(error.FileNotFound, ctx.dir.realpathAlloc(allocator, test_file_path)); |
| ... | ... | @@ -1041,7 +1041,7 @@ test "openSelfExe" { |
| 1041 | 1041 | test "selfExePath" { |
| 1042 | 1042 | if (native_os == .wasi) return error.SkipZigTest; |
| 1043 | 1043 | |
| 1044 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1044 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 1045 | 1045 | const buf_self_exe_path = try std.fs.selfExePath(&buf); |
| 1046 | 1046 | const alloc_self_exe_path = try std.fs.selfExePathAlloc(testing.allocator); |
| 1047 | 1047 | defer testing.allocator.free(alloc_self_exe_path); |
| ... | ... | @@ -2061,7 +2061,7 @@ test "invalid UTF-8/WTF-8 paths" { |
| 2061 | 2061 | try testing.expectError(expected_err, fs.deleteFileAbsolute(invalid_path)); |
| 2062 | 2062 | try testing.expectError(expected_err, fs.deleteFileAbsoluteZ(invalid_path)); |
| 2063 | 2063 | try testing.expectError(expected_err, fs.deleteTreeAbsolute(invalid_path)); |
| 2064 | var readlink_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 2064 | var readlink_buf: [fs.max_path_bytes]u8 = undefined; | |
| 2065 | 2065 | try testing.expectError(expected_err, fs.readLinkAbsolute(invalid_path, &readlink_buf)); |
| 2066 | 2066 | try testing.expectError(expected_err, fs.readLinkAbsoluteZ(invalid_path, &readlink_buf)); |
| 2067 | 2067 | try testing.expectError(expected_err, fs.symLinkAbsolute(invalid_path, invalid_path, .{})); |
lib/std/mem.zig+3-6| ... | ... | @@ -2083,8 +2083,7 @@ test byteSwapAllFields { |
| 2083 | 2083 | }, k); |
| 2084 | 2084 | } |
| 2085 | 2085 | |
| 2086 | /// Deprecated: use `tokenizeAny`, `tokenizeSequence`, or `tokenizeScalar` | |
| 2087 | pub const tokenize = tokenizeAny; | |
| 2086 | pub const tokenize = @compileError("deprecated; use tokenizeAny, tokenizeSequence, or tokenizeScalar"); | |
| 2088 | 2087 | |
| 2089 | 2088 | /// Returns an iterator that iterates over the slices of `buffer` that are not |
| 2090 | 2089 | /// any of the items in `delimiters`. |
| ... | ... | @@ -2284,8 +2283,7 @@ test "tokenize (reset)" { |
| 2284 | 2283 | } |
| 2285 | 2284 | } |
| 2286 | 2285 | |
| 2287 | /// Deprecated: use `splitSequence`, `splitAny`, or `splitScalar` | |
| 2288 | pub const split = splitSequence; | |
| 2286 | pub const split = @compileError("deprecated; use splitSequence, splitAny, or splitScalar"); | |
| 2289 | 2287 | |
| 2290 | 2288 | /// Returns an iterator that iterates over the slices of `buffer` that |
| 2291 | 2289 | /// are separated by the byte sequence in `delimiter`. |
| ... | ... | @@ -2486,8 +2484,7 @@ test "split (reset)" { |
| 2486 | 2484 | } |
| 2487 | 2485 | } |
| 2488 | 2486 | |
| 2489 | /// Deprecated: use `splitBackwardsSequence`, `splitBackwardsAny`, or `splitBackwardsScalar` | |
| 2490 | pub const splitBackwards = splitBackwardsSequence; | |
| 2487 | pub const splitBackwards = @compileError("deprecated; use splitBackwardsSequence, splitBackwardsAny, or splitBackwardsScalar"); | |
| 2491 | 2488 | |
| 2492 | 2489 | /// Returns an iterator that iterates backwards over the slices of `buffer` that |
| 2493 | 2490 | /// are separated by the sequence in `delimiter`. |
lib/std/os.zig+10-10| ... | ... | @@ -21,7 +21,7 @@ const mem = std.mem; |
| 21 | 21 | const elf = std.elf; |
| 22 | 22 | const fs = std.fs; |
| 23 | 23 | const dl = @import("dynamic_library.zig"); |
| 24 | const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES; | |
| 24 | const max_path_bytes = std.fs.max_path_bytes; | |
| 25 | 25 | const posix = std.posix; |
| 26 | 26 | |
| 27 | 27 | pub const linux = @import("os/linux.zig"); |
| ... | ... | @@ -99,7 +99,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool { |
| 99 | 99 | /// * On other platforms, the result is an opaque sequence of bytes with no particular encoding. |
| 100 | 100 | /// |
| 101 | 101 | /// Calling this function is usually a bug. |
| 102 | pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix.RealPathError![]u8 { | |
| 102 | pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix.RealPathError![]u8 { | |
| 103 | 103 | if (!comptime isGetFdPathSupportedOnTarget(builtin.os)) { |
| 104 | 104 | @compileError("querying for canonical path of a handle is unsupported on this host"); |
| 105 | 105 | } |
| ... | ... | @@ -114,7 +114,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix. |
| 114 | 114 | .macos, .ios, .watchos, .tvos, .visionos => { |
| 115 | 115 | // On macOS, we can use F.GETPATH fcntl command to query the OS for |
| 116 | 116 | // the path to the file descriptor. |
| 117 | @memset(out_buffer[0..MAX_PATH_BYTES], 0); | |
| 117 | @memset(out_buffer[0..max_path_bytes], 0); | |
| 118 | 118 | switch (posix.errno(posix.system.fcntl(fd, posix.F.GETPATH, out_buffer))) { |
| 119 | 119 | .SUCCESS => {}, |
| 120 | 120 | .BADF => return error.FileNotFound, |
| ... | ... | @@ -123,7 +123,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix. |
| 123 | 123 | // errno values to expect when command is F.GETPATH... |
| 124 | 124 | else => |err| return posix.unexpectedErrno(err), |
| 125 | 125 | } |
| 126 | const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse MAX_PATH_BYTES; | |
| 126 | const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes; | |
| 127 | 127 | return out_buffer[0..len]; |
| 128 | 128 | }, |
| 129 | 129 | .linux => { |
| ... | ... | @@ -163,7 +163,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix. |
| 163 | 163 | .BADF => return error.FileNotFound, |
| 164 | 164 | else => |err| return posix.unexpectedErrno(err), |
| 165 | 165 | } |
| 166 | const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse MAX_PATH_BYTES; | |
| 166 | const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse max_path_bytes; | |
| 167 | 167 | if (len == 0) return error.NameTooLong; |
| 168 | 168 | const result = out_buffer[0..len]; |
| 169 | 169 | @memcpy(result, kfile.path[0..len]); |
| ... | ... | @@ -196,7 +196,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix. |
| 196 | 196 | while (i < len) { |
| 197 | 197 | const kf: *align(1) std.c.kinfo_file = @ptrCast(&buf[i]); |
| 198 | 198 | if (kf.fd == fd) { |
| 199 | len = mem.indexOfScalar(u8, &kf.path, 0) orelse MAX_PATH_BYTES; | |
| 199 | len = mem.indexOfScalar(u8, &kf.path, 0) orelse max_path_bytes; | |
| 200 | 200 | if (len == 0) return error.NameTooLong; |
| 201 | 201 | const result = out_buffer[0..len]; |
| 202 | 202 | @memcpy(result, kf.path[0..len]); |
| ... | ... | @@ -208,18 +208,18 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix. |
| 208 | 208 | } |
| 209 | 209 | }, |
| 210 | 210 | .dragonfly => { |
| 211 | @memset(out_buffer[0..MAX_PATH_BYTES], 0); | |
| 211 | @memset(out_buffer[0..max_path_bytes], 0); | |
| 212 | 212 | switch (posix.errno(std.c.fcntl(fd, posix.F.GETPATH, out_buffer))) { |
| 213 | 213 | .SUCCESS => {}, |
| 214 | 214 | .BADF => return error.FileNotFound, |
| 215 | 215 | .RANGE => return error.NameTooLong, |
| 216 | 216 | else => |err| return posix.unexpectedErrno(err), |
| 217 | 217 | } |
| 218 | const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse MAX_PATH_BYTES; | |
| 218 | const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes; | |
| 219 | 219 | return out_buffer[0..len]; |
| 220 | 220 | }, |
| 221 | 221 | .netbsd => { |
| 222 | @memset(out_buffer[0..MAX_PATH_BYTES], 0); | |
| 222 | @memset(out_buffer[0..max_path_bytes], 0); | |
| 223 | 223 | switch (posix.errno(std.c.fcntl(fd, posix.F.GETPATH, out_buffer))) { |
| 224 | 224 | .SUCCESS => {}, |
| 225 | 225 | .ACCES => return error.AccessDenied, |
| ... | ... | @@ -229,7 +229,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[MAX_PATH_BYTES]u8) std.posix. |
| 229 | 229 | .RANGE => return error.NameTooLong, |
| 230 | 230 | else => |err| return posix.unexpectedErrno(err), |
| 231 | 231 | } |
| 232 | const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse MAX_PATH_BYTES; | |
| 232 | const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes; | |
| 233 | 233 | return out_buffer[0..len]; |
| 234 | 234 | }, |
| 235 | 235 | else => unreachable, // made unreachable by isGetFdPathSupportedOnTarget above |
lib/std/os/linux/IoUring.zig+2-2| ... | ... | @@ -3995,7 +3995,7 @@ test "ring mapped buffers recv" { |
| 3995 | 3995 | defer fds.close(); |
| 3996 | 3996 | |
| 3997 | 3997 | // for random user_data in sqe/cqe |
| 3998 | var Rnd = std.rand.DefaultPrng.init(0); | |
| 3998 | var Rnd = std.Random.DefaultPrng.init(0); | |
| 3999 | 3999 | var rnd = Rnd.random(); |
| 4000 | 4000 | |
| 4001 | 4001 | var round: usize = 4; // repeat send/recv cycle round times |
| ... | ... | @@ -4081,7 +4081,7 @@ test "ring mapped buffers multishot recv" { |
| 4081 | 4081 | defer fds.close(); |
| 4082 | 4082 | |
| 4083 | 4083 | // for random user_data in sqe/cqe |
| 4084 | var Rnd = std.rand.DefaultPrng.init(0); | |
| 4084 | var Rnd = std.Random.DefaultPrng.init(0); | |
| 4085 | 4085 | var rnd = Rnd.random(); |
| 4086 | 4086 | |
| 4087 | 4087 | var round: usize = 4; // repeat send/recv cycle round times |
lib/std/os/plan9.zig+5-5| ... | ... | @@ -285,16 +285,16 @@ pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, _: mode_t) usize { |
| 285 | 285 | if (dirfd == AT.FDCWD) { // openat(AT_FDCWD, ...) == open(...) |
| 286 | 286 | return open(path, flags); |
| 287 | 287 | } |
| 288 | var dir_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 289 | var total_path_buf: [std.fs.MAX_PATH_BYTES + 1]u8 = undefined; | |
| 290 | const rc = fd2path(dirfd, &dir_path_buf, std.fs.MAX_PATH_BYTES); | |
| 288 | var dir_path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 289 | var total_path_buf: [std.fs.max_path_bytes + 1]u8 = undefined; | |
| 290 | const rc = fd2path(dirfd, &dir_path_buf, std.fs.max_path_bytes); | |
| 291 | 291 | if (rc != 0) return rc; |
| 292 | 292 | var fba = std.heap.FixedBufferAllocator.init(&total_path_buf); |
| 293 | 293 | var alloc = fba.allocator(); |
| 294 | 294 | const dir_path = std.mem.span(@as([*:0]u8, @ptrCast(&dir_path_buf))); |
| 295 | const total_path = std.fs.path.join(alloc, &.{ dir_path, std.mem.span(path) }) catch unreachable; // the allocation shouldn't fail because it should not exceed MAX_PATH_BYTES | |
| 295 | const total_path = std.fs.path.join(alloc, &.{ dir_path, std.mem.span(path) }) catch unreachable; // the allocation shouldn't fail because it should not exceed max_path_bytes | |
| 296 | 296 | fba.reset(); |
| 297 | const total_path_z = alloc.dupeZ(u8, total_path) catch unreachable; // should not exceed MAX_PATH_BYTES + 1 | |
| 297 | const total_path_z = alloc.dupeZ(u8, total_path) catch unreachable; // should not exceed max_path_bytes + 1 | |
| 298 | 298 | return open(total_path_z.ptr, flags); |
| 299 | 299 | } |
| 300 | 300 |
lib/std/os/windows/test.zig+2-2| ... | ... | @@ -30,7 +30,7 @@ fn testToPrefixedFileNoOracle(comptime path: []const u8, comptime expected_path: |
| 30 | 30 | const expected_path_utf16 = std.unicode.utf8ToUtf16LeStringLiteral(expected_path); |
| 31 | 31 | const actual_path = try windows.wToPrefixedFileW(null, path_utf16); |
| 32 | 32 | std.testing.expectEqualSlices(u16, expected_path_utf16, actual_path.span()) catch |e| { |
| 33 | std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(actual_path.span()), std.unicode.fmtUtf16le(expected_path_utf16) }); | |
| 33 | std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(actual_path.span()), std.unicode.fmtUtf16Le(expected_path_utf16) }); | |
| 34 | 34 | return e; |
| 35 | 35 | }; |
| 36 | 36 | } |
| ... | ... | @@ -48,7 +48,7 @@ fn testToPrefixedFileOnlyOracle(comptime path: []const u8) !void { |
| 48 | 48 | const zig_result = try windows.wToPrefixedFileW(null, path_utf16); |
| 49 | 49 | const win32_api_result = try RtlDosPathNameToNtPathName_U(path_utf16); |
| 50 | 50 | std.testing.expectEqualSlices(u16, win32_api_result.span(), zig_result.span()) catch |e| { |
| 51 | std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(zig_result.span()), std.unicode.fmtUtf16le(win32_api_result.span()) }); | |
| 51 | std.debug.print("got '{s}', expected '{s}'\n", .{ std.unicode.fmtUtf16Le(zig_result.span()), std.unicode.fmtUtf16Le(win32_api_result.span()) }); | |
| 52 | 52 | return e; |
| 53 | 53 | }; |
| 54 | 54 | } |
lib/std/posix.zig+1-1| ... | ... | @@ -19,7 +19,7 @@ const root = @import("root"); |
| 19 | 19 | const std = @import("std.zig"); |
| 20 | 20 | const mem = std.mem; |
| 21 | 21 | const fs = std.fs; |
| 22 | const max_path_bytes = fs.MAX_PATH_BYTES; | |
| 22 | const max_path_bytes = fs.max_path_bytes; | |
| 23 | 23 | const maxInt = std.math.maxInt; |
| 24 | 24 | const cast = std.math.cast; |
| 25 | 25 | const assert = std.debug.assert; |
lib/std/posix/test.zig+10-10| ... | ... | @@ -31,13 +31,13 @@ test "chdir smoke test" { |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Get current working directory path |
| 34 | var old_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 34 | var old_cwd_buf: [fs.max_path_bytes]u8 = undefined; | |
| 35 | 35 | const old_cwd = try posix.getcwd(old_cwd_buf[0..]); |
| 36 | 36 | |
| 37 | 37 | { |
| 38 | 38 | // Firstly, changing to itself should have no effect |
| 39 | 39 | try posix.chdir(old_cwd); |
| 40 | var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 40 | var new_cwd_buf: [fs.max_path_bytes]u8 = undefined; | |
| 41 | 41 | const new_cwd = try posix.getcwd(new_cwd_buf[0..]); |
| 42 | 42 | try expect(mem.eql(u8, old_cwd, new_cwd)); |
| 43 | 43 | } |
| ... | ... | @@ -50,7 +50,7 @@ test "chdir smoke test" { |
| 50 | 50 | // Restore cwd because process may have other tests that do not tolerate chdir. |
| 51 | 51 | defer posix.chdir(old_cwd) catch unreachable; |
| 52 | 52 | |
| 53 | var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 53 | var new_cwd_buf: [fs.max_path_bytes]u8 = undefined; | |
| 54 | 54 | const new_cwd = try posix.getcwd(new_cwd_buf[0..]); |
| 55 | 55 | try expect(mem.eql(u8, parent, new_cwd)); |
| 56 | 56 | } |
| ... | ... | @@ -58,7 +58,7 @@ test "chdir smoke test" { |
| 58 | 58 | // Next, change current working directory to a temp directory one level below |
| 59 | 59 | { |
| 60 | 60 | // Create a tmp directory |
| 61 | var tmp_dir_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 61 | var tmp_dir_buf: [fs.max_path_bytes]u8 = undefined; | |
| 62 | 62 | const tmp_dir_path = path: { |
| 63 | 63 | var allocator = std.heap.FixedBufferAllocator.init(&tmp_dir_buf); |
| 64 | 64 | break :path try fs.path.resolve(allocator.allocator(), &[_][]const u8{ old_cwd, "zig-test-tmp" }); |
| ... | ... | @@ -68,11 +68,11 @@ test "chdir smoke test" { |
| 68 | 68 | // Change current working directory to tmp directory |
| 69 | 69 | try posix.chdir("zig-test-tmp"); |
| 70 | 70 | |
| 71 | var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 71 | var new_cwd_buf: [fs.max_path_bytes]u8 = undefined; | |
| 72 | 72 | const new_cwd = try posix.getcwd(new_cwd_buf[0..]); |
| 73 | 73 | |
| 74 | 74 | // On Windows, fs.path.resolve returns an uppercase drive letter, but the drive letter returned by getcwd may be lowercase |
| 75 | var resolved_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 75 | var resolved_cwd_buf: [fs.max_path_bytes]u8 = undefined; | |
| 76 | 76 | const resolved_cwd = path: { |
| 77 | 77 | var allocator = std.heap.FixedBufferAllocator.init(&resolved_cwd_buf); |
| 78 | 78 | break :path try fs.path.resolve(allocator.allocator(), &[_][]const u8{new_cwd}); |
| ... | ... | @@ -230,7 +230,7 @@ test "symlink with relative paths" { |
| 230 | 230 | try posix.symlink("file.txt", "symlinked"); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 233 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 234 | 234 | const given = try posix.readlink("symlinked", buffer[0..]); |
| 235 | 235 | try expect(mem.eql(u8, "file.txt", given)); |
| 236 | 236 | |
| ... | ... | @@ -247,7 +247,7 @@ test "readlink on Windows" { |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void { |
| 250 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 250 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 251 | 251 | const given = try posix.readlink(symlink_path, buffer[0..]); |
| 252 | 252 | try expect(mem.eql(u8, target_path, given)); |
| 253 | 253 | } |
| ... | ... | @@ -385,7 +385,7 @@ test "readlinkat" { |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // read the link |
| 388 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 388 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 389 | 389 | const read_link = try posix.readlinkat(tmp.dir.fd, "link", buffer[0..]); |
| 390 | 390 | try expect(mem.eql(u8, "file.txt", read_link)); |
| 391 | 391 | } |
| ... | ... | @@ -466,7 +466,7 @@ test "getrandom" { |
| 466 | 466 | |
| 467 | 467 | test "getcwd" { |
| 468 | 468 | // at least call it so it gets compiled |
| 469 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 469 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 470 | 470 | _ = posix.getcwd(&buf) catch undefined; |
| 471 | 471 | } |
| 472 | 472 |
lib/std/process.zig+3-3| ... | ... | @@ -32,9 +32,9 @@ pub const GetCwdAllocError = Allocator.Error || posix.GetCwdError; |
| 32 | 32 | /// On Windows, the result is encoded as [WTF-8](https://simonsapin.github.io/wtf-8/). |
| 33 | 33 | /// On other platforms, the result is an opaque sequence of bytes with no particular encoding. |
| 34 | 34 | pub fn getCwdAlloc(allocator: Allocator) ![]u8 { |
| 35 | // The use of MAX_PATH_BYTES here is just a heuristic: most paths will fit | |
| 35 | // The use of max_path_bytes here is just a heuristic: most paths will fit | |
| 36 | 36 | // in stack_buf, avoiding an extra allocation in the common case. |
| 37 | var stack_buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 37 | var stack_buf: [fs.max_path_bytes]u8 = undefined; | |
| 38 | 38 | var heap_buf: ?[]u8 = null; |
| 39 | 39 | defer if (heap_buf) |buf| allocator.free(buf); |
| 40 | 40 | |
| ... | ... | @@ -1618,7 +1618,7 @@ pub const can_execv = switch (native_os) { |
| 1618 | 1618 | else => true, |
| 1619 | 1619 | }; |
| 1620 | 1620 | |
| 1621 | /// Tells whether spawning child processes is supported (e.g. via ChildProcess) | |
| 1621 | /// Tells whether spawning child processes is supported (e.g. via Child) | |
| 1622 | 1622 | pub const can_spawn = switch (native_os) { |
| 1623 | 1623 | .wasi, .watchos, .tvos, .visionos => false, |
| 1624 | 1624 | else => true, |
lib/std/std.zig-4| ... | ... | @@ -43,8 +43,6 @@ pub const StringHashMap = hash_map.StringHashMap; |
| 43 | 43 | pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged; |
| 44 | 44 | pub const StringArrayHashMap = array_hash_map.StringArrayHashMap; |
| 45 | 45 | pub const StringArrayHashMapUnmanaged = array_hash_map.StringArrayHashMapUnmanaged; |
| 46 | /// deprecated: use `DoublyLinkedList`. | |
| 47 | pub const TailQueue = DoublyLinkedList; | |
| 48 | 46 | pub const Target = @import("Target.zig"); |
| 49 | 47 | pub const Thread = @import("Thread.zig"); |
| 50 | 48 | pub const Treap = @import("treap.zig").Treap; |
| ... | ... | @@ -88,8 +86,6 @@ pub const packed_int_array = @import("packed_int_array.zig"); |
| 88 | 86 | pub const pdb = @import("pdb.zig"); |
| 89 | 87 | pub const posix = @import("posix.zig"); |
| 90 | 88 | pub const process = @import("process.zig"); |
| 91 | /// Deprecated: use `Random` instead. | |
| 92 | pub const rand = Random; | |
| 93 | 89 | pub const sort = @import("sort.zig"); |
| 94 | 90 | pub const simd = @import("simd.zig"); |
| 95 | 91 | pub const ascii = @import("ascii.zig"); |
lib/std/tar.zig+6-6| ... | ... | @@ -283,9 +283,9 @@ fn nullStr(str: []const u8) []const u8 { |
| 283 | 283 | /// Options for iterator. |
| 284 | 284 | /// Buffers should be provided by the caller. |
| 285 | 285 | pub const IteratorOptions = struct { |
| 286 | /// Use a buffer with length `std.fs.MAX_PATH_BYTES` to match file system capabilities. | |
| 286 | /// Use a buffer with length `std.fs.max_path_bytes` to match file system capabilities. | |
| 287 | 287 | file_name_buffer: []u8, |
| 288 | /// Use a buffer with length `std.fs.MAX_PATH_BYTES` to match file system capabilities. | |
| 288 | /// Use a buffer with length `std.fs.max_path_bytes` to match file system capabilities. | |
| 289 | 289 | link_name_buffer: []u8, |
| 290 | 290 | /// Collects error messages during unpacking |
| 291 | 291 | diagnostics: ?*Diagnostics = null, |
| ... | ... | @@ -613,8 +613,8 @@ fn PaxIterator(comptime ReaderType: type) type { |
| 613 | 613 | |
| 614 | 614 | /// Saves tar file content to the file systems. |
| 615 | 615 | pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: PipeOptions) !void { |
| 616 | var file_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 617 | var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 616 | var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 617 | var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 618 | 618 | var iter = iterator(reader, .{ |
| 619 | 619 | .file_name_buffer = &file_name_buffer, |
| 620 | 620 | .link_name_buffer = &link_name_buffer, |
| ... | ... | @@ -946,8 +946,8 @@ test iterator { |
| 946 | 946 | var fbs = std.io.fixedBufferStream(data); |
| 947 | 947 | |
| 948 | 948 | // User provided buffers to the iterator |
| 949 | var file_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 950 | var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 949 | var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 950 | var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 951 | 951 | // Create iterator |
| 952 | 952 | var iter = iterator(fbs.reader(), .{ |
| 953 | 953 | .file_name_buffer = &file_name_buffer, |
lib/std/tar/test.zig+2-2| ... | ... | @@ -342,8 +342,8 @@ const Md5Writer = struct { |
| 342 | 342 | }; |
| 343 | 343 | |
| 344 | 344 | test "run test cases" { |
| 345 | var file_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 346 | var link_name_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 345 | var file_name_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 346 | var link_name_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 347 | 347 | |
| 348 | 348 | for (cases) |case| { |
| 349 | 349 | var fsb = std.io.fixedBufferStream(case.data); |
lib/std/unicode.zig+6-11| ... | ... | @@ -983,8 +983,7 @@ pub fn utf16LeToUtf8ArrayList(result: *std.ArrayList(u8), utf16le: []const u16) |
| 983 | 983 | return utf16LeToUtf8ArrayListImpl(result, utf16le, .cannot_encode_surrogate_half); |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | /// Deprecated; renamed to utf16LeToUtf8Alloc | |
| 987 | pub const utf16leToUtf8Alloc = utf16LeToUtf8Alloc; | |
| 986 | pub const utf16leToUtf8Alloc = @compileError("deprecated; renamed to utf16LeToUtf8Alloc"); | |
| 988 | 987 | |
| 989 | 988 | /// Caller must free returned memory. |
| 990 | 989 | pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![]u8 { |
| ... | ... | @@ -996,8 +995,7 @@ pub fn utf16LeToUtf8Alloc(allocator: mem.Allocator, utf16le: []const u16) Utf16L |
| 996 | 995 | return result.toOwnedSlice(); |
| 997 | 996 | } |
| 998 | 997 | |
| 999 | /// Deprecated; renamed to utf16LeToUtf8AllocZ | |
| 1000 | pub const utf16leToUtf8AllocZ = utf16LeToUtf8AllocZ; | |
| 998 | pub const utf16leToUtf8AllocZ = @compileError("deprecated; renamed to utf16LeToUtf8AllocZ"); | |
| 1001 | 999 | |
| 1002 | 1000 | /// Caller must free returned memory. |
| 1003 | 1001 | pub fn utf16LeToUtf8AllocZ(allocator: mem.Allocator, utf16le: []const u16) Utf16LeToUtf8AllocError![:0]u8 { |
| ... | ... | @@ -1067,8 +1065,7 @@ fn utf16LeToUtf8Impl(utf8: []u8, utf16le: []const u16, comptime surrogates: Surr |
| 1067 | 1065 | return dest_index; |
| 1068 | 1066 | } |
| 1069 | 1067 | |
| 1070 | /// Deprecated; renamed to utf16LeToUtf8 | |
| 1071 | pub const utf16leToUtf8 = utf16LeToUtf8; | |
| 1068 | pub const utf16leToUtf8 = @compileError("deprecated; renamed to utf16LeToUtf8"); | |
| 1072 | 1069 | |
| 1073 | 1070 | pub fn utf16LeToUtf8(utf8: []u8, utf16le: []const u16) Utf16LeToUtf8Error!usize { |
| 1074 | 1071 | return utf16LeToUtf8Impl(utf8, utf16le, .cannot_encode_surrogate_half); |
| ... | ... | @@ -1189,8 +1186,7 @@ pub fn utf8ToUtf16LeAlloc(allocator: mem.Allocator, utf8: []const u8) error{ Inv |
| 1189 | 1186 | return result.toOwnedSlice(); |
| 1190 | 1187 | } |
| 1191 | 1188 | |
| 1192 | /// Deprecated; renamed to utf8ToUtf16LeAllocZ | |
| 1193 | pub const utf8ToUtf16LeWithNull = utf8ToUtf16LeAllocZ; | |
| 1189 | pub const utf8ToUtf16LeWithNull = @compileError("deprecated; renamed to utf8ToUtf16LeAllocZ"); | |
| 1194 | 1190 | |
| 1195 | 1191 | pub fn utf8ToUtf16LeAllocZ(allocator: mem.Allocator, utf8: []const u8) error{ InvalidUtf8, OutOfMemory }![:0]u16 { |
| 1196 | 1192 | // optimistically guess that it will not require surrogate pairs |
| ... | ... | @@ -1335,7 +1331,7 @@ test utf8ToUtf16LeAllocZ { |
| 1335 | 1331 | try testing.expectError(error.InvalidUtf8, result); |
| 1336 | 1332 | } |
| 1337 | 1333 | { |
| 1338 | const utf16 = try utf8ToUtf16LeWithNull(testing.allocator, "This string has been designed to test the vectorized implementat" ++ | |
| 1334 | const utf16 = try utf8ToUtf16LeAllocZ(testing.allocator, "This string has been designed to test the vectorized implementat" ++ | |
| 1339 | 1335 | "ion by beginning with one hundred twenty-seven ASCII characters¡"); |
| 1340 | 1336 | defer testing.allocator.free(utf16); |
| 1341 | 1337 | try testing.expectEqualSlices(u8, &.{ |
| ... | ... | @@ -1479,8 +1475,7 @@ fn formatUtf16Le( |
| 1479 | 1475 | try writer.writeAll(buf[0..u8len]); |
| 1480 | 1476 | } |
| 1481 | 1477 | |
| 1482 | /// Deprecated; renamed to fmtUtf16Le | |
| 1483 | pub const fmtUtf16le = fmtUtf16Le; | |
| 1478 | pub const fmtUtf16le = @compileError("deprecated; renamed to fmtUtf16Le"); | |
| 1484 | 1479 | |
| 1485 | 1480 | /// Return a Formatter for a (potentially ill-formed) UTF-16 LE string, |
| 1486 | 1481 | /// which will be converted to UTF-8 during formatting. |
lib/std/zig.zig+1-2| ... | ... | @@ -15,8 +15,7 @@ pub const Ast = @import("zig/Ast.zig"); |
| 15 | 15 | pub const AstGen = @import("zig/AstGen.zig"); |
| 16 | 16 | pub const Zir = @import("zig/Zir.zig"); |
| 17 | 17 | pub const system = @import("zig/system.zig"); |
| 18 | /// Deprecated: use `std.Target.Query`. | |
| 19 | pub const CrossTarget = std.Target.Query; | |
| 18 | pub const CrossTarget = @compileError("deprecated; use std.Target.Query"); | |
| 20 | 19 | pub const BuiltinFn = @import("zig/BuiltinFn.zig"); |
| 21 | 20 | pub const AstRlAnnotate = @import("zig/AstRlAnnotate.zig"); |
| 22 | 21 | pub const LibCInstallation = @import("zig/LibCInstallation.zig"); |
lib/std/zig/WindowsSdk.zig+7-7| ... | ... | @@ -444,7 +444,7 @@ pub const Installation = struct { |
| 444 | 444 | |
| 445 | 445 | error.OutOfMemory => return error.OutOfMemory, |
| 446 | 446 | }; |
| 447 | if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) { | |
| 447 | if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) { | |
| 448 | 448 | allocator.free(path_maybe_with_trailing_slash); |
| 449 | 449 | return error.PathTooLong; |
| 450 | 450 | } |
| ... | ... | @@ -459,7 +459,7 @@ pub const Installation = struct { |
| 459 | 459 | errdefer allocator.free(path); |
| 460 | 460 | |
| 461 | 461 | const version = version: { |
| 462 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 462 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 463 | 463 | const sdk_lib_dir_path = std.fmt.bufPrint(buf[0..], "{s}\\Lib\\", .{path}) catch |err| switch (err) { |
| 464 | 464 | error.NoSpaceLeft => return error.PathTooLong, |
| 465 | 465 | }; |
| ... | ... | @@ -516,7 +516,7 @@ pub const Installation = struct { |
| 516 | 516 | error.OutOfMemory => return error.OutOfMemory, |
| 517 | 517 | }; |
| 518 | 518 | |
| 519 | if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) { | |
| 519 | if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) { | |
| 520 | 520 | allocator.free(path_maybe_with_trailing_slash); |
| 521 | 521 | return error.PathTooLong; |
| 522 | 522 | } |
| ... | ... | @@ -562,7 +562,7 @@ pub const Installation = struct { |
| 562 | 562 | |
| 563 | 563 | /// Check whether this version is enumerated in registry. |
| 564 | 564 | fn isValidVersion(installation: Installation) bool { |
| 565 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 565 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 566 | 566 | const reg_query_as_wtf8 = std.fmt.bufPrint(buf[0..], "{s}\\{s}\\Installed Options", .{ |
| 567 | 567 | windows_kits_reg_key, |
| 568 | 568 | installation.version, |
| ... | ... | @@ -878,7 +878,7 @@ const MsvcLibDir = struct { |
| 878 | 878 | error.OutOfMemory => return error.OutOfMemory, |
| 879 | 879 | else => continue, |
| 880 | 880 | }; |
| 881 | if (source_directories_value.len > (std.fs.MAX_PATH_BYTES * 30)) { // note(bratishkaerik): guessing from the fact that on my computer it has 15 pathes and at least some of them are not of max length | |
| 881 | if (source_directories_value.len > (std.fs.max_path_bytes * 30)) { // note(bratishkaerik): guessing from the fact that on my computer it has 15 pathes and at least some of them are not of max length | |
| 882 | 882 | allocator.free(source_directories_value); |
| 883 | 883 | continue; |
| 884 | 884 | } |
| ... | ... | @@ -892,7 +892,7 @@ const MsvcLibDir = struct { |
| 892 | 892 | const msvc_dir: []const u8 = msvc_dir: { |
| 893 | 893 | const msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first()); |
| 894 | 894 | |
| 895 | if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) { | |
| 895 | if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) { | |
| 896 | 896 | allocator.free(msvc_include_dir_maybe_with_trailing_slash); |
| 897 | 897 | return error.PathNotFound; |
| 898 | 898 | } |
| ... | ... | @@ -960,7 +960,7 @@ const MsvcLibDir = struct { |
| 960 | 960 | else => break :try_vs7_key, |
| 961 | 961 | }; |
| 962 | 962 | |
| 963 | if (path_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) { | |
| 963 | if (path_maybe_with_trailing_slash.len > std.fs.max_path_bytes or !std.fs.path.isAbsolute(path_maybe_with_trailing_slash)) { | |
| 964 | 964 | allocator.free(path_maybe_with_trailing_slash); |
| 965 | 965 | break :try_vs7_key; |
| 966 | 966 | } |
lib/std/zip.zig+1-1| ... | ... | @@ -583,7 +583,7 @@ pub fn extract(dest: std.fs.Dir, seekable_stream: anytype, options: ExtractOptio |
| 583 | 583 | const SeekableStream = @TypeOf(seekable_stream); |
| 584 | 584 | var iter = try Iterator(SeekableStream).init(seekable_stream); |
| 585 | 585 | |
| 586 | var filename_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 586 | var filename_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 587 | 587 | while (try iter.next()) |entry| { |
| 588 | 588 | const crc32 = try entry.extract(seekable_stream, options, &filename_buf, dest); |
| 589 | 589 | if (crc32 != entry.crc32) |
lib/std/zip/test.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ pub fn expectFiles( |
| 17 | 17 | }, |
| 18 | 18 | ) !void { |
| 19 | 19 | for (test_files) |test_file| { |
| 20 | var normalized_sub_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 20 | var normalized_sub_path_buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 21 | 21 | |
| 22 | 22 | const name = blk: { |
| 23 | 23 | if (opt.strip_prefix) |strip_prefix| { |
src/Builtin.zig+1-1| ... | ... | @@ -266,7 +266,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void { |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | fn writeFile(file: *File, mod: *Module) !void { |
| 269 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 269 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 270 | 270 | var af = try mod.root.atomicFile(mod.root_src_path, .{ .make_path = true }, &buf); |
| 271 | 271 | defer af.deinit(); |
| 272 | 272 | try af.file.writeAll(file.source); |
src/Package/Fetch.zig+2-2| ... | ... | @@ -1364,7 +1364,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: fs.Dir, tmp_dir: fs.Dir) anyerror!void |
| 1364 | 1364 | }; |
| 1365 | 1365 | }, |
| 1366 | 1366 | .sym_link => { |
| 1367 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1367 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 1368 | 1368 | const link_name = try dir.readLink(entry.path, &buf); |
| 1369 | 1369 | // TODO: if this would create a symlink to outside |
| 1370 | 1370 | // the destination directory, fail with an error instead. |
| ... | ... | @@ -1748,7 +1748,7 @@ pub fn depDigest( |
| 1748 | 1748 | switch (dep.location) { |
| 1749 | 1749 | .url => return null, |
| 1750 | 1750 | .path => |rel_path| { |
| 1751 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1751 | var buf: [fs.max_path_bytes]u8 = undefined; | |
| 1752 | 1752 | var fba = std.heap.FixedBufferAllocator.init(&buf); |
| 1753 | 1753 | const new_root = pkg_root.resolvePosix(fba.allocator(), rel_path) catch |
| 1754 | 1754 | return null; |
src/codegen/llvm.zig+1-1| ... | ... | @@ -1975,7 +1975,7 @@ pub const Object = struct { |
| 1975 | 1975 | defer gpa.free(dir_path); |
| 1976 | 1976 | if (std.fs.path.isAbsolute(dir_path)) |
| 1977 | 1977 | break :dir_path try o.builder.metadataString(dir_path); |
| 1978 | var abs_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1978 | var abs_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 1979 | 1979 | const abs_path = std.fs.realpath(dir_path, &abs_buffer) catch |
| 1980 | 1980 | break :dir_path try o.builder.metadataString(dir_path); |
| 1981 | 1981 | break :dir_path try o.builder.metadataString(abs_path); |
src/link/Dwarf.zig+3-3| ... | ... | @@ -2006,7 +2006,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, zcu: *Module, low_pc: u64, high_pc: u64) |
| 2006 | 2006 | |
| 2007 | 2007 | // Write the form for the compile unit, which must match the abbrev table above. |
| 2008 | 2008 | const name_strp = try self.strtab.insert(self.allocator, zcu.root_mod.root_src_path); |
| 2009 | var compile_unit_dir_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 2009 | var compile_unit_dir_buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 2010 | 2010 | const compile_unit_dir = resolveCompilationDir(zcu, &compile_unit_dir_buffer); |
| 2011 | 2011 | const comp_dir_strp = try self.strtab.insert(self.allocator, compile_unit_dir); |
| 2012 | 2012 | const producer_strp = try self.strtab.insert(self.allocator, link.producer_string); |
| ... | ... | @@ -2058,7 +2058,7 @@ pub fn writeDbgInfoHeader(self: *Dwarf, zcu: *Module, low_pc: u64, high_pc: u64) |
| 2058 | 2058 | } |
| 2059 | 2059 | } |
| 2060 | 2060 | |
| 2061 | fn resolveCompilationDir(module: *Module, buffer: *[std.fs.MAX_PATH_BYTES]u8) []const u8 { | |
| 2061 | fn resolveCompilationDir(module: *Module, buffer: *[std.fs.max_path_bytes]u8) []const u8 { | |
| 2062 | 2062 | // We fully resolve all paths at this point to avoid lack of source line info in stack |
| 2063 | 2063 | // traces or lack of debugging information which, if relative paths were used, would |
| 2064 | 2064 | // be very location dependent. |
| ... | ... | @@ -2804,7 +2804,7 @@ fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator) !struct { |
| 2804 | 2804 | const dir_path = std.fs.path.dirname(full_path) orelse "."; |
| 2805 | 2805 | const sub_file_path = std.fs.path.basename(full_path); |
| 2806 | 2806 | // https://github.com/ziglang/zig/issues/19353 |
| 2807 | var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 2807 | var buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 2808 | 2808 | const resolved = if (!std.fs.path.isAbsolute(dir_path)) |
| 2809 | 2809 | std.posix.realpath(dir_path, &buffer) catch dir_path |
| 2810 | 2810 | else |
src/link/Elf.zig+2-2| ... | ... | @@ -1831,7 +1831,7 @@ fn parseLdScript(self: *Elf, lib: SystemLib) ParseError!void { |
| 1831 | 1831 | break :success; |
| 1832 | 1832 | } |
| 1833 | 1833 | } else { |
| 1834 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1834 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 1835 | 1835 | if (fs.realpath(scr_obj.path, &buffer)) |path| { |
| 1836 | 1836 | test_path.clearRetainingCapacity(); |
| 1837 | 1837 | try test_path.writer().writeAll(path); |
| ... | ... | @@ -3706,7 +3706,7 @@ fn sortInitFini(self: *Elf) !void { |
| 3706 | 3706 | } |
| 3707 | 3707 | const default: i32 = if (is_ctor_dtor) -1 else std.math.maxInt(i32); |
| 3708 | 3708 | const name = atom_ptr.name(self); |
| 3709 | var it = mem.splitBackwards(u8, name, "."); | |
| 3709 | var it = mem.splitBackwardsScalar(u8, name, '.'); | |
| 3710 | 3710 | const priority = std.fmt.parseUnsigned(u16, it.first(), 10) catch default; |
| 3711 | 3711 | break :blk priority; |
| 3712 | 3712 | }; |
src/link/MachO.zig+2-2| ... | ... | @@ -1230,7 +1230,7 @@ fn parseDependentDylibs(self: *MachO) !void { |
| 1230 | 1230 | const prefix = eatPrefix(rpath, "@loader_path/") orelse rpath; |
| 1231 | 1231 | const rel_path = try fs.path.join(arena, &.{ prefix, path }); |
| 1232 | 1232 | try checked_paths.append(rel_path); |
| 1233 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1233 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 1234 | 1234 | const full_path = fs.realpath(rel_path, &buffer) catch continue; |
| 1235 | 1235 | break :full_path try arena.dupe(u8, full_path); |
| 1236 | 1236 | } |
| ... | ... | @@ -1243,7 +1243,7 @@ fn parseDependentDylibs(self: *MachO) !void { |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | try checked_paths.append(try arena.dupe(u8, id.name)); |
| 1246 | var buffer: [fs.MAX_PATH_BYTES]u8 = undefined; | |
| 1246 | var buffer: [fs.max_path_bytes]u8 = undefined; | |
| 1247 | 1247 | if (fs.realpath(id.name, &buffer)) |full_path| { |
| 1248 | 1248 | break :full_path try arena.dupe(u8, full_path); |
| 1249 | 1249 | } else |_| { |
src/link/MachO/Dylib.zig+1-1| ... | ... | @@ -831,7 +831,7 @@ pub const Id = struct { |
| 831 | 831 | var out: u32 = 0; |
| 832 | 832 | var values: [3][]const u8 = undefined; |
| 833 | 833 | |
| 834 | var split = mem.split(u8, string, "."); | |
| 834 | var split = mem.splitScalar(u8, string, '.'); | |
| 835 | 835 | var count: u4 = 0; |
| 836 | 836 | while (split.next()) |value| { |
| 837 | 837 | if (count > 2) { |
src/link/Plan9.zig+1-1| ... | ... | @@ -365,7 +365,7 @@ fn putFn(self: *Plan9, decl_index: InternPool.DeclIndex, out: FnDeclOutput) !voi |
| 365 | 365 | try a.writer().writeInt(u16, 1, .big); |
| 366 | 366 | |
| 367 | 367 | // getting the full file path |
| 368 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 368 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 369 | 369 | const full_path = try std.fs.path.join(arena, &.{ |
| 370 | 370 | file.mod.root.root_dir.path orelse try std.posix.getcwd(&buf), |
| 371 | 371 | file.mod.root.sub_path, |
src/link/Wasm/Archive.zig+1-1| ... | ... | @@ -192,7 +192,7 @@ pub fn parseObject(archive: Archive, wasm_file: *const Wasm, file_offset: u32) ! |
| 192 | 192 | |
| 193 | 193 | const object_name = try archive.parseName(header); |
| 194 | 194 | const name = name: { |
| 195 | var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 195 | var buffer: [std.fs.max_path_bytes]u8 = undefined; | |
| 196 | 196 | const path = try std.posix.realpath(archive.name, &buffer); |
| 197 | 197 | break :name try std.fmt.allocPrint(gpa, "{s}({s})", .{ path, object_name }); |
| 198 | 198 | }; |
test/standalone/self_exe_symlink/main.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ pub fn main() !void { |
| 10 | 10 | |
| 11 | 11 | var self_exe = try std.fs.openSelfExe(.{}); |
| 12 | 12 | defer self_exe.close(); |
| 13 | var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; | |
| 13 | var buf: [std.fs.max_path_bytes]u8 = undefined; | |
| 14 | 14 | const self_exe_path = try std.os.getFdPath(self_exe.handle, &buf); |
| 15 | 15 | |
| 16 | 16 | try std.testing.expectEqualStrings(self_exe_path, self_path); |
test/standalone/windows_argv/fuzz.zig+2-2| ... | ... | @@ -32,7 +32,7 @@ pub fn main() !void { |
| 32 | 32 | } |
| 33 | 33 | break :seed try std.fmt.parseUnsigned(u64, args[3], 10); |
| 34 | 34 | }; |
| 35 | var random = std.rand.DefaultPrng.init(seed); | |
| 35 | var random = std.Random.DefaultPrng.init(seed); | |
| 36 | 36 | const rand = random.random(); |
| 37 | 37 | |
| 38 | 38 | // If the seed was not given via the CLI, then output the |
| ... | ... | @@ -72,7 +72,7 @@ pub fn main() !void { |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | fn randomCommandLineW(allocator: Allocator, rand: std.rand.Random) ![:0]const u16 { | |
| 75 | fn randomCommandLineW(allocator: Allocator, rand: std.Random) ![:0]const u16 { | |
| 76 | 76 | const Choice = enum { |
| 77 | 77 | backslash, |
| 78 | 78 | quote, |
test/standalone/windows_bat_args/fuzz.zig+2-2| ... | ... | @@ -27,7 +27,7 @@ pub fn main() anyerror!void { |
| 27 | 27 | }; |
| 28 | 28 | break :seed try std.fmt.parseUnsigned(u64, seed_arg, 10); |
| 29 | 29 | }; |
| 30 | var random = std.rand.DefaultPrng.init(seed); | |
| 30 | var random = std.Random.DefaultPrng.init(seed); | |
| 31 | 31 | const rand = random.random(); |
| 32 | 32 | |
| 33 | 33 | // If the seed was not given via the CLI, then output the |
| ... | ... | @@ -109,7 +109,7 @@ fn testExecBat(allocator: std.mem.Allocator, bat: []const u8, args: []const []co |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | fn randomArg(allocator: Allocator, rand: std.rand.Random) ![]const u8 { | |
| 112 | fn randomArg(allocator: Allocator, rand: std.Random) ![]const u8 { | |
| 113 | 113 | const Choice = enum { |
| 114 | 114 | backslash, |
| 115 | 115 | quote, |