diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 4f78cfcce..715fc6fea 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -1247,6 +1247,18 @@ fmt_write_array :: proc(fi: ^Info, array_data: rawptr, count: int, elem_size: in } } + +@(private) +handle_tag :: proc(info: reflect.Type_Info_Struct, i: int, verb: ^rune) -> (do_continue: bool) { + tag := info.tags[i] + if value, ok := reflect.struct_tag_lookup(reflect.Struct_Tag(tag), "fmt"); ok { + if value == "-" { + return true + } + } + return false +} + fmt_value :: proc(fi: ^Info, v: any, verb: rune) { write_padded_number :: proc(fi: ^Info, i: i64, width: int) { n := width-1 @@ -1465,6 +1477,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { defer io.write_byte(fi.writer, '}', &fi.n) for name, i in b.names { + verb := 'v' field_count += 1 if !hash && field_count > 0 { io.write_string(fi.writer, ", ", &fi.n) } @@ -1481,7 +1494,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { io.write_string(fi.writer, "any{}", &fi.n) } else { data := rawptr(uintptr(v.data) + b.offsets[i] + index*t_size) - fmt_arg(fi, any{data, t.id}, 'v') + fmt_arg(fi, any{data, t.id}, verb) } if hash { io.write_string(fi.writer, ",\n", &fi.n) } @@ -1490,6 +1503,10 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { } else { field_count := -1 for name, i in b.names { + verb := 'v' + if handle_tag(b, i, &verb) { + continue + } field_count += 1 if !hash && field_count > 0 { io.write_string(fi.writer, ", ") } @@ -1504,7 +1521,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { io.write_string(fi.writer, "any{}", &fi.n) } else { data := rawptr(uintptr(v.data) + b.offsets[i]) - fmt_arg(fi, any{data, t.id}, 'v') + fmt_arg(fi, any{data, t.id}, verb) } if hash { io.write_string(fi.writer, ",\n", &fi.n) } @@ -1793,6 +1810,7 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { defer io.write_byte(fi.writer, '}', &fi.n) for i in 0.. 0 { io.write_string(fi.writer, ", ", &fi.n) } @@ -1841,11 +1864,12 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) { io.write_string(fi.writer, name, &fi.n) io.write_string(fi.writer, " = ", &fi.n) + if t := info.types[i]; reflect.is_any(t) { io.write_string(fi.writer, "any{}", &fi.n) } else { data := rawptr(uintptr(v.data) + info.offsets[i]) - fmt_arg(fi, any{data, t.id}, 'v') + fmt_arg(fi, any{data, t.id}, verb) } if hash {