Skip to content

Commit fb39a19

Browse files
committed
std: format contents of sentinel terminated many pointers
1 parent 2537756 commit fb39a19

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/std/fmt.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ pub fn formatType(
442442
else => return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) }),
443443
},
444444
.Many, .C => {
445+
if (ptr_info.sentinel) |sentinel| {
446+
const slice = mem.pointerToSlice([:sentinel]const ptr_info.child, value);
447+
return formatType(slice, fmt, options, context, Errors, output, max_depth);
448+
}
445449
if (ptr_info.child == u8) {
446450
if (fmt.len > 0 and fmt[0] == 's') {
447451
const len = mem.len(u8, value);

0 commit comments

Comments
 (0)