authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-30 21:45:01-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-04 00:27:08-08:00
logb85524d0c83686b7492aee78d5f766e76b59fc90
treeb980218e98e957460fc3190efdd441eae5295db9
parent32af0f6154edb1c1434d0bb489d2abfea7da1685

std.process.Environ: fix contains function


3 files changed, 8 insertions(+), 7 deletions(-)

lib/std/Io.zig+1-1
......@@ -2242,5 +2242,5 @@ pub fn unlockStderr(io: Io) void {
22422242pub fn environ(io: Io, name: []const u8) ?[]const u8 {
22432243 _ = io;
22442244 _ = name;
2245 if (true) @panic("TODO");
2245 if (true) @panic("TODO Io.environ");
22462246}
lib/std/Io/Threaded.zig+3-3
......@@ -12711,21 +12711,21 @@ fn scanEnviron(t: *Threaded) void {
1271112711fn processReplace(userdata: ?*anyopaque, options: std.process.ReplaceOptions) std.process.ReplaceError {
1271212712 _ = userdata;
1271312713 _ = options;
12714 @panic("TODO");
12714 @panic("TODO processReplace");
1271512715}
1271612716
1271712717fn processReplacePath(userdata: ?*anyopaque, dir: Dir, options: std.process.ReplaceOptions) std.process.ReplaceError {
1271812718 _ = userdata;
1271912719 _ = dir;
1272012720 _ = options;
12721 @panic("TODO");
12721 @panic("TODO processReplacePath");
1272212722}
1272312723
1272412724fn processSpawnPath(userdata: ?*anyopaque, dir: Dir, options: process.SpawnOptions) process.SpawnError!process.Child {
1272512725 _ = userdata;
1272612726 _ = dir;
1272712727 _ = options;
12728 @panic("TODO");
12728 @panic("TODO processSpawnPath");
1272912729}
1273012730
1273112731const processSpawn = switch (native_os) {
lib/std/process/Environ.zig+4-3
......@@ -150,7 +150,7 @@ pub const Map = struct {
150150 }
151151
152152 pub fn contains(m: *const Map, key: []const u8) bool {
153 return m.contains(key);
153 return m.array_hash_map.contains(key);
154154 }
155155
156156 /// If there is an entry with a matching key, it is deleted from the hash
......@@ -579,10 +579,11 @@ pub const CreateBlockOptions = struct {
579579/// Creates a null-delimited environment variable block in the format expected
580580/// by POSIX, from a different one.
581581pub fn createBlock(existing: Environ, arena: Allocator, options: CreateBlockOptions) Allocator.Error![:null]?[*:0]u8 {
582 const existing_block: [*:null]const ?[*:0]const u8 = @ptrCast(existing.block);
582583 const existing_count, const contains_zig_progress = c: {
583584 var count: usize = 0;
584585 var contains = false;
585 while (existing.block[count]) |line| : (count += 1) {
586 while (existing_block[count]) |line| : (count += 1) {
586587 contains = contains or mem.eql(u8, mem.sliceTo(line, '='), "ZIG_PROGRESS");
587588 }
588589 break :c .{ count, contains };
......@@ -617,7 +618,7 @@ pub fn createBlock(existing: Environ, arena: Allocator, options: CreateBlockOpti
617618 i += 1;
618619 }
619620
620 while (existing.block[existing_index]) |line| : (existing_index += 1) {
621 while (existing_block[existing_index]) |line| : (existing_index += 1) {
621622 if (mem.eql(u8, mem.sliceTo(line, '='), "ZIG_PROGRESS")) switch (zig_progress_action) {
622623 .add => unreachable,
623624 .delete => continue,