Add fmt:"s,0" to allow arrays and multi-pointers to be printed with NUL termination

This commit is contained in:
gingerBill
2022-06-12 13:07:43 +01:00
parent 35fd8e7f68
commit d04f732e68
2 changed files with 63 additions and 12 deletions
+6
View File
@@ -109,6 +109,12 @@ check_zero_ptr :: proc(ptr: rawptr, len: int) -> bool {
case ptr == nil:
return true
}
switch len {
case 1: return (^u8)(ptr)^ == 0
case 2: return intrinsics.unaligned_load((^u16)(ptr)) == 0
case 4: return intrinsics.unaligned_load((^u32)(ptr)) == 0
case 8: return intrinsics.unaligned_load((^u64)(ptr)) == 0
}
start := uintptr(ptr)
start_aligned := align_forward_uintptr(start, align_of(uintptr))