From 711c18e7f4d951255aa8b0851e5a55d5a5fb0ddb Mon Sep 17 00:00:00 2001 From: Nikita Mikhaylov Date: Fri, 23 Aug 2024 13:12:44 +0200 Subject: [PATCH] Replaced fdatasync with fsync (#27) --- src/replxx_impl.cxx | 12 ++++++------ src/terminal.cxx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/replxx_impl.cxx b/src/replxx_impl.cxx index b08a133..a056b72 100644 --- a/src/replxx_impl.cxx +++ b/src/replxx_impl.cxx @@ -643,12 +643,12 @@ char const* Replxx::ReplxxImpl::input( std::string const& prompt ) { } if ( ! _errorMessage.empty() ) { dprintf( _out_fd, "%s", _errorMessage.c_str() ); - fdatasync( _out_fd ); + fsync( _out_fd ); _errorMessage.clear(); } if ( isUnsupportedTerm() ) { dprintf( _out_fd, "%s", prompt.c_str() ); - fdatasync( _out_fd ); + fsync( _out_fd ); return ( read_from_stdin() ); } std::unique_lock l( _mutex ); @@ -1236,7 +1236,7 @@ char32_t Replxx::ReplxxImpl::do_complete_line( bool showCompletions_ ) { refresh_line(); _pos = savePos; dprintf(_out_fd, "\nDisplay all %u possibilities? (y or n)", static_cast( _completions.size() ) ); - fdatasync(_out_fd); + fsync(_out_fd); onNewLine = true; while (c != 'y' && c != 'Y' && c != 'n' && c != 'N' && c != Replxx::KEY::control('C')) { do { @@ -1285,7 +1285,7 @@ char32_t Replxx::ReplxxImpl::do_complete_line( bool showCompletions_ ) { for (size_t row = 0; row < rowCount; ++row) { if (row == pauseRow) { dprintf(_out_fd, "\n--More--"); - fdatasync(_out_fd); + fsync(_out_fd); c = 0; bool doBeep = false; while (c != ' ' && c != Replxx::KEY::ENTER && c != 'y' && c != 'Y' && @@ -1335,7 +1335,7 @@ char32_t Replxx::ReplxxImpl::do_complete_line( bool showCompletions_ ) { if ( index < _completions.size() ) { Completion const& c( _completions[index] ); int itemLength = static_cast(c.text().length()); - fdatasync(_out_fd); + fsync(_out_fd); if ( longestCommonPrefix > 0 ) { static UnicodeString const col( ansi_color( Replxx::Color::BRIGHTMAGENTA ) ); @@ -1365,7 +1365,7 @@ char32_t Replxx::ReplxxImpl::do_complete_line( bool showCompletions_ ) { } } } - fdatasync(_out_fd); + fsync(_out_fd); } // display the prompt on a new line, then redisplay the input buffer diff --git a/src/terminal.cxx b/src/terminal.cxx index d211875..2a94c89 100644 --- a/src/terminal.cxx +++ b/src/terminal.cxx @@ -342,7 +342,7 @@ char32_t read_unicode_character(int in_fd_) { void beep(int fd_) { dprintf(fd_, "\x7"); // ctrl-G == bell/beep - fdatasync(fd_); + fsync(fd_); } // replxx_read_char -- read a keystroke or keychord from the keyboard, and translate it