Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Update for changes to zig 0.11.0-dev.3853+ build system etc. #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ pub fn build(b: *std.build.Builder) void {
.target = target,
.optimize = optimize,
});
exe.install();

const run_cmd = exe.run();
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running `zig build`).
b.installArtifact(exe);

const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
Expand Down
12 changes: 6 additions & 6 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ pub fn main() !u8 {
}

fn shellLoop(stdin: std.fs.File.Reader, stdout: std.fs.File.Writer) !void {
while (true) {
const max_input = 1024;
const max_args = 10;
const max_input = 1024;
const max_args = 10;
const prompt = "> ";

// Prompt
try stdout.print("> ", .{});
while (true) {
try stdout.print(prompt, .{});

// Read STDIN into buffer
var input_buffer: [max_input]u8 = undefined;
Expand All @@ -39,7 +39,7 @@ fn shellLoop(stdin: std.fs.File.Reader, stdout: std.fs.File.Writer) !void {
while (i <= input_str.len) : (i += 1) {
if (input_buffer[i] == 0x20 or input_buffer[i] == 0xa) {
input_buffer[i] = 0; // turn space or line feed into null byte as sentinel
args_ptrs[n] = @ptrCast(*align(1) const [*:0]u8, &input_buffer[ofs..i :0]).*;
args_ptrs[n] = @as(*align(1) const [*:0]u8, @ptrCast(&input_buffer[ofs..i :0])).*;
n += 1;
ofs = i + 1;
}
Expand Down