diff --git a/kernel/src/stdio/__stdout_write.c b/kernel/src/stdio/__stdout_write.c index f64f59d9ffa8413415b2f1f34722144287c3275b..8205b7b7bbbfd41ed4e4d57e1fa688010b88f665 100644 --- a/kernel/src/stdio/__stdout_write.c +++ b/kernel/src/stdio/__stdout_write.c @@ -6,12 +6,6 @@ size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) struct winsize wsz; if (!(f->flags & F_SVB) && ioctl(f->fd, TIOCGWINSZ, &wsz)) { f->lbf = EOF; - } else { - f->lbf = '\n'; - f->write = __stdio_write; - f->wpos = f->wbase = f->buf; - f->wend = f->buf + f->buf_size; } - if (len == -1) return 0; return __stdio_write(f, buf, len); } diff --git a/kernel/src/stdio/fwrite.c b/kernel/src/stdio/fwrite.c index 7f8781097aa9e722332517d064edcadf477d0315..c90d39d45e2ad99090aacefc91d3fbd6860acb7d 100644 --- a/kernel/src/stdio/fwrite.c +++ b/kernel/src/stdio/fwrite.c @@ -13,8 +13,6 @@ size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) if (l > f->wend - f->wpos) return f->write(f, s, l); - if (f->lbf == EOF) f->write(f, s, -1); - if (f->lbf >= 0) { /* Match /^(.*\n|)/ */ for (i=l; i && s[i-1] != '\n'; i--); diff --git a/kernel/src/stdio/vfprintf.c b/kernel/src/stdio/vfprintf.c index 6ed977c153080a099a73fa3ed5f9f6b1d45a4f07..bb8c00bad3db5b17549eac8a817f7092413c3cdc 100644 --- a/kernel/src/stdio/vfprintf.c +++ b/kernel/src/stdio/vfprintf.c @@ -10,6 +10,7 @@ #include #include #include +#include /* Some useful macros */ @@ -443,7 +444,14 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, int t, pl; wchar_t wc[2], *ws; char mb[4]; + struct winsize wsz; + if (f && (f->write == __stdout_write) && !ioctl(f->fd, TIOCGWINSZ, &wsz)) { + f->lbf = '\n'; + f->write = __stdio_write; + f->wpos = f->wbase = f->buf; + f->wend = f->buf + f->buf_size; + } for (;;) { /* This error is only specified for snprintf, but since it's * unspecified for other forms, do the same. Stop immediately