Skip to content

Commit

Permalink
zig_writer: Replace tabs with spaces when outputting
Browse files Browse the repository at this point in the history
  • Loading branch information
sin-ack committed Sep 15, 2024
1 parent 3346992 commit 7e882d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/zig_writer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ pub fn ZigWriter(comptime Writer: type) type {
const arg = @field(args, arg_fields[current_arg].name);
const arg_type_info = @typeInfo(@TypeOf(arg));
if (arg_type_info == .pointer and arg_type_info.pointer.size == .Slice and arg_type_info.pointer.child == u8) {
try w.out.print("{s}", .{arg});
for (arg) |char| {
switch (char) {
// Zig is very tab-hostile, so we have to replace tabs with spaces.
// This is most relevant when translating documentation.
'\t' => try w.out.writeAll(" "),
else => try w.out.writeByte(char),
}
}
} else {
try w.out.print("{}", .{arg});
}
Expand Down

0 comments on commit 7e882d7

Please sign in to comment.