Skip to content

Commit

Permalink
vlib: use the builtin flush functions, instead of the C. ones (#20108)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Dec 7, 2023
1 parent 9817dfc commit 5b74f3a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions vlib/builtin/builtin.c.v
Expand Up @@ -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()
}
}

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

Expand Down
4 changes: 2 additions & 2 deletions vlib/os/os.c.v
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion vlib/readline/readline_nix.c.v
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion vlib/readline/readline_windows.c.v
Expand Up @@ -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
Expand Down

0 comments on commit 5b74f3a

Please sign in to comment.