Use bools, we have the technology

This commit is contained in:
Fabian Homborg 2020-09-24 17:21:49 +02:00
parent 4cb9f3224c
commit a776b08e84
6 changed files with 39 additions and 39 deletions

View file

@ -131,20 +131,20 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_
wchar_t *cmd = argv[0];
int buffer_part = 0;
int cut_at_cursor = 0;
bool cut_at_cursor = false;
int argc = builtin_count_args(argv);
int append_mode = 0;
int function_mode = 0;
int selection_mode = 0;
bool function_mode = false;
bool selection_mode = false;
int tokenize = 0;
bool tokenize = false;
int cursor_mode = 0;
int line_mode = 0;
int search_mode = 0;
int paging_mode = 0;
bool cursor_mode = false;
bool line_mode = false;
bool search_mode = false;
bool paging_mode = false;
const wchar_t *begin = nullptr, *end = nullptr;
const auto &ld = parser.libdata();
@ -212,7 +212,7 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_
break;
}
case 'c': {
cut_at_cursor = 1;
cut_at_cursor = true;
break;
}
case 't': {
@ -228,11 +228,11 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_
break;
}
case 'f': {
function_mode = 1;
function_mode = true;
break;
}
case 'o': {
tokenize = 1;
tokenize = true;
break;
}
case 'I': {
@ -241,23 +241,23 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_
break;
}
case 'C': {
cursor_mode = 1;
cursor_mode = true;
break;
}
case 'L': {
line_mode = 1;
line_mode = true;
break;
}
case 'S': {
search_mode = 1;
search_mode = true;
break;
}
case 's': {
selection_mode = 1;
selection_mode = true;
break;
}
case 'P': {
paging_mode = 1;
paging_mode = true;
break;
}
case 'h': {

View file

@ -126,7 +126,7 @@ maybe_t<int> builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **arg
int argc = builtin_count_args(argv);
bool found = false;
int mode = JOBS_DEFAULT;
int print_last = 0;
bool print_last = false;
static const wchar_t *const short_options = L":cghlpq";
static const struct woption long_options[] = {{L"command", no_argument, nullptr, 'c'},
@ -159,7 +159,7 @@ maybe_t<int> builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **arg
break;
}
case 'l': {
print_last = 1;
print_last = true;
break;
}
case 'h': {

View file

@ -930,8 +930,8 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
const bool no_caret = feature_test(features_t::stderr_nocaret);
const bool no_qmark = feature_test(features_t::qmark_noglob);
int need_escape = 0;
int need_complex_escape = 0;
bool need_escape = false;
bool need_complex_escape = false;
if (!no_quoted && in_len == 0) {
out.assign(L"''");
@ -951,7 +951,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
tmp = val % 16;
out += tmp > 9 ? L'a' + (tmp - 10) : L'0' + tmp;
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
} else {
wchar_t c = *in;
@ -959,36 +959,36 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
case L'\t': {
out += L'\\';
out += L't';
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
break;
}
case L'\n': {
out += L'\\';
out += L'n';
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
break;
}
case L'\b': {
out += L'\\';
out += L'b';
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
break;
}
case L'\r': {
out += L'\\';
out += L'r';
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
break;
}
case L'\x1B': {
out += L'\\';
out += L'e';
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
break;
}
case L'\\':
case L'\'': {
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
out += L'\\';
out += *in;
break;
@ -1030,7 +1030,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
bool char_is_normal = (c == L'~' && no_tilde) || (c == L'^' && no_caret) ||
(c == L'?' && no_qmark);
if (!char_is_normal) {
need_escape = 1;
need_escape = true;
if (escape_all) out += L'\\';
}
out += *in;
@ -1044,7 +1044,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
out += L'c';
out += L'a' + *in - 1;
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
break;
}
@ -1053,7 +1053,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
out += L'x';
out += ((*in > 15) ? L'1' : L'0');
out += tmp > 9 ? L'a' + (tmp - 10) : L'0' + tmp;
need_escape = need_complex_escape = 1;
need_escape = need_complex_escape = true;
} else {
out += *in;
}

View file

@ -205,7 +205,7 @@ bool is_potential_path(const wcstring &potential_path_fragment, const wcstring_l
const bool require_dir = static_cast<bool>(flags & PATH_REQUIRE_DIR);
wcstring clean_potential_path_fragment;
int has_magic = 0;
bool has_magic = false;
wcstring path_with_magic(potential_path_fragment);
if (flags & PATH_EXPAND_TILDE) expand_tilde(path_with_magic, ctx.vars);
@ -221,7 +221,7 @@ bool is_potential_path(const wcstring &potential_path_fragment, const wcstring_l
case ANY_CHAR:
case ANY_STRING:
case ANY_STRING_RECURSIVE: {
has_magic = 1;
has_magic = true;
break;
}
case INTERNAL_SEPARATOR: {

View file

@ -466,11 +466,11 @@ rgb_color_t best_color(const std::vector<rgb_color_t> &candidates, color_support
/// Return the internal color code representing the specified color.
/// TODO: This code should be refactored to enable sharing with builtin_set_color.
rgb_color_t parse_color(const env_var_t &var, bool is_background) {
int is_bold = 0;
int is_underline = 0;
int is_italics = 0;
int is_dim = 0;
int is_reverse = 0;
bool is_bold = false;
bool is_underline = false;
bool is_italics = false;
bool is_dim = false;
bool is_reverse = false;
std::vector<rgb_color_t> candidates;

View file

@ -110,7 +110,7 @@ static int parse_util_locate_brackets_of_type(const wchar_t *in, wchar_t **begin
// open_type is typically ( or [, and close type is the corresponding value.
wchar_t *pos;
wchar_t prev = 0;
int syntax_error = 0;
bool syntax_error = false;
int paran_count = 0;
wchar_t *paran_begin = nullptr, *paran_end = nullptr;
@ -142,7 +142,7 @@ static int parse_util_locate_brackets_of_type(const wchar_t *in, wchar_t **begin
}
if (paran_count < 0) {
syntax_error = 1;
syntax_error = true;
break;
}
}