diff options
| author | Barinzaya <barinzaya@gmail.com> | 2025-02-14 10:44:42 -0500 |
|---|---|---|
| committer | Barinzaya <barinzaya@gmail.com> | 2025-02-14 10:44:42 -0500 |
| commit | dc2c9b5d51a47ff303a7630d0c7a683c87e4b6c2 (patch) | |
| tree | 67e9c91711579942e7fb11ec7b4b79bdd57cf139 /core/fmt | |
| parent | 04830e944be062f00647de2fc63bf40acdc8cab8 (diff) | |
Support use of `*` in format strings without an index.
This allows `*` to be used in C fashion, without specifying an argument
index to use. Like C, this results in the argument *preceding* the value
for the format specifier itself.
Diffstat (limited to 'core/fmt')
| -rw-r--r-- | core/fmt/fmt.odin | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index 51e70f6b7..2fe6d3350 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -613,6 +613,10 @@ wprintf :: proc(w: io.Writer, fmt: string, args: ..any, flush := true, newline : i += 1 width_index, _, index_ok := _arg_number(fmt, &i, len(args)) + if !index_ok { + width_index, index_ok = error_check_arg(fi, false, unused_args^) + } + if index_ok { unused_args^ -= {width_index} @@ -638,6 +642,10 @@ wprintf :: proc(w: io.Writer, fmt: string, args: ..any, flush := true, newline : i += 1 precision_index, _, index_ok := _arg_number(fmt, &i, len(args)) + if !index_ok { + precision_index, index_ok = error_check_arg(fi, false, unused_args^) + } + if index_ok { unused_args^ -= {precision_index} fi.prec, _, fi.prec_set = int_from_arg(args, precision_index) |