1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: fix termux prints (#10595)

This commit is contained in:
Thomas Treffner 2021-06-28 07:27:12 +02:00 committed by GitHub
parent 4bed4afef7
commit 9651a9796b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,10 +141,10 @@ pub fn eprint(s string) {
[manualfree]
pub fn print(s string) {
$if android {
// android print for logcat
C.fprintf(C.stdout, c'%.*s', s.len, s.str)
_write_buf_to_fd(1, s.str, s.len)
} $else $if ios {
C.fprintf(C.stdout, c'%.*s', s.len, s.str) // logcat
}
// no else if for android termux support
$if ios {
// TODO: Implement a buffer as NSLog doesn't have a "print"
C.WrappedNSLog(s.str)
} $else $if freestanding {
@ -161,14 +161,14 @@ pub fn println(s string) {
println('println(NIL)')
return
}
$if android {
C.fprintf(C.stdout, c'%.*s\n', s.len, s.str) // logcat
return
}
// no else if for android termux support
$if ios {
C.WrappedNSLog(s.str)
return
} $else $if android {
// android print for logcat
C.fprintf(C.stdout, c'%.*s\n', s.len, s.str)
_writeln_to_fd(1, s)
return
} $else $if freestanding {
bare_print(s.str, u64(s.len))
bare_print(c'\n', 1)