From b85524d0c83686b7492aee78d5f766e76b59fc90 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 30 Dec 2025 21:45:01 -0800 Subject: [PATCH] std.process.Environ: fix contains function --- lib/std/Io.zig | 2 +- lib/std/Io/Threaded.zig | 6 +++--- lib/std/process/Environ.zig | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/std/Io.zig b/lib/std/Io.zig index 9670ac3bd7..f7de23aa54 100644 --- a/lib/std/Io.zig +++ b/lib/std/Io.zig @@ -2242,5 +2242,5 @@ pub fn unlockStderr(io: Io) void { pub fn environ(io: Io, name: []const u8) ?[]const u8 { _ = io; _ = name; - if (true) @panic("TODO"); + if (true) @panic("TODO Io.environ"); } diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index df1ce77fe5..7f143970ae 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -12711,21 +12711,21 @@ fn scanEnviron(t: *Threaded) void { fn processReplace(userdata: ?*anyopaque, options: std.process.ReplaceOptions) std.process.ReplaceError { _ = userdata; _ = options; - @panic("TODO"); + @panic("TODO processReplace"); } fn processReplacePath(userdata: ?*anyopaque, dir: Dir, options: std.process.ReplaceOptions) std.process.ReplaceError { _ = userdata; _ = dir; _ = options; - @panic("TODO"); + @panic("TODO processReplacePath"); } fn processSpawnPath(userdata: ?*anyopaque, dir: Dir, options: process.SpawnOptions) process.SpawnError!process.Child { _ = userdata; _ = dir; _ = options; - @panic("TODO"); + @panic("TODO processSpawnPath"); } const processSpawn = switch (native_os) { diff --git a/lib/std/process/Environ.zig b/lib/std/process/Environ.zig index 5f5386f02d..ea89edd313 100644 --- a/lib/std/process/Environ.zig +++ b/lib/std/process/Environ.zig @@ -150,7 +150,7 @@ pub const Map = struct { } pub fn contains(m: *const Map, key: []const u8) bool { - return m.contains(key); + return m.array_hash_map.contains(key); } /// If there is an entry with a matching key, it is deleted from the hash @@ -579,10 +579,11 @@ pub const CreateBlockOptions = struct { /// Creates a null-delimited environment variable block in the format expected /// by POSIX, from a different one. pub fn createBlock(existing: Environ, arena: Allocator, options: CreateBlockOptions) Allocator.Error![:null]?[*:0]u8 { + const existing_block: [*:null]const ?[*:0]const u8 = @ptrCast(existing.block); const existing_count, const contains_zig_progress = c: { var count: usize = 0; var contains = false; - while (existing.block[count]) |line| : (count += 1) { + while (existing_block[count]) |line| : (count += 1) { contains = contains or mem.eql(u8, mem.sliceTo(line, '='), "ZIG_PROGRESS"); } break :c .{ count, contains }; @@ -617,7 +618,7 @@ pub fn createBlock(existing: Environ, arena: Allocator, options: CreateBlockOpti i += 1; } - while (existing.block[existing_index]) |line| : (existing_index += 1) { + while (existing_block[existing_index]) |line| : (existing_index += 1) { if (mem.eql(u8, mem.sliceTo(line, '='), "ZIG_PROGRESS")) switch (zig_progress_action) { .add => unreachable, .delete => continue,