authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-08-24 02:40:22 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-08-24 02:40:22 -07:00
loge918b368d93f61e0af31facfa4bd46f452d827d3
tree1b2e3a3bc0ba3ac5d6729123f8160d7d8150861d
parente5c0a7088040fd61b764a4339e93a6ce67574700

use sys-libc


3 files changed, 13 insertions(+), 5 deletions(-)

licenses.txt+6
......@@ -1,4 +1,10 @@
11MIT:
22= https://spdx.org/licenses/MIT
33- This
4- git https://github.com/nektro/zig-errno
45- git https://github.com/nektro/zig-extras
6- git https://github.com/nektro/zig-libc
7- git https://github.com/nektro/zig-sys-libc
8
9Unspecified:
10- system_lib c
src/lib.zig+6-5
......@@ -2,6 +2,7 @@ const std = @import("std");
22const string = []const u8;
33const List = std.ArrayList(string);
44const extras = @import("extras");
5const libc = @import("sys-libc");
56
67var singles: std.StringArrayHashMap(string) = undefined;
78var multis: std.StringArrayHashMap(List) = undefined;
......@@ -67,7 +68,7 @@ pub fn parse(k: FlagDashKind) !std.process.ArgIterator {
6768 }
6869 }
6970 std.log.err("Unrecognized argument: {s}{s}", .{ dash, name });
70 std.posix.exit(1);
71 libc.exit(1);
7172 }
7273 return argiter;
7374}
......@@ -78,7 +79,7 @@ pub fn parseEnv() !void {
7879 for (singles.keys(), singles.values()) |k, *v| {
7980 const u = try fixNameForEnv(alloc, k);
8081 defer alloc.free(u);
81 if (std.posix.getenv(u)) |value| {
82 if (libc.getenv(u)) |value| {
8283 v.* = value;
8384 }
8485 }
......@@ -87,9 +88,9 @@ pub fn parseEnv() !void {
8788 while (true) : (n += 1) {
8889 const u = try fixNameForEnv(alloc, k);
8990 defer alloc.free(u);
90 const w = try std.fmt.allocPrint(alloc, "{s}_{d}", .{ u, n });
91 const w = try std.fmt.allocPrintZ(alloc, "{s}_{d}", .{ u, n });
9192 defer alloc.free(w);
92 if (std.posix.getenv(w)) |value| {
93 if (libc.getenv(w)) |value| {
9394 try v.append(value);
9495 continue;
9596 }
......@@ -98,7 +99,7 @@ pub fn parseEnv() !void {
9899 }
99100}
100101
101fn fixNameForEnv(alloc: std.mem.Allocator, input: string) !string {
102fn fixNameForEnv(alloc: std.mem.Allocator, input: string) ![:0]const u8 {
102103 var ret = try extras.asciiUpper(alloc, input);
103104 for (0..ret.len) |i| {
104105 if (ret[i] == '-') {
zig.mod+1
......@@ -5,3 +5,4 @@ license: MIT
55description: Config management for Zig.
66dependencies:
77 - src: git https://github.com/nektro/zig-extras
8 - src: git https://github.com/nektro/zig-sys-libc