From 4087b2ee153afa8264cab8ecf874bc2d3b00ba91 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 25 Nov 2019 16:36:13 -0800 Subject: [PATCH] [clang-tidy] Use bool literals Found with modernize-use-bool-literals Signed-off-by: Rosen Penev --- src/common.cpp | 6 +++--- src/complete.cpp | 4 ++-- src/exec.cpp | 10 +++++----- src/expand.cpp | 2 +- src/fish_indent.cpp | 2 +- src/history_file.cpp | 2 +- src/input_common.cpp | 2 +- src/parse_util.cpp | 2 +- src/reader.cpp | 12 ++++++------ 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 634afe81f..cfa4cb0d8 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -252,7 +252,7 @@ int fgetws2(wcstring *s, FILE *f) { int i = 0; wint_t c; - while (1) { + while (true) { errno = 0; c = std::fgetwc(f); @@ -556,7 +556,7 @@ void append_format(wcstring &str, const wchar_t *format, ...) { wchar_t *quote_end(const wchar_t *pos) { wchar_t c = *pos; - while (1) { + while (true) { pos++; if (!*pos) return nullptr; @@ -816,7 +816,7 @@ wcstring reformat_for_screen(const wcstring &msg) { if (screen_width) { const wchar_t *start = msg.c_str(); const wchar_t *pos = start; - while (1) { + while (true) { int overflow = 0; int tok_width = 0; diff --git a/src/complete.cpp b/src/complete.cpp index f6429faa8..a31496262 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -586,7 +586,7 @@ void completer_t::complete_cmd_desc(const wcstring &str) { // least two characters if we don't know the location of the whatis-database. if (cmd.length() < 2) return; - if (wildcard_has(cmd, 0)) { + if (wildcard_has(cmd, false)) { return; } @@ -939,7 +939,7 @@ bool completer_t::complete_param(const wcstring &cmd_orig, const wcstring &popt, for (const option_list_t &options : all_options) { size_t short_opt_pos = short_option_pos(str, options); bool last_option_requires_param = false; - use_common = 1; + use_common = true; if (use_switches) { if (str[0] == L'-') { // Check if we are entering a combined option and argument (like --color=auto or diff --git a/src/exec.cpp b/src/exec.cpp index 3e78a01be..a627cc362 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -315,7 +315,7 @@ void internal_exec(env_stack_t &vars, job_t *j, const io_chain_t &all_ios) { launch_process_nofork(vars, j->processes.front().get()); } else { j->mut_flags().constructed = true; - j->processes.front()->completed = 1; + j->processes.front()->completed = true; return; } } @@ -645,7 +645,7 @@ static bool handle_builtin_output(parser_t &parser, const std::shared_ptr if (!must_use_process && outbuff.empty() && errbuff.empty()) { // We do not need to construct a background process. // TODO: factor this job-status-setting stuff into a single place. - p->completed = 1; + p->completed = true; if (p->is_last_in_job) { FLOGF(exec_job_status, L"Set status of job %d (%ls) to %d using short circuit", j->job_id, j->preview().c_str(), p->status); @@ -863,7 +863,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr if (!block_output_bufferfill) { // No buffer, so we exit directly. This means we have to manually set the exit // status. - p->completed = 1; + p->completed = true; if (p->is_last_in_job) { parser.set_last_statuses(j->get_statuses()); } @@ -883,7 +883,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr if (p->is_last_in_job) { parser.set_last_statuses(j->get_statuses()); } - p->completed = 1; + p->completed = true; } return true; } @@ -1128,7 +1128,7 @@ bool exec_job(parser_t &parser, shared_ptr j) { internal_exec(parser.vars(), j.get(), all_ios); // internal_exec only returns if it failed to set up redirections. // In case of an successful exec, this code is not reached. - bool status = j->flags().negate ? 0 : 1; + bool status = j->flags().negate ? false : true; parser.set_last_statuses(statuses_t::just(status)); return false; } diff --git a/src/expand.cpp b/src/expand.cpp index 37583ddb6..09ae53913 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -156,7 +156,7 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vectorprev_end_loop && bg_jobs) { reader_bg_job_warning(parser); reader_set_end_loop(false); - data->prev_end_loop = 1; + data->prev_end_loop = true; return; } } @@ -2261,7 +2261,7 @@ static int read_i(parser_t &parser) { reader_import_history_if_necessary(); reader_data_t *data = current_data(); - data->prev_end_loop = 0; + data->prev_end_loop = false; while (!shell_is_exiting()) { run_count++; @@ -2302,7 +2302,7 @@ static int read_i(parser_t &parser) { if (shell_is_exiting()) { handle_end_loop(parser); } else { - data->prev_end_loop = 0; + data->prev_end_loop = false; } } } @@ -3254,7 +3254,7 @@ maybe_t reader_data_t::readline(int nchars_or_0) { } maybe_t event_needing_handling{}; - while (1) { + while (true) { event_needing_handling = read_normal_chars(rls); if (event_needing_handling.has_value()) break;