mirror of
https://github.com/vlang/v.git
synced 2025-09-17 03:17:25 -04:00
vlib: use the builtin flush functions, instead of the C. ones (#20108)
This commit is contained in:
parent
9817dfc5ba
commit
5b74f3af3e
@ -171,14 +171,14 @@ pub fn eprintln(s string) {
|
|||||||
} $else $if ios {
|
} $else $if ios {
|
||||||
C.WrappedNSLog(s.str)
|
C.WrappedNSLog(s.str)
|
||||||
} $else {
|
} $else {
|
||||||
C.fflush(C.stdout)
|
flush_stdout()
|
||||||
C.fflush(C.stderr)
|
flush_stderr()
|
||||||
// eprintln is used in panics, so it should not fail at all
|
// eprintln is used in panics, so it should not fail at all
|
||||||
$if android && !termux {
|
$if android && !termux {
|
||||||
C.android_print(C.stderr, c'%.*s\n', s.len, s.str)
|
C.android_print(C.stderr, c'%.*s\n', s.len, s.str)
|
||||||
}
|
}
|
||||||
_writeln_to_fd(2, s)
|
_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"
|
// TODO: Implement a buffer as NSLog doesn't have a "print"
|
||||||
C.WrappedNSLog(s.str)
|
C.WrappedNSLog(s.str)
|
||||||
} $else {
|
} $else {
|
||||||
C.fflush(C.stdout)
|
flush_stdout()
|
||||||
C.fflush(C.stderr)
|
flush_stderr()
|
||||||
$if android && !termux {
|
$if android && !termux {
|
||||||
C.android_print(C.stderr, c'%.*s', s.len, s.str)
|
C.android_print(C.stderr, c'%.*s', s.len, s.str)
|
||||||
}
|
}
|
||||||
_write_buf_to_fd(2, s.str, s.len)
|
_write_buf_to_fd(2, s.str, s.len)
|
||||||
C.fflush(C.stderr)
|
flush_stderr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,9 +399,9 @@ pub fn system(cmd string) int {
|
|||||||
$if windows {
|
$if windows {
|
||||||
// overcome bug in system & _wsystem (cmd) when first char is quote `"`
|
// overcome bug in system & _wsystem (cmd) when first char is quote `"`
|
||||||
wcmd := if cmd.len > 1 && cmd[0] == `"` && cmd[1] != `"` { '"${cmd}"' } else { cmd }
|
wcmd := if cmd.len > 1 && cmd[0] == `"` && cmd[1] != `"` { '"${cmd}"' } else { cmd }
|
||||||
|
flush_stdout()
|
||||||
|
flush_stderr()
|
||||||
unsafe {
|
unsafe {
|
||||||
C.fflush(C.stdout)
|
|
||||||
C.fflush(C.stderr)
|
|
||||||
ret = C._wsystem(wcmd.to_wide())
|
ret = C._wsystem(wcmd.to_wide())
|
||||||
}
|
}
|
||||||
} $else {
|
} $else {
|
||||||
|
@ -121,7 +121,7 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ![]rune {
|
|||||||
}
|
}
|
||||||
print(r.prompt)
|
print(r.prompt)
|
||||||
for {
|
for {
|
||||||
unsafe { C.fflush(C.stdout) }
|
flush_stdout()
|
||||||
c := r.read_char() or { return err }
|
c := r.read_char() or { return err }
|
||||||
a := r.analyse(c)
|
a := r.analyse(c)
|
||||||
if r.execute(a, c) {
|
if r.execute(a, c) {
|
||||||
|
@ -36,7 +36,7 @@ pub fn (mut r Readline) read_line_utf8(prompt string) ![]rune {
|
|||||||
r.previous_lines[0] = []rune{}
|
r.previous_lines[0] = []rune{}
|
||||||
}
|
}
|
||||||
print(r.prompt)
|
print(r.prompt)
|
||||||
unsafe { C.fflush(C.stdout) }
|
flush_stdout()
|
||||||
r.current = os.get_raw_line().runes()
|
r.current = os.get_raw_line().runes()
|
||||||
r.previous_lines[0] = []rune{}
|
r.previous_lines[0] = []rune{}
|
||||||
r.search_index = 0
|
r.search_index = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user