vlib: use the builtin flush functions, instead of the C. ones (#20108)

This commit is contained in:
Turiiya 2023-12-07 17:24:27 +01:00 committed by GitHub
parent 9817dfc5ba
commit 5b74f3af3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View File

@ -171,14 +171,14 @@ pub fn eprintln(s string) {
} $else $if ios {
C.WrappedNSLog(s.str)
} $else {
C.fflush(C.stdout)
C.fflush(C.stderr)
flush_stdout()
flush_stderr()
// eprintln is used in panics, so it should not fail at all
$if android && !termux {
C.android_print(C.stderr, c'%.*s\n', s.len, s.str)
}
_writeln_to_fd(2, s)
C.fflush(C.stderr)
flush_stderr()
}
}
@ -195,13 +195,13 @@ pub fn eprint(s string) {
// TODO: Implement a buffer as NSLog doesn't have a "print"
C.WrappedNSLog(s.str)
} $else {
C.fflush(C.stdout)
C.fflush(C.stderr)
flush_stdout()
flush_stderr()
$if android && !termux {
C.android_print(C.stderr, c'%.*s', s.len, s.str)
}
_write_buf_to_fd(2, s.str, s.len)
C.fflush(C.stderr)
flush_stderr()
}
}

View File

@ -399,9 +399,9 @@ pub fn system(cmd string) int {
$if windows {
// overcome bug in system & _wsystem (cmd) when first char is quote `"`
wcmd := if cmd.len > 1 && cmd[0] == `"` && cmd[1] != `"` { '"${cmd}"' } else { cmd }
flush_stdout()
flush_stderr()
unsafe {
C.fflush(C.stdout)
C.fflush(C.stderr)
ret = C._wsystem(wcmd.to_wide())
}
} $else {

View File

@ -121,7 +121,7 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ![]rune {
}
print(r.prompt)
for {
unsafe { C.fflush(C.stdout) }
flush_stdout()
c := r.read_char() or { return err }
a := r.analyse(c)
if r.execute(a, c) {

View File

@ -36,7 +36,7 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ![]rune {
r.previous_lines[0] = []rune{}
}
print(r.prompt)
unsafe { C.fflush(C.stdout) }
flush_stdout()
r.current = os.get_raw_line().runes()
r.previous_lines[0] = []rune{}
r.search_index = 0