diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-01-15 19:43:46 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-01-15 19:43:46 -0800 |
| commit | cf898e242a32b589e63a8de6674a5c2d6f5225bc (patch) | |
| tree | 055694c4daa959ce1c09591f860e32e6feea33a1 /lib/std/Build/Step/CheckObject.zig | |
| parent | 605311211b457d9c9a08d354c8fbe40257c4d649 (diff) | |
| download | zig-cf898e242a32b589e63a8de6674a5c2d6f5225bc.tar.gz zig-cf898e242a32b589e63a8de6674a5c2d6f5225bc.zip | |
std.Build.Step.CheckObject: better EOF handling
when unexpected end of stream occurs, just add that as a token into the
text
Diffstat (limited to 'lib/std/Build/Step/CheckObject.zig')
| -rw-r--r-- | lib/std/Build/Step/CheckObject.zig | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/std/Build/Step/CheckObject.zig b/lib/std/Build/Step/CheckObject.zig index d3632f6b87..289a4ff4f8 100644 --- a/lib/std/Build/Step/CheckObject.zig +++ b/lib/std/Build/Step/CheckObject.zig @@ -2424,7 +2424,22 @@ const WasmDumper = struct { } var output = std.ArrayList(u8).init(gpa); - errdefer output.deinit(); + defer output.deinit(); + parseAndDumpInner(step, check, bytes, &fbs, &output) catch |err| switch (err) { + error.EndOfStream => try output.appendSlice("\n<UnexpectedEndOfStream>"), + else => |e| return e, + }; + return output.toOwnedSlice(); + } + + fn parseAndDumpInner( + step: *Step, + check: Check, + bytes: []const u8, + fbs: *std.io.FixedBufferStream([]const u8), + output: *std.ArrayList(u8), + ) !void { + const reader = fbs.reader(); const writer = output.writer(); switch (check.kind) { @@ -2442,8 +2457,6 @@ const WasmDumper = struct { else => return step.fail("invalid check kind for Wasm file format: {s}", .{@tagName(check.kind)}), } - - return output.toOwnedSlice(); } fn parseAndDumpSection( |
