aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-06-11 01:17:33 +0100
committergingerBill <bill@gingerbill.org>2022-06-11 01:17:33 +0100
commit339d6cfd41c8d9ad63f957582ff190ee292ff03c (patch)
treef06cb66e6924219d525bae896aee6bd739c23f55
parent7bded4f189399d4c81f4153a2c2511405268b181 (diff)
Check for `in_bad`
-rw-r--r--core/fmt/fmt.odin9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin
index ab9beae22..d5f22fd9d 100644
--- a/core/fmt/fmt.odin
+++ b/core/fmt/fmt.odin
@@ -28,6 +28,7 @@ Info :: struct {
reordered: bool,
good_arg_index: bool,
ignore_user_formatters: bool,
+ in_bad: bool,
writer: io.Writer,
arg: any, // Temporary
@@ -591,6 +592,10 @@ int_from_arg :: proc(args: []any, arg_index: int) -> (int, int, bool) {
fmt_bad_verb :: proc(using fi: ^Info, verb: rune) {
+ prev_in_bad := fi.in_bad
+ defer fi.in_bad = prev_in_bad
+ fi.in_bad = true
+
io.write_string(writer, "%!", &fi.n)
io.write_rune(writer, verb, &fi.n)
io.write_byte(writer, '(', &fi.n)
@@ -947,7 +952,7 @@ fmt_string :: proc(fi: ^Info, s: string, verb: rune) {
if ol, ok := fi.optional_len.?; ok {
s = s[:min(len(s), ol)]
}
- if fi.record_level >= 0 && verb == 'v' {
+ if !fi.in_bad && fi.record_level >= 0 && verb == 'v' {
verb = 'q'
}
@@ -1271,7 +1276,7 @@ handle_tag :: proc(data: rawptr, info: reflect.Type_Info_Struct, idx: int, verb:
value = value[w:]
if value == "" || value[0] == ',' {
verb^ = r
- if value[0] == ',' {
+ if len(value) > 0 && value[0] == ',' {
switch r {
case 's', 'q':
if optional_len != nil {