From 00d126b0d78f15f66ae7c8db46010701d8272117 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Tue, 7 Mar 2023 15:08:43 -0600 Subject: [PATCH] bugfix: printing '{' did not work --- core/conv/format.onyx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/conv/format.onyx b/core/conv/format.onyx index 183f80ae..e6e3a564 100644 --- a/core/conv/format.onyx +++ b/core/conv/format.onyx @@ -280,10 +280,18 @@ format_va :: (output: &Format_Output, format: str, va: [] any) -> str { continue; } + format_piece := format[i .. i+1]; + completed_format := false; + i += 1; while true { - ch = format[i]; + if i >= format.length { + break; + } + + format_piece.length += 1; + ch = format[i]; switch ch { case #char "*" { i += 1; @@ -364,13 +372,19 @@ format_va :: (output: &Format_Output, format: str, va: [] any) -> str { arg := va[vararg_index]; vararg_index += 1; format_any(output, &formatting, arg); + completed_format = true; - break break; + continue continue; } case #default do break break; } } + + if !completed_format { + output->write(format_piece); + continue; + } } if ch == #char "}" { @@ -379,8 +393,6 @@ format_va :: (output: &Format_Output, format: str, va: [] any) -> str { i += 1; continue; } - - continue; } output->write(ch); -- 2.25.1