From dc27de81909afb1d8933064a3d5c0b0c888c8c90 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 2 Mar 2019 15:10:37 -0800 Subject: [PATCH] Rename reader_interrupted to reader_test_and_clear_interrupted --- src/complete.cpp | 3 ++- src/fish_key_reader.cpp | 2 +- src/history.cpp | 2 +- src/proc.cpp | 4 ++-- src/reader.cpp | 6 +++--- src/reader.h | 2 +- src/wildcard.cpp | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/complete.cpp b/src/complete.cpp index 3198299ae..b0ae97cc1 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -1253,7 +1253,8 @@ bool completer_t::try_complete_user(const wcstring &str) { setpwent(); // cppcheck-suppress getpwentCalled while (struct passwd *pw = getpwent()) { - bool interrupted = is_main_thread() ? reader_interrupted() : reader_thread_job_is_stale(); + bool interrupted = + is_main_thread() ? reader_test_and_clear_interrupted() : reader_thread_job_is_stale(); if (interrupted) { break; } diff --git a/src/fish_key_reader.cpp b/src/fish_key_reader.cpp index aec1626be..daf90e8e2 100644 --- a/src/fish_key_reader.cpp +++ b/src/fish_key_reader.cpp @@ -205,7 +205,7 @@ static void process_input(bool continuous_mode) { fwprintf(stderr, L"Press a key\n\n"); while (keep_running) { wchar_t wc; - if (reader_interrupted()) { + if (reader_test_and_clear_interrupted()) { wc = shell_modes.c_cc[VINTR]; } else { wc = input_common_readch(true); diff --git a/src/history.cpp b/src/history.cpp index 920b4c46d..36b3d081f 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1101,7 +1101,7 @@ bool history_search_t::go_backwards() { size_t index = current_index_; while (++index < max_index) { - if (main_thread ? reader_interrupted() : reader_thread_job_is_stale()) { + if (main_thread ? reader_test_and_clear_interrupted() : reader_thread_job_is_stale()) { return false; } diff --git a/src/proc.cpp b/src/proc.cpp index 72f6fd3bd..41fbf8d20 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -595,8 +595,8 @@ static bool process_clean_after_marking(bool allow_interactive) { fwprintf(stdout, L"\n"); } found = false; - p->status = proc_status_t::from_exit_code( - 0); // clear status so it is not reported more than once + // clear status so it is not reported more than once + p->status = proc_status_t::from_exit_code(0); } // If all processes have completed, tell the user the job has completed and delete it from diff --git a/src/reader.cpp b/src/reader.cpp index 9821482d7..de6dc754f 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -797,16 +797,16 @@ bool reader_data_t::expand_abbreviation_as_necessary(size_t cursor_backtrack) { void reader_reset_interrupted() { interrupted = 0; } -int reader_interrupted() { +bool reader_test_and_clear_interrupted() { int res = interrupted; if (res) { interrupted = 0; } - return res; + return res != 0; } int reader_reading_interrupted() { - int res = reader_interrupted(); + int res = reader_test_and_clear_interrupted(); reader_data_t *data = current_data_or_null(); if (res && data && data->exit_on_interrupt) { reader_set_end_loop(true); diff --git a/src/reader.h b/src/reader.h index 871547cfd..13055c22d 100644 --- a/src/reader.h +++ b/src/reader.h @@ -123,7 +123,7 @@ bool reader_get_selection(size_t *start, size_t *len); /// Return the value of the interrupted flag, which is set by the sigint handler, and clear it if it /// was set. -int reader_interrupted(); +bool reader_test_and_clear_interrupted(); /// Clear the interrupted flag unconditionally without handling anything. The flag could have been /// set e.g. when an interrupt arrived just as we were ending an earlier \c reader_readline diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 1a01c44d8..6172c3042 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -499,8 +499,8 @@ class wildcard_expander_t { /// Indicate whether we should cancel wildcard expansion. This latches 'interrupt'. bool interrupted() { if (!did_interrupt) { - did_interrupt = - (is_main_thread() ? reader_interrupted() : reader_thread_job_is_stale()); + did_interrupt = (is_main_thread() ? reader_test_and_clear_interrupted() + : reader_thread_job_is_stale()); } return did_interrupt; }