|
@@ -7,18 +7,18 @@ import "core:io"
|
|
import "core:bufio"
|
|
import "core:bufio"
|
|
|
|
|
|
// fprint formats using the default print settings and writes to fd
|
|
// fprint formats using the default print settings and writes to fd
|
|
-fprint :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
|
|
|
|
|
|
+fprint :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true) -> int {
|
|
buf: [1024]byte
|
|
buf: [1024]byte
|
|
b: bufio.Writer
|
|
b: bufio.Writer
|
|
defer bufio.writer_flush(&b)
|
|
defer bufio.writer_flush(&b)
|
|
|
|
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
w := bufio.writer_to_writer(&b)
|
|
w := bufio.writer_to_writer(&b)
|
|
- return wprint(w, ..args, sep=sep)
|
|
|
|
|
|
+ return wprint(w, ..args, sep=sep, flush=flush)
|
|
}
|
|
}
|
|
|
|
|
|
// fprintln formats using the default print settings and writes to fd
|
|
// fprintln formats using the default print settings and writes to fd
|
|
-fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
|
|
|
|
|
|
+fprintln :: proc(fd: os.Handle, args: ..any, sep := " ", flush := true) -> int {
|
|
buf: [1024]byte
|
|
buf: [1024]byte
|
|
b: bufio.Writer
|
|
b: bufio.Writer
|
|
defer bufio.writer_flush(&b)
|
|
defer bufio.writer_flush(&b)
|
|
@@ -26,10 +26,10 @@ fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int {
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
|
|
|
|
w := bufio.writer_to_writer(&b)
|
|
w := bufio.writer_to_writer(&b)
|
|
- return wprintln(w, ..args, sep=sep)
|
|
|
|
|
|
+ return wprintln(w, ..args, sep=sep, flush=flush)
|
|
}
|
|
}
|
|
// fprintf formats according to the specified format string and writes to fd
|
|
// fprintf formats according to the specified format string and writes to fd
|
|
-fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int {
|
|
|
|
|
|
+fprintf :: proc(fd: os.Handle, fmt: string, args: ..any, flush := true) -> int {
|
|
buf: [1024]byte
|
|
buf: [1024]byte
|
|
b: bufio.Writer
|
|
b: bufio.Writer
|
|
defer bufio.writer_flush(&b)
|
|
defer bufio.writer_flush(&b)
|
|
@@ -37,9 +37,9 @@ fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int {
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
|
|
|
|
w := bufio.writer_to_writer(&b)
|
|
w := bufio.writer_to_writer(&b)
|
|
- return wprintf(w, fmt, ..args)
|
|
|
|
|
|
+ return wprintf(w, fmt, ..args, flush=flush)
|
|
}
|
|
}
|
|
-fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io.Error) {
|
|
|
|
|
|
+fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info, flush := true) -> (n: int, err: io.Error) {
|
|
buf: [1024]byte
|
|
buf: [1024]byte
|
|
b: bufio.Writer
|
|
b: bufio.Writer
|
|
defer bufio.writer_flush(&b)
|
|
defer bufio.writer_flush(&b)
|
|
@@ -47,9 +47,9 @@ fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
|
|
|
|
w := bufio.writer_to_writer(&b)
|
|
w := bufio.writer_to_writer(&b)
|
|
- return wprint_type(w, info)
|
|
|
|
|
|
+ return wprint_type(w, info, flush=flush)
|
|
}
|
|
}
|
|
-fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) {
|
|
|
|
|
|
+fprint_typeid :: proc(fd: os.Handle, id: typeid, flush := true) -> (n: int, err: io.Error) {
|
|
buf: [1024]byte
|
|
buf: [1024]byte
|
|
b: bufio.Writer
|
|
b: bufio.Writer
|
|
defer bufio.writer_flush(&b)
|
|
defer bufio.writer_flush(&b)
|
|
@@ -57,19 +57,19 @@ fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) {
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
bufio.writer_init_with_buf(&b, os.stream_from_handle(fd), buf[:])
|
|
|
|
|
|
w := bufio.writer_to_writer(&b)
|
|
w := bufio.writer_to_writer(&b)
|
|
- return wprint_typeid(w, id)
|
|
|
|
|
|
+ return wprint_typeid(w, id, flush=flush)
|
|
}
|
|
}
|
|
|
|
|
|
// print formats using the default print settings and writes to os.stdout
|
|
// print formats using the default print settings and writes to os.stdout
|
|
-print :: proc(args: ..any, sep := " ") -> int { return fprint(os.stdout, ..args, sep=sep) }
|
|
|
|
|
|
+print :: proc(args: ..any, sep := " ", flush := true) -> int { return fprint(os.stdout, ..args, sep=sep, flush=flush) }
|
|
// println formats using the default print settings and writes to os.stdout
|
|
// println formats using the default print settings and writes to os.stdout
|
|
-println :: proc(args: ..any, sep := " ") -> int { return fprintln(os.stdout, ..args, sep=sep) }
|
|
|
|
|
|
+println :: proc(args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stdout, ..args, sep=sep, flush=flush) }
|
|
// printf formats according to the specified format string and writes to os.stdout
|
|
// printf formats according to the specified format string and writes to os.stdout
|
|
-printf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stdout, fmt, ..args) }
|
|
|
|
|
|
+printf :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stdout, fmt, ..args, flush=flush) }
|
|
|
|
|
|
// eprint formats using the default print settings and writes to os.stderr
|
|
// eprint formats using the default print settings and writes to os.stderr
|
|
-eprint :: proc(args: ..any, sep := " ") -> int { return fprint(os.stderr, ..args, sep=sep) }
|
|
|
|
|
|
+eprint :: proc(args: ..any, sep := " ", flush := true) -> int { return fprint(os.stderr, ..args, sep=sep, flush=flush) }
|
|
// eprintln formats using the default print settings and writes to os.stderr
|
|
// eprintln formats using the default print settings and writes to os.stderr
|
|
-eprintln :: proc(args: ..any, sep := " ") -> int { return fprintln(os.stderr, ..args, sep=sep) }
|
|
|
|
|
|
+eprintln :: proc(args: ..any, sep := " ", flush := true) -> int { return fprintln(os.stderr, ..args, sep=sep, flush=flush) }
|
|
// eprintf formats according to the specified format string and writes to os.stderr
|
|
// eprintf formats according to the specified format string and writes to os.stderr
|
|
-eprintf :: proc(fmt: string, args: ..any) -> int { return fprintf(os.stderr, fmt, ..args) }
|
|
|
|
|
|
+eprintf :: proc(fmt: string, args: ..any, flush := true) -> int { return fprintf(os.stderr, fmt, ..args, flush=flush) }
|