lint: unnecessary else statement

This commit is contained in:
Kurtis Rader 2016-11-02 14:42:33 -07:00
parent 5709c81fe0
commit 9b0d45d4fa
5 changed files with 51 additions and 52 deletions

View File

@ -794,11 +794,10 @@ void history_t::add(const wcstring &str, history_identifier_t ident, bool pendin
bool icompare_pred(wchar_t a, wchar_t b) { return std::tolower(a) == std::tolower(b); } bool icompare_pred(wchar_t a, wchar_t b) { return std::tolower(a) == std::tolower(b); }
bool icompare(wcstring const &a, wcstring const &b) { bool icompare(wcstring const &a, wcstring const &b) {
if (a.length() == b.length()) { if (a.length() != b.length()) {
return std::equal(b.begin(), b.end(), a.begin(), icompare_pred);
} else {
return false; return false;
} }
return std::equal(b.begin(), b.end(), a.begin(), icompare_pred);
} }
// Remove matching history entries from our list of new items. This only supports literal, // Remove matching history entries from our list of new items. This only supports literal,

View File

@ -66,33 +66,32 @@ static bool write_color_escape(char *todo, unsigned char idx, bool is_fg) {
if (term_supports_color_natively(idx)) { if (term_supports_color_natively(idx)) {
// Use tparm to emit color escape. // Use tparm to emit color escape.
writembs(tparm(todo, idx)); writembs(tparm(todo, idx));
return true;
} else {
// We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
char buff[16] = "";
if (idx < 16) {
// this allows the non-bright color to happen instead of no color working at all when
// a bright is attempted when only colors 0-7 are supported.
// TODO: enter bold mode in builtin_set_color in the same circumstance- doing that
// combined
// with what we do here, will make the brights actually work for virtual
// consoles/ancient emulators.
if (max_colors == 8 && idx > 8) idx -= 8;
snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10);
} else {
snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
}
int (*writer)(char) = output_get_writer();
if (writer) {
for (size_t i = 0; buff[i]; i++) {
writer(buff[i]);
}
}
return true; return true;
} }
// We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
char buff[16] = "";
if (idx < 16) {
// this allows the non-bright color to happen instead of no color working at all when a
// bright is attempted when only colors 0-7 are supported.
//
// TODO: enter bold mode in builtin_set_color in the same circumstance- doing that combined
// with what we do here, will make the brights actually work for virtual consoles/ancient
// emulators.
if (max_colors == 8 && idx > 8) idx -= 8;
snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10);
} else {
snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
}
int (*writer)(char) = output_get_writer();
if (writer) {
for (size_t i = 0; buff[i]; i++) {
writer(buff[i]);
}
}
return true;
} }
static bool write_foreground_color(unsigned char idx) { static bool write_foreground_color(unsigned char idx) {
@ -121,21 +120,22 @@ bool write_color(rgb_color_t color, bool is_fg) {
// Indexed or non-24 bit color. // Indexed or non-24 bit color.
unsigned char idx = index_for_color(color); unsigned char idx = index_for_color(color);
return (is_fg ? write_foreground_color : write_background_color)(idx); return (is_fg ? write_foreground_color : write_background_color)(idx);
} else { }
// 24 bit! No tparm here, just ANSI escape sequences.
// Foreground: ^[38;2;<r>;<g>;<b>m // 24 bit! No tparm here, just ANSI escape sequences.
// Background: ^[48;2;<r>;<g>;<b>m // Foreground: ^[38;2;<r>;<g>;<b>m
color24_t rgb = color.to_color24(); // Background: ^[48;2;<r>;<g>;<b>m
char buff[128]; color24_t rgb = color.to_color24();
snprintf(buff, sizeof buff, "\x1b[%d;2;%u;%u;%um", is_fg ? 38 : 48, rgb.rgb[0], rgb.rgb[1], char buff[128];
rgb.rgb[2]); snprintf(buff, sizeof buff, "\x1b[%d;2;%u;%u;%um", is_fg ? 38 : 48, rgb.rgb[0], rgb.rgb[1],
int (*writer)(char) = output_get_writer(); rgb.rgb[2]);
if (writer) { int (*writer)(char) = output_get_writer();
for (size_t i = 0; buff[i]; i++) { if (writer) {
writer(buff[i]); for (size_t i = 0; buff[i]; i++) {
} writer(buff[i]);
} }
} }
return true; return true;
} }

View File

@ -564,11 +564,11 @@ bool parser_t::job_remove(job_t *j) {
if (iter != my_job_list.end()) { if (iter != my_job_list.end()) {
my_job_list.erase(iter); my_job_list.erase(iter);
return true; return true;
} else {
debug(1, _(L"Job inconsistency"));
sanity_lose();
return false;
} }
debug(1, _(L"Job inconsistency"));
sanity_lose();
return false;
} }
void parser_t::job_promote(job_t *job) { void parser_t::job_promote(job_t *job) {

View File

@ -2212,10 +2212,10 @@ static void reader_super_highlight_me_plenty(int match_highlight_pos_adjust, boo
} }
bool shell_is_exiting() { bool shell_is_exiting() {
if (shell_is_interactive()) if (shell_is_interactive()) {
return job_list_is_empty() && data != NULL && data->end_loop; return job_list_is_empty() && data != NULL && data->end_loop;
else }
return end_loop; return end_loop;
} }
/// This function is called when the main loop notices that end_loop has been set while in /// This function is called when the main loop notices that end_loop has been set while in

View File

@ -185,11 +185,11 @@ bool set_cloexec(int fd) {
int flags = fcntl(fd, F_GETFD, 0); int flags = fcntl(fd, F_GETFD, 0);
if (flags < 0) { if (flags < 0) {
return false; return false;
} else if (flags & FD_CLOEXEC) {
return true;
} else {
return fcntl(fd, F_SETFD, flags | FD_CLOEXEC) >= 0;
} }
if (flags & FD_CLOEXEC) {
return true;
}
return fcntl(fd, F_SETFD, flags | FD_CLOEXEC) >= 0;
} }
static int wopen_internal(const wcstring &pathname, int flags, mode_t mode, bool cloexec) { static int wopen_internal(const wcstring &pathname, int flags, mode_t mode, bool cloexec) {