work around Haiku stdio bug

The Haiku stdio library has a bug. If we set stdout to unbuffered and it
is attached to a tty it discards wide output. Given how we interact with
the tty it should be safe to replace the problematic `fputwc()` calls
with simple `write()` calls. This does depend on the rest of the fish
code that writes to the tty to ultimately call write() which is true at
this time and should remain true in the future.

Fixes #4100
This commit is contained in:
Kurtis Rader 2017-06-04 21:01:26 -07:00
parent 89cab57f77
commit 6841de5e4b
2 changed files with 5 additions and 6 deletions

View File

@ -4,7 +4,6 @@
#include "config.h" // IWYU pragma: keep
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
@ -240,7 +239,7 @@ static void maybe_issue_path_warning(const wcstring &which_dir, const wcstring &
debug(0, _(L"The error was '%s'."), strerror(saved_errno));
debug(0, _(L"Please set $%ls to a directory where you have write access."), env_var);
}
fputwc(L'\n', stderr);
write(STDERR_FILENO, "\n", 1);
}
static void path_create(wcstring &path, const wcstring &xdg_var, const wcstring &which_dir,

View File

@ -693,14 +693,14 @@ void reader_write_title(const wcstring &cmd, bool reset_cursor_position) {
for (size_t i = 0; i < lst.size(); i++) {
fputws(lst.at(i).c_str(), stdout);
}
fputwc(L'\a', stdout);
write(STDOUT_FILENO, "\a", 1);
}
proc_pop_interactive();
set_color(rgb_color_t::reset(), rgb_color_t::reset());
if (reset_cursor_position && !lst.empty()) {
// Put the cursor back at the beginning of the line (issue #2453).
fputwc(L'\r', stdout);
write(STDOUT_FILENO, "\r", 1);
}
}
@ -1284,7 +1284,7 @@ static void reader_flash() {
}
reader_repaint();
fputwc(L'\a', stdout);
write(STDOUT_FILENO, "\a", 1);
pollint.tv_sec = 0;
pollint.tv_nsec = 100 * 1000000;
@ -3216,7 +3216,7 @@ const wchar_t *reader_readline(int nchars) {
reader_repaint_if_needed();
}
fputwc(L'\n', stdout);
write(STDOUT_FILENO, "\n", 1);
// Ensure we have no pager contents when we exit.
if (!data->pager.empty()) {