Skip to content

Commit 3f63e40

Browse files
fix: home path
1 parent d8fc56f commit 3f63e40

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/Context.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub const CliContext = struct {
127127
break :blk std.process.getEnvVarOwned(context_storage.static_mem.allocator(), "USERPROFILE") catch "./";
128128
} else {
129129
// On POSIX, use getenv which doesn't allocate, then copy to our buffer
130-
const home_env = util_tool.getenv_cross_platform("HOME") orelse "./";
130+
const home_env = std.posix.getenv("HOME") orelse "./";
131131
const allocated = context_storage.static_mem.allocator().dupe(u8, home_env) catch "./";
132132
break :blk allocated;
133133
}
@@ -149,7 +149,7 @@ pub const CliContext = struct {
149149
@memcpy(context_storage.home_dir_buffer[0..home.len], home);
150150
context_storage.home_dir_length = @intCast(home.len);
151151

152-
assert(context_storage.home_dir_length == home.len);
152+
assert(context_storage.home_dir_length > 0);
153153
assert(context_storage.home_dir_length <= context_storage.home_dir_buffer.len);
154154
}
155155

src/main.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ fn detect_version_for_alias(args: []const []const u8) ![]const u8 {
318318
const bytes_read = file.readAll(&content_buf) catch break;
319319
if (bytes_read == 0) break;
320320

321-
if (extractMinimumZigVersionFromJson(content_buf[0..bytes_read])) |version| {
321+
if (extract_minimum_zig_version_from_json(content_buf[0..bytes_read])) |version| {
322322
// Validate version using semantic version parsing
323-
if (validateSemanticVersion(version)) {
323+
if (validate_semantic_version(version)) {
324324
// Store version in static buffer to avoid allocation issues
325325
var version_buf: [64]u8 = undefined;
326326
if (version.len <= version_buf.len) {
@@ -348,7 +348,7 @@ fn detect_version_for_alias(args: []const []const u8) ![]const u8 {
348348
return "current";
349349
}
350350

351-
pub fn validateSemanticVersion(version: []const u8) bool {
351+
pub fn validate_semantic_version(version: []const u8) bool {
352352
// Pair assertion: Validate input bounds
353353
assert(version.len > 0);
354354
assert(version.len < 64); // Reasonable version length limit
@@ -361,7 +361,7 @@ pub fn validateSemanticVersion(version: []const u8) bool {
361361
return true;
362362
}
363363

364-
pub fn extractMinimumZigVersionFromJson(content: []const u8) ?[]const u8 {
364+
pub fn extract_minimum_zig_version_from_json(content: []const u8) ?[]const u8 {
365365
// Pair assertion: Validate input bounds
366366
assert(content.len > 0); // Don't process empty content
367367
assert(content.len <= 8192); // Reasonable upper bound for JSON
@@ -391,7 +391,7 @@ fn ensure_version_available(version: []const u8) !bool {
391391
if (std.mem.eql(u8, version, "current")) return true;
392392

393393
// Get home directory
394-
const home = std.posix.getenv("HOME") orelse return error.HomeNotFound;
394+
const home = util_tool.getenv_cross_platform("HOME") orelse return error.HomeNotFound;
395395

396396
// Build version path with separate buffers
397397
var version_path_buf: [1024]u8 = undefined;

0 commit comments

Comments
 (0)