bugfix: printing '{' did not work
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 7 Mar 2023 21:08:43 +0000 (15:08 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 7 Mar 2023 21:08:43 +0000 (15:08 -0600)
core/conv/format.onyx

index 183f80ae15f912d7cf588477c63a407218f5eaf7..e6e3a564ab1aa3b3be40999edbe638866379f438 100644 (file)
@@ -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);