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

Commit 5d9bf92

Browse files
committed
Update for changes to zig 0.11.0-dev.3853+ build system etc.
tested with 0.11.0-dev.3857+7322aa118 also - fix @ptrCast (with `zig fmt` help) - move const out of while loop - define const prompt = "> "
1 parent 3f18e56 commit 5d9bf92

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

build.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ pub fn build(b: *std.build.Builder) void {
1717
.target = target,
1818
.optimize = optimize,
1919
});
20-
exe.install();
2120

22-
const run_cmd = exe.run();
21+
// This declares intent for the executable to be installed into the
22+
// standard location when the user invokes the "install" step (the default
23+
// step when running `zig build`).
24+
b.installArtifact(exe);
25+
26+
const run_cmd = b.addRunArtifact(exe);
2327
run_cmd.step.dependOn(b.getInstallStep());
2428
if (b.args) |args| {
2529
run_cmd.addArgs(args);

src/main.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub fn main() !u8 {
1010
}
1111

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

17-
// Prompt
18-
try stdout.print("> ", .{});
17+
while (true) {
18+
try stdout.print(prompt, .{});
1919

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

0 commit comments

Comments
 (0)