commit b85524d0c83686b7492aee78d5f766e76b59fc90 (tree)
parent 32af0f6154edb1c1434d0bb489d2abfea7da1685
Author: Andrew Kelley <andrew@ziglang.org>
Date: Tue, 30 Dec 2025 21:45:01 -0800
std.process.Environ: fix contains function
Diffstat:
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git 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
@@ -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
@@ -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,