builtin: use fprintf to print to stderr on Android (#9130)
parent
12f8b1b443
commit
07a1a9b84d
|
@ -80,11 +80,19 @@ pub fn eprintln(s string) {
|
||||||
C.fflush(C.stdout)
|
C.fflush(C.stdout)
|
||||||
C.fflush(C.stderr)
|
C.fflush(C.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 s.str == 0 {
|
$if android {
|
||||||
C.write(2, c'eprintln(NIL)\n', 14)
|
if s.str == 0 {
|
||||||
} else {
|
C.fprintf(C.stderr, c'eprintln(NIL)\n')
|
||||||
C.write(2, s.str, s.len)
|
} else {
|
||||||
C.write(2, c'\n', 1)
|
C.fprintf(C.stderr, c'%.*s\n', s.len, s.str)
|
||||||
|
}
|
||||||
|
} $else {
|
||||||
|
if s.str == 0 {
|
||||||
|
C.write(2, c'eprintln(NIL)\n', 14)
|
||||||
|
} else {
|
||||||
|
C.write(2, s.str, s.len)
|
||||||
|
C.write(2, c'\n', 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
C.fflush(C.stderr)
|
C.fflush(C.stderr)
|
||||||
}
|
}
|
||||||
|
@ -93,10 +101,18 @@ pub fn eprintln(s string) {
|
||||||
pub fn eprint(s string) {
|
pub fn eprint(s string) {
|
||||||
C.fflush(C.stdout)
|
C.fflush(C.stdout)
|
||||||
C.fflush(C.stderr)
|
C.fflush(C.stderr)
|
||||||
if s.str == 0 {
|
$if android {
|
||||||
C.write(2, c'eprint(NIL)\n', 12)
|
if s.str == 0 {
|
||||||
} else {
|
C.fprintf(C.stderr, c'eprint(NIL)')
|
||||||
C.write(2, s.str, s.len)
|
} else {
|
||||||
|
C.fprintf(C.stderr, c'%.*s', s.len, s.str)
|
||||||
|
}
|
||||||
|
} $else {
|
||||||
|
if s.str == 0 {
|
||||||
|
C.write(2, c'eprint(NIL)', 11)
|
||||||
|
} else {
|
||||||
|
C.write(2, s.str, s.len)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
C.fflush(C.stderr)
|
C.fflush(C.stderr)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +120,11 @@ pub fn eprint(s string) {
|
||||||
// print prints a message to stdout. Unlike `println` stdout is not automatically flushed.
|
// print prints a message to stdout. Unlike `println` stdout is not automatically flushed.
|
||||||
// A call to `flush()` will flush the output buffer to stdout.
|
// A call to `flush()` will flush the output buffer to stdout.
|
||||||
pub fn print(s string) {
|
pub fn print(s string) {
|
||||||
C.write(1, s.str, s.len)
|
$if android {
|
||||||
|
C.fprintf(C.stdout, c'%.*s', s.len, s.str)
|
||||||
|
} $else {
|
||||||
|
C.write(1, s.str, s.len)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue