mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Add optional flush := true to many of the core:fmt procedures
This commit is contained in:
+23
-14
@@ -327,7 +327,7 @@ ctprintf :: proc(format: string, args: ..any) -> cstring {
|
||||
// Returns: A formatted string
|
||||
//
|
||||
sbprint :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
|
||||
wprint(strings.to_writer(buf), ..args, sep=sep)
|
||||
wprint(strings.to_writer(buf), ..args, sep=sep, flush=true)
|
||||
return strings.to_string(buf^)
|
||||
}
|
||||
// Formats and writes to a strings.Builder buffer using the default print settings
|
||||
@@ -340,7 +340,7 @@ sbprint :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
|
||||
// Returns: The resulting formatted string
|
||||
//
|
||||
sbprintln :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
|
||||
wprintln(strings.to_writer(buf), ..args, sep=sep)
|
||||
wprintln(strings.to_writer(buf), ..args, sep=sep, flush=true)
|
||||
return strings.to_string(buf^)
|
||||
}
|
||||
// Formats and writes to a strings.Builder buffer according to the specified format string
|
||||
@@ -353,7 +353,7 @@ sbprintln :: proc(buf: ^strings.Builder, args: ..any, sep := " ") -> string {
|
||||
// Returns: The resulting formatted string
|
||||
//
|
||||
sbprintf :: proc(buf: ^strings.Builder, fmt: string, args: ..any) -> string {
|
||||
wprintf(strings.to_writer(buf), fmt, ..args)
|
||||
wprintf(strings.to_writer(buf), fmt, ..args, flush=true)
|
||||
return strings.to_string(buf^)
|
||||
}
|
||||
// Formats and writes to an io.Writer using the default print settings
|
||||
@@ -365,7 +365,7 @@ sbprintf :: proc(buf: ^strings.Builder, fmt: string, args: ..any) -> string {
|
||||
//
|
||||
// Returns: The number of bytes written
|
||||
//
|
||||
wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
|
||||
wprint :: proc(w: io.Writer, args: ..any, sep := " ", flush := true) -> int {
|
||||
fi: Info
|
||||
fi.writer = w
|
||||
|
||||
@@ -391,7 +391,9 @@ wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
|
||||
|
||||
fmt_value(&fi, args[i], 'v')
|
||||
}
|
||||
io.flush(auto_cast w)
|
||||
if flush {
|
||||
io.flush(w)
|
||||
}
|
||||
|
||||
return fi.n
|
||||
}
|
||||
@@ -404,7 +406,7 @@ wprint :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
|
||||
//
|
||||
// Returns: The number of bytes written
|
||||
//
|
||||
wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
|
||||
wprintln :: proc(w: io.Writer, args: ..any, sep := " ", flush := true) -> int {
|
||||
fi: Info
|
||||
fi.writer = w
|
||||
|
||||
@@ -416,7 +418,9 @@ wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
|
||||
fmt_value(&fi, args[i], 'v')
|
||||
}
|
||||
io.write_byte(fi.writer, '\n', &fi.n)
|
||||
io.flush(auto_cast w)
|
||||
if flush {
|
||||
io.flush(w)
|
||||
}
|
||||
return fi.n
|
||||
}
|
||||
// Formats and writes to an io.Writer according to the specified format string
|
||||
@@ -428,7 +432,7 @@ wprintln :: proc(w: io.Writer, args: ..any, sep := " ") -> int {
|
||||
//
|
||||
// Returns: The number of bytes written
|
||||
//
|
||||
wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int {
|
||||
wprintf :: proc(w: io.Writer, fmt: string, args: ..any, flush := true) -> int {
|
||||
fi: Info
|
||||
arg_index: int = 0
|
||||
end := len(fmt)
|
||||
@@ -698,8 +702,9 @@ wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int {
|
||||
}
|
||||
io.write_string(fi.writer, ")", &fi.n)
|
||||
}
|
||||
|
||||
io.flush(auto_cast w)
|
||||
if flush {
|
||||
io.flush(w)
|
||||
}
|
||||
|
||||
return fi.n
|
||||
}
|
||||
@@ -711,9 +716,11 @@ wprintf :: proc(w: io.Writer, fmt: string, args: ..any) -> int {
|
||||
//
|
||||
// Returns: The number of bytes written and an io.Error if encountered
|
||||
//
|
||||
wprint_type :: proc(w: io.Writer, info: ^runtime.Type_Info) -> (int, io.Error) {
|
||||
wprint_type :: proc(w: io.Writer, info: ^runtime.Type_Info, flush := true) -> (int, io.Error) {
|
||||
n, err := reflect.write_type(w, info)
|
||||
io.flush(auto_cast w)
|
||||
if flush {
|
||||
io.flush(w)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
// Writes a typeid value to an io.Writer
|
||||
@@ -724,9 +731,11 @@ wprint_type :: proc(w: io.Writer, info: ^runtime.Type_Info) -> (int, io.Error) {
|
||||
//
|
||||
// Returns: The number of bytes written and an io.Error if encountered
|
||||
//
|
||||
wprint_typeid :: proc(w: io.Writer, id: typeid) -> (int, io.Error) {
|
||||
wprint_typeid :: proc(w: io.Writer, id: typeid, flush := true) -> (int, io.Error) {
|
||||
n, err := reflect.write_type(w, type_info_of(id))
|
||||
io.flush(auto_cast w)
|
||||
if flush {
|
||||
io.flush(w)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
// Parses an integer from a given string starting at a specified offset
|
||||
|
||||
Reference in New Issue
Block a user