authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-15 16:04:44-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:33-07:00
log0b3ca115206c0332284c80f7f7d42358d96379c1
tree85ac49e6f2086568fdcd52b4d47eb3fc65ecb5ae
parent2e88ac8842a6a5bbd9fe654292ab416cadfaf8bf

std.Io.Writer: placeholder code for new {q} format character

intendend to print something with double quotes, escaped the same as a zig string literal.

1 files changed, 19 insertions(+), 0 deletions(-)

lib/std/Io/Writer.zig+19
...@@ -1172,6 +1172,25 @@ pub fn printValue(...@@ -1172,6 +1172,25 @@ pub fn printValue(
1172 },1172 },
1173 else => invalidFmtError(fmt, value),1173 else => invalidFmtError(fmt, value),
1174 },1174 },
1175 // TODO make this print double quotes and quote-escape the string
1176 // according to zig string syntax rules
1177 'q' => switch (@typeInfo(T)) {
1178 .pointer => |info| switch (info.size) {
1179 .one, .slice => {
1180 const slice: []const u8 = value;
1181 return w.alignBufferOptions(slice, options);
1182 },
1183 .many, .c => {
1184 const slice: [:0]const u8 = std.mem.span(value);
1185 return w.alignBufferOptions(slice, options);
1186 },
1187 },
1188 .array => {
1189 const slice: []const u8 = &value;
1190 return w.alignBufferOptions(slice, options);
1191 },
1192 else => invalidFmtError(fmt, value),
1193 },
1175 'B' => switch (@typeInfo(T)) {1194 'B' => switch (@typeInfo(T)) {
1176 .int, .comptime_int => return w.printByteSize(value, .decimal, options),1195 .int, .comptime_int => return w.printByteSize(value, .decimal, options),
1177 .@"struct" => return value.formatByteSize(w, .decimal),1196 .@"struct" => return value.formatByteSize(w, .decimal),