aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorJulien Dessaux2022-08-13 01:23:32 +0200
committerJulien Dessaux2022-08-13 01:23:32 +0200
commit0f440dfb6fc21c460b6c621571921298d94eb1b0 (patch)
tree4a7011ce12f4bf611883ea9b645e59a213d301af /src/main.zig
parentImplemented the under funge command (diff)
downloadzigfunge98-0f440dfb6fc21c460b6c621571921298d94eb1b0.tar.gz
zigfunge98-0f440dfb6fc21c460b6c621571921298d94eb1b0.tar.bz2
zigfunge98-0f440dfb6fc21c460b6c621571921298d94eb1b0.zip
Add environment handling
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig6
1 files changed, 4 insertions, 2 deletions
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);