Skip to content

Commit

Permalink
Support use of * in format strings without an index.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Barinzaya committed Feb 14, 2025
1 parent 04830e9 commit dc2c9b5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/fmt/fmt.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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)
Expand Down

0 comments on commit dc2c9b5

Please sign in to comment.