mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: simplify println(), use C.write consistently on unix as on windows so that 0 bytes are output also
This commit is contained in:
parent
f3484345c7
commit
824790a2bd
@ -139,26 +139,19 @@ fn C.asl_log(voidptr, voidptr, int, charptr)
|
|||||||
*/
|
*/
|
||||||
// println prints a message with a line end, to stdout. stdout is flushed.
|
// println prints a message with a line end, to stdout. stdout is flushed.
|
||||||
pub fn println(s string) {
|
pub fn println(s string) {
|
||||||
$if windows {
|
if s.str == 0 {
|
||||||
print(s)
|
$if android {
|
||||||
print('\n')
|
C.fprintf(C.stdout, c'println(NIL)\n')
|
||||||
} $else {
|
} $else {
|
||||||
// For debugging .app applications (no way to read stdout) so that it's printed to macOS Console
|
C.write(1, c'println(NIL)\n', 13)
|
||||||
/*
|
|
||||||
$if macos {
|
|
||||||
C.asl_log(0, 0, C.ASL_LEVEL_ERR, s.str)
|
|
||||||
}
|
}
|
||||||
*/
|
return
|
||||||
// TODO: a syscall sys_write on linux works, except for the v repl.
|
}
|
||||||
// Probably it is a stdio buffering issue. Needs more testing...
|
$if android {
|
||||||
// $if linux {
|
C.fprintf(C.stdout, c'%.*s\n', s.len, s.str)
|
||||||
// $if !android {
|
} $else {
|
||||||
// snl := s + '\n'
|
C.write(1, s.str, s.len)
|
||||||
// C.syscall(/* sys_write */ 1, /* stdout_value */ 1, snl.str, s.len+1)
|
C.write(1, c'\n', 1)
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
C.printf('%.*s\n', s.len, s.str)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user