{s}", .{
"zig", name,
});
@@ -618,7 +619,7 @@ fn printSourceBlock(arena: Allocator, out: anytype, source_bytes: []const u8, na
try out.writeAll("");
}
-fn tokenizeAndPrint(arena: Allocator, out: anytype, raw_src: []const u8) !void {
+fn tokenizeAndPrint(arena: Allocator, out: *Writer, raw_src: []const u8) !void {
const src_non_terminated = mem.trim(u8, raw_src, " \r\n");
const src = try arena.dupeZ(u8, src_non_terminated);
@@ -846,7 +847,7 @@ fn tokenizeAndPrint(arena: Allocator, out: anytype, raw_src: []const u8) !void {
try out.writeAll("");
}
-fn writeEscapedLines(out: anytype, text: []const u8) !void {
+fn writeEscapedLines(out: *Writer, text: []const u8) !void {
return writeEscaped(out, text);
}
@@ -983,7 +984,7 @@ fn escapeHtml(allocator: Allocator, input: []const u8) ![]u8 {
return try buf.toOwnedSlice();
}
-fn writeEscaped(out: anytype, input: []const u8) !void {
+fn writeEscaped(out: *Writer, input: []const u8) !void {
for (input) |c| {
try switch (c) {
'&' => out.writeAll("&"),
@@ -1014,7 +1015,6 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
var buf = std.array_list.Managed(u8).init(allocator);
defer buf.deinit();
- var out = buf.writer();
var sgr_param_start_index: usize = undefined;
var sgr_num: u8 = undefined;
var sgr_color: u8 = undefined;
@@ -1037,10 +1037,10 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
.start => switch (c) {
'\x1b' => state = .escape,
'\n' => {
- try out.writeByte(c);
+ try buf.append(c);
last_new_line = buf.items.len;
},
- else => try out.writeByte(c),
+ else => try buf.append(c),
},
.escape => switch (c) {
'[' => state = .lbracket,
@@ -1101,16 +1101,16 @@ fn termColor(allocator: Allocator, input: []const u8) ![]u8 {
'm' => {
state = .start;
while (open_span_count != 0) : (open_span_count -= 1) {
- try out.writeAll("");
+ try buf.appendSlice("");
}
if (sgr_num == 0) {
if (sgr_color != 0) return error.UnsupportedColor;
continue;
}
if (sgr_color != 0) {
- try out.print("