From 7bded4f189399d4c81f4153a2c2511405268b181 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 11 Jun 2022 01:09:42 +0100 Subject: [PATCH] Default to `q` for strings within structs --- core/fmt/fmt.odin | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 09dd227dd..ab9beae22 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -943,10 +943,14 @@ fmt_float :: proc(fi: ^Info, v: f64, bit_size: int, verb: rune) { fmt_string :: proc(fi: ^Info, s: string, verb: rune) { - s := s + s, verb := s, verb if ol, ok := fi.optional_len.?; ok { s = s[:min(len(s), ol)] } + if fi.record_level >= 0 && verb == 'v' { + verb = 'q' + } + switch verb { case 's', 'v': if fi.width_set { @@ -1269,7 +1273,7 @@ handle_tag :: proc(data: rawptr, info: reflect.Type_Info_Struct, idx: int, verb: verb^ = r if value[0] == ',' { switch r { - case 's': + case 's', 'q': if optional_len != nil { field_name := value[1:] for f, i in info.names {