From 0f440dfb6fc21c460b6c621571921298d94eb1b0 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 13 Aug 2022 01:23:32 +0200 Subject: Add environment handling --- src/main.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 32874e5..d1b6ccb 100644 --- a/src/main.zig +++ b/src/main.zig @@ -15,7 +15,8 @@ pub fn main() anyerror!void { var file = try std.fs.cwd().openFile("mycology/sanity.bf", .{}); defer file.close(); - var i = try interpreter.Interpreter.init(gpa.allocator(), file.reader(), args); + const env: []const [*:0]const u8 = std.os.environ; + var i = try interpreter.Interpreter.init(gpa.allocator(), file.reader(), args, env[0..]); defer i.deinit(); var ioContext = io.context(std.io.getStdIn().reader(), std.io.getStdOut().writer()); @@ -33,7 +34,8 @@ test "sanity" { defer stdout.deinit(); const expected = "0123456789"; const args = [_][]const u8{"sanity"}; - var i = try interpreter.Interpreter.init(std.testing.allocator, file.reader(), args[0..]); + const env = [_][*:0]const u8{"ENV=TEST"}; + var i = try interpreter.Interpreter.init(std.testing.allocator, file.reader(), args[0..], env[0..]); defer i.deinit(); var ioContext = io.context(stdin.reader(), stdout.writer()); try std.testing.expectEqual(try i.run(&ioContext), 0); -- cgit v1.2.3