Support string literals for fixed arrays of runes; Add %q support for arrays/slices of bytes

This commit is contained in:
gingerBill
2020-11-20 16:24:23 +00:00
parent 6416a6f39c
commit 63e4a2341f
6 changed files with 96 additions and 29 deletions
+2 -2
View File
@@ -1599,7 +1599,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
}
case runtime.Type_Info_Array:
if verb == 's' && reflect.is_byte(info.elem) {
if (verb == 's' || verb == 'q') && reflect.is_byte(info.elem) {
s := strings.string_from_ptr((^byte)(v.data), info.count);
fmt_string(fi, s, verb);
} else {
@@ -1664,7 +1664,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
case runtime.Type_Info_Slice:
slice := cast(^mem.Raw_Slice)v.data;
if verb == 's' && reflect.is_byte(info.elem) {
if (verb == 's' || verb == 'q') && reflect.is_byte(info.elem) {
s := strings.string_from_ptr((^byte)(slice.data), slice.len);
fmt_string(fi, s, verb);
} else if verb == 'p' {