[clang-tidy] Use bool literals

Found with modernize-use-bool-literals

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2019-11-25 16:36:13 -08:00
committed by ridiculousfish
parent c3fa8c04bf
commit 4087b2ee15
9 changed files with 21 additions and 21 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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<job_t>
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<job_t>
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<job_t>
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<job_t> 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;
}

View File

@@ -156,7 +156,7 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vector<long
int zero_index = -1;
bool literal_zero_index = true;
while (1) {
while (true) {
while (iswspace(in[pos]) || (in[pos] == INTERNAL_SEPARATOR)) pos++;
if (in[pos] == L']') {
pos++;

View File

@@ -54,7 +54,7 @@ static int ret = 0;
// Read the entire contents of a file into the specified string.
static wcstring read_file(FILE *f) {
wcstring result;
while (1) {
while (true) {
wint_t c = std::fgetwc(f);
if (c == WEOF) {

View File

@@ -480,7 +480,7 @@ static history_item_t decode_item_fish_1_x(const char *begin, size_t length) {
bool timestamp_mode = false;
time_t timestamp = 0;
while (1) {
while (true) {
wchar_t c;
size_t res;
mbstate_t state = {};

View File

@@ -171,7 +171,7 @@ char_event_t input_event_queue_t::readch() {
}
wchar_t res;
mbstate_t state = {};
while (1) {
while (true) {
auto evt = readb();
if (!evt.is_char()) {
return evt;

View File

@@ -457,7 +457,7 @@ static wchar_t get_quote(const wcstring &cmd_str, size_t len) {
wchar_t res = 0;
const wchar_t *const cmd = cmd_str.c_str();
while (1) {
while (true) {
if (!cmd[i]) break;
if (cmd[i] == L'\\') {

View File

@@ -517,7 +517,7 @@ static bool should_exit() { return s_end_current_loop || s_exit_forced; }
static void term_donate(outputter_t &outp) {
outp.set_color(rgb_color_t::normal(), rgb_color_t::normal());
while (1) {
while (true) {
if (tcsetattr(STDIN_FILENO, TCSANOW, &tty_modes_for_external_cmds) == -1) {
if (errno == EIO) redirect_tty_output();
if (errno != EINTR) {
@@ -532,7 +532,7 @@ static void term_donate(outputter_t &outp) {
/// Grab control of terminal.
static void term_steal() {
while (1) {
while (true) {
if (tcsetattr(STDIN_FILENO, TCSANOW, &shell_modes) == -1) {
if (errno == EIO) redirect_tty_output();
if (errno != EINTR) {
@@ -2224,7 +2224,7 @@ static void handle_end_loop(const parser_t &parser) {
if (!data->prev_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<wcstring> reader_data_t::readline(int nchars_or_0) {
}
maybe_t<char_event_t> event_needing_handling{};
while (1) {
while (true) {
event_needing_handling = read_normal_chars(rls);
if (event_needing_handling.has_value()) break;