time for another make style-all

This commit is contained in:
Kurtis Rader 2016-12-03 20:12:53 -08:00
parent 45d3a705be
commit 9443a415bf
17 changed files with 89 additions and 120 deletions

View file

@ -826,8 +826,10 @@ static int builtin_command(parser_t &parser, io_streams_t &streams, wchar_t **ar
w.woptind = 0;
static const struct woption long_options[] = {
{L"quiet", no_argument, 0, 'q'}, {L"search", no_argument, 0, 's'}, {L"help", no_argument, 0, 'h'}, {0, 0, 0, 0}};
static const struct woption long_options[] = {{L"quiet", no_argument, NULL, 'q'},
{L"search", no_argument, NULL, 's'},
{L"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}};
while (1) {
int opt_index = 0;

View file

@ -310,8 +310,8 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
if (do_complete) {
const wchar_t *token;
parse_util_token_extent(do_complete_param.c_str(), do_complete_param.size(), &token, 0,
0, 0);
parse_util_token_extent(do_complete_param.c_str(), do_complete_param.size(), &token, 0, 0,
0);
// Create a scoped transient command line, so that bulitin_commandline will see our
// argument, not the reader buffer.
@ -322,7 +322,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
std::vector<completion_t> comp;
complete(do_complete_param, &comp, COMPLETION_REQUEST_DEFAULT,
env_vars_snapshot_t::current());
env_vars_snapshot_t::current());
for (size_t i = 0; i < comp.size(); i++) {
const completion_t &next = comp.at(i);
@ -339,8 +339,7 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
// just look for the space and clear it.
if (!(next.flags & COMPLETE_NO_SPACE) &&
string_suffixes_string(L" ", faux_cmdline_with_completion)) {
faux_cmdline_with_completion.resize(faux_cmdline_with_completion.size() -
1);
faux_cmdline_with_completion.resize(faux_cmdline_with_completion.size() - 1);
}
// The input data is meant to be something like you would have on the command

View file

@ -167,7 +167,8 @@ class test_parser {
expression *parse_binary_primary(unsigned int start, unsigned int end);
expression *parse_just_a_string(unsigned int start, unsigned int end);
static expression *parse_args(const wcstring_list_t &args, wcstring &err, wchar_t *program_name);
static expression *parse_args(const wcstring_list_t &args, wcstring &err,
wchar_t *program_name);
};
struct range_t {
@ -538,7 +539,8 @@ expression *test_parser::parse_expression(unsigned int start, unsigned int end)
}
}
expression *test_parser::parse_args(const wcstring_list_t &args, wcstring &err, wchar_t *program_name) {
expression *test_parser::parse_args(const wcstring_list_t &args, wcstring &err,
wchar_t *program_name) {
// Empty list and one-arg list should be handled by caller.
assert(args.size() > 1);
@ -820,7 +822,7 @@ int builtin_test(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
wcstring_list_t eval_errors;
bool result = expr->evaluate(eval_errors);
if (!eval_errors.empty() && ! should_suppress_stderr_for_tests()) {
if (!eval_errors.empty() && !should_suppress_stderr_for_tests()) {
printf("test returned eval errors:\n");
for (size_t i = 0; i < eval_errors.size(); i++) {
printf("\t%ls\n", eval_errors.at(i).c_str());

View file

@ -675,7 +675,8 @@ ssize_t read_loop(int fd, void *buff, size_t count);
///
/// will print the string 'fish: Pi = 3.141', given that debug_level is 1 or higher, and that
/// program_name is 'fish'.
void __attribute__((noinline)) debug(int level, const char *msg, ...) __attribute__ ((format (printf, 2, 3)));
void __attribute__((noinline)) debug(int level, const char *msg, ...)
__attribute__((format(printf, 2, 3)));
void __attribute__((noinline)) debug(int level, const wchar_t *msg, ...);
/// Replace special characters with backslash escape sequences. Newline is replaced with \n, etc.

View file

@ -676,7 +676,7 @@ void completer_t::complete_cmd(const wcstring &str_cmd, bool use_function, bool
NULL);
if (result != EXPAND_ERROR && this->wants_descriptions()) {
this->complete_cmd_desc(str_cmd);
}
}
}
if (use_implicit_cd) {
@ -961,7 +961,7 @@ bool completer_t::complete_param(const wcstring &scmd_orig, const wcstring &spop
}
for (option_list_t::const_iterator oiter = options.begin(); oiter != options.end();
++oiter) {
++oiter) {
const complete_entry_opt_t *o = &*oiter;
// If this entry is for the base command, check if any of the arguments match.
if (!this->condition_test(o->condition)) continue;
@ -1240,9 +1240,8 @@ bool completer_t::try_complete_user(const wcstring &str) {
wcstring name = format_string(L"~%ls", pw_name);
wcstring desc = format_string(COMPLETE_USER_DESC, pw_name);
append_completion(&this->completions, name, desc, COMPLETE_REPLACES_TOKEN |
COMPLETE_DONT_ESCAPE |
COMPLETE_NO_SPACE);
append_completion(&this->completions, name, desc,
COMPLETE_REPLACES_TOKEN | COMPLETE_DONT_ESCAPE | COMPLETE_NO_SPACE);
result = true;
}
}

View file

@ -595,8 +595,8 @@ bool env_universal_t::open_and_acquire_lock(const wcstring &path, int *out_fd) {
// Try taking the lock, if necessary. If we failed, we may be on lockless NFS, etc.; in that
// case we pretend we succeeded. See the comment in save_to_path for the rationale.
if (needs_lock) {
// This is safe in terms of the fallback function implemented in terms of fcntl: only ever
// run on the main thread, and protected by the universal variable lock
// This is safe in terms of the fallback function implemented in terms of fcntl: only
// ever run on the main thread, and protected by the universal variable lock.
// cppcheck-suppress flockSemanticsWarning
while (flock(fd, LOCK_EX) < 0) {
/* error */

View file

@ -204,7 +204,8 @@ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz) {
// Not enough room in dst, add NUL and traverse rest of src.
if (n == 0) {
if (siz != 0) *d = '\0'; // NUL-terminate dst
while (*s++) ; // ignore rest of src
while (*s++)
; // ignore rest of src
}
return s - src - 1; // count does not include NUL
}
@ -506,7 +507,7 @@ int flock(int fd, int op) {
struct flock fl = {0};
switch (op & (LOCK_EX|LOCK_SH|LOCK_UN)) {
switch (op & (LOCK_EX | LOCK_SH | LOCK_UN)) {
case LOCK_EX:
fl.l_type = F_WRLCK;
break;
@ -527,10 +528,9 @@ int flock(int fd, int op) {
fl.l_whence = SEEK_SET;
rc = fcntl(fd, op & LOCK_NB ? F_SETLK : F_SETLKW, &fl);
if (rc && (errno == EAGAIN))
errno = EWOULDBLOCK;
if (rc && (errno == EAGAIN)) errno = EWOULDBLOCK;
return rc;
}
#endif // HAVE_FLOCK
#endif // HAVE_FLOCK

View file

@ -134,10 +134,10 @@ int killpg(int pgr, int sig);
// cppcheck-suppress flockSemanticsWarning
int flock(int fd, int op);
#define LOCK_SH 1 /* Shared lock. */
#define LOCK_EX 2 /* Exclusive lock. */
#define LOCK_UN 8 /* Unlock. */
#define LOCK_NB 4 /* Don't block when locking. */
#define LOCK_SH 1 // Shared lock.
#define LOCK_EX 2 // Exclusive lock.
#define LOCK_UN 8 // Unlock.
#define LOCK_NB 4 // Don't block when locking.
#endif

View file

@ -1649,7 +1649,8 @@ struct pager_layout_testcase_t {
wcstring text = sd.line(0).to_string();
if (text != expected) {
fprintf(stderr, "width %lu got <%ls>, expected <%ls>\n", this->width, text.c_str(), expected.c_str());
fprintf(stderr, "width %lu got <%ls>, expected <%ls>\n", this->width, text.c_str(),
expected.c_str());
}
do_test(text == expected);
}
@ -1666,20 +1667,14 @@ static void test_pager_layout() {
const completion_t c1(L"abcdefghij", L"1234567890");
pager.set_completions(completion_list_t(1, c1));
const pager_layout_testcase_t testcases1[] = {
{26, L"abcdefghij (1234567890)"},
{25, L"abcdefghij (1234567890)"},
{24, L"abcdefghij (1234567890)"},
{23, L"abcdefghij (12345678…)"},
{22, L"abcdefghij (1234567…)"},
{21, L"abcdefghij (123456…)"},
{20, L"abcdefghij (12345…)"},
{19, L"abcdefghij (1234…)"},
{18, L"abcdefgh… (1234…)"},
{17, L"abcdefg… (1234…)"},
{16, L"abcdefg… (123…)"},
{0, NULL} // sentinel terminator
{26, L"abcdefghij (1234567890)"}, {25, L"abcdefghij (1234567890)"},
{24, L"abcdefghij (1234567890)"}, {23, L"abcdefghij (12345678…)"},
{22, L"abcdefghij (1234567…)"}, {21, L"abcdefghij (123456…)"},
{20, L"abcdefghij (12345…)"}, {19, L"abcdefghij (1234…)"},
{18, L"abcdefgh… (1234…)"}, {17, L"abcdefg… (1234…)"},
{16, L"abcdefg… (123…)"}, {0, NULL} // sentinel terminator
};
for (size_t i=0; testcases1[i].expected != NULL; i++) {
for (size_t i = 0; testcases1[i].expected != NULL; i++) {
testcases1[i].run(pager);
}
@ -1687,20 +1682,14 @@ static void test_pager_layout() {
const completion_t c2(L"abcdefghijklmnopqrs", L"1");
pager.set_completions(completion_list_t(1, c2));
const pager_layout_testcase_t testcases2[] = {
{26, L"abcdefghijklmnopqrs (1)"},
{25, L"abcdefghijklmnopqrs (1)"},
{24, L"abcdefghijklmnopqrs (1)"},
{23, L"abcdefghijklmnopq… (1)"},
{22, L"abcdefghijklmnop… (1)"},
{21, L"abcdefghijklmno… (1)"},
{20, L"abcdefghijklmn… (1)"},
{19, L"abcdefghijklm… (1)"},
{18, L"abcdefghijkl… (1)"},
{17, L"abcdefghijk… (1)"},
{16, L"abcdefghij… (1)"},
{0, NULL} // sentinel terminator
{26, L"abcdefghijklmnopqrs (1)"}, {25, L"abcdefghijklmnopqrs (1)"},
{24, L"abcdefghijklmnopqrs (1)"}, {23, L"abcdefghijklmnopq… (1)"},
{22, L"abcdefghijklmnop… (1)"}, {21, L"abcdefghijklmno… (1)"},
{20, L"abcdefghijklmn… (1)"}, {19, L"abcdefghijklm… (1)"},
{18, L"abcdefghijkl… (1)"}, {17, L"abcdefghijk… (1)"},
{16, L"abcdefghij… (1)"}, {0, NULL} // sentinel terminator
};
for (size_t i=0; testcases2[i].expected != NULL; i++) {
for (size_t i = 0; testcases2[i].expected != NULL; i++) {
testcases2[i].run(pager);
}
@ -1708,25 +1697,18 @@ static void test_pager_layout() {
const completion_t c3(L"abcdefghijklmnopqrst", L"");
pager.set_completions(completion_list_t(1, c3));
const pager_layout_testcase_t testcases3[] = {
{26, L"abcdefghijklmnopqrst"},
{25, L"abcdefghijklmnopqrst"},
{24, L"abcdefghijklmnopqrst"},
{23, L"abcdefghijklmnopqrst"},
{22, L"abcdefghijklmnopqrst"},
{21, L"abcdefghijklmnopqrst"},
{20, L"abcdefghijklmnopqrst"},
{19, L"abcdefghijklmnopqr…"},
{18, L"abcdefghijklmnopq…"},
{17, L"abcdefghijklmnop…"},
{16, L"abcdefghijklmno…"},
{0, NULL} // sentinel terminator
{26, L"abcdefghijklmnopqrst"}, {25, L"abcdefghijklmnopqrst"},
{24, L"abcdefghijklmnopqrst"}, {23, L"abcdefghijklmnopqrst"},
{22, L"abcdefghijklmnopqrst"}, {21, L"abcdefghijklmnopqrst"},
{20, L"abcdefghijklmnopqrst"}, {19, L"abcdefghijklmnopqr…"},
{18, L"abcdefghijklmnopq…"}, {17, L"abcdefghijklmnop…"},
{16, L"abcdefghijklmno…"}, {0, NULL} // sentinel terminator
};
for (size_t i=0; testcases3[i].expected != NULL; i++) {
for (size_t i = 0; testcases3[i].expected != NULL; i++) {
testcases3[i].run(pager);
}
}
enum word_motion_t { word_motion_left, word_motion_right };
static void test_1_word_motion(word_motion_t motion, move_word_style_t style,
const wcstring &test) {
@ -4127,10 +4109,10 @@ static void test_illegal_command_exit_code(void) {
{L"**", STATUS_ILLEGAL_CMD},
{L"%", STATUS_ILLEGAL_CMD},
{L"%test", STATUS_ILLEGAL_CMD},
// the following two inputs cause errors during tests for unknown reasons
// ("terminate called after throwing an instance of 'std::bad_alloc'")
// {L"?", STATUS_ILLEGAL_CMD},
// {L"abc?def", STATUS_ILLEGAL_CMD},
// the following two inputs cause errors during tests for unknown reasons
// ("terminate called after throwing an instance of 'std::bad_alloc'")
// {L"?", STATUS_ILLEGAL_CMD},
// {L"abc?def", STATUS_ILLEGAL_CMD},
{L") ", STATUS_ILLEGAL_CMD}};
int res = 0;
@ -4143,7 +4125,8 @@ static void test_illegal_command_exit_code(void) {
int exit_status = res ? STATUS_UNKNOWN_COMMAND : proc_get_last_status();
if (exit_status != tests[i].result) {
err(L"command '%ls': expected exit code %d , got %d", tests[i].txt, tests[i].result, exit_status);
err(L"command '%ls': expected exit code %d , got %d", tests[i].txt, tests[i].result,
exit_status);
}
}
}

View file

@ -327,7 +327,8 @@ class history_search_t {
}
// Default constructor.
history_search_t() : history(), term(), search_type(HISTORY_SEARCH_TYPE_CONTAINS), case_sensitive(true) {}
history_search_t()
: history(), term(), search_type(HISTORY_SEARCH_TYPE_CONTAINS), case_sensitive(true) {}
};
// Init history library. The history file won't actually be loaded until the first time a history

View file

@ -75,15 +75,9 @@ class pager_t {
/// On-screen width of the description information.
size_t desc_width;
/// Minimum acceptable width.
//size_t min_width;
// size_t min_width;
comp_t()
: comp(),
desc(),
representative(L""),
comp_width(0),
desc_width(0)
{}
comp_t() : comp(), desc(), representative(L""), comp_width(0), desc_width(0) {}
// Our text looks like this:
// completion (description)
@ -119,8 +113,8 @@ class pager_t {
bool completion_info_passes_filter(const comp_t &info) const;
void completion_print(size_t cols, const size_t *width_per_column, size_t row_start, size_t row_stop,
const wcstring &prefix, const comp_info_list_t &lst,
void completion_print(size_t cols, const size_t *width_per_column, size_t row_start,
size_t row_stop, const wcstring &prefix, const comp_info_list_t &lst,
page_rendering_t *rendering) const;
line_t completion_print_item(const wcstring &prefix, const comp_t *c, size_t row, size_t column,
size_t width, bool secondary, bool selected,

View file

@ -136,22 +136,14 @@ enum parse_keyword_t {
} __packed;
const enum_map<parse_keyword_t> keyword_enum_map[] = {
{parse_keyword_and, L"and"},
{parse_keyword_begin, L"begin"},
{parse_keyword_builtin, L"builtin"},
{parse_keyword_case, L"case"},
{parse_keyword_command, L"command"},
{parse_keyword_else, L"else"},
{parse_keyword_end, L"end"},
{parse_keyword_exec, L"exec"},
{parse_keyword_for, L"for"},
{parse_keyword_function, L"function"},
{parse_keyword_if, L"if"},
{parse_keyword_in, L"in"},
{parse_keyword_not, L"not"},
{parse_keyword_or, L"or"},
{parse_keyword_switch, L"switch"},
{parse_keyword_while, L"while"},
{parse_keyword_and, L"and"}, {parse_keyword_begin, L"begin"},
{parse_keyword_builtin, L"builtin"}, {parse_keyword_case, L"case"},
{parse_keyword_command, L"command"}, {parse_keyword_else, L"else"},
{parse_keyword_end, L"end"}, {parse_keyword_exec, L"exec"},
{parse_keyword_for, L"for"}, {parse_keyword_function, L"function"},
{parse_keyword_if, L"if"}, {parse_keyword_in, L"in"},
{parse_keyword_not, L"not"}, {parse_keyword_or, L"or"},
{parse_keyword_switch, L"switch"}, {parse_keyword_while, L"while"},
{parse_keyword_none, NULL}};
#define keyword_enum_map_len (sizeof keyword_enum_map / sizeof *keyword_enum_map)

View file

@ -708,8 +708,7 @@ parse_execution_result_t parse_execution_context_t::report_errors(
parser->get_backtrace(src, error_list, &backtrace_and_desc);
// Print it.
if (! should_suppress_stderr_for_tests())
fprintf(stderr, "%ls", backtrace_and_desc.c_str());
if (!should_suppress_stderr_for_tests()) fprintf(stderr, "%ls", backtrace_and_desc.c_str());
}
return parse_execution_errored;
}

View file

@ -204,9 +204,9 @@ static int parse_util_locate_brackets_range(const wcstring &str, size_t *inout_c
// The command substitutions must not be NULL and must be in the valid pointer range, and
// the end must be bigger than the beginning.
assert(bracket_range_begin != NULL && bracket_range_begin >= valid_range_start &&
bracket_range_begin <= valid_range_end);
bracket_range_begin <= valid_range_end);
assert(bracket_range_end != NULL && bracket_range_end > bracket_range_begin &&
bracket_range_end >= valid_range_start && bracket_range_end <= valid_range_end);
bracket_range_end >= valid_range_start && bracket_range_end <= valid_range_end);
// Assign the substring to the out_contents.
const wchar_t *interior_begin = bracket_range_begin + 1;
@ -1040,13 +1040,12 @@ parser_test_error_bits_t parse_util_detect_errors_in_argument(const parse_node_t
if (out_errors) {
// We have something like $$$^.... Back up until we reach the first $.
size_t first_dollar = idx;
while (first_dollar > 0 &&
(unesc.at(first_dollar - 1) == VARIABLE_EXPAND ||
unesc.at(first_dollar - 1) == VARIABLE_EXPAND_SINGLE)) {
while (first_dollar > 0 && (unesc.at(first_dollar - 1) == VARIABLE_EXPAND ||
unesc.at(first_dollar - 1) == VARIABLE_EXPAND_SINGLE)) {
first_dollar--;
}
parse_util_expand_variable_error(unesc, node.source_start, first_dollar,
out_errors);
out_errors);
}
}
}
@ -1174,13 +1173,13 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src,
parse_bool_statement_type_t bool_type =
parse_node_tree_t::statement_boolean_type(*spec_statement);
if (bool_type == parse_bool_and) { // this is not allowed
errored = append_syntax_error(
&parse_errors, spec_statement->source_start,
BOOL_AFTER_BACKGROUND_ERROR_MSG, L"and");
errored =
append_syntax_error(&parse_errors, spec_statement->source_start,
BOOL_AFTER_BACKGROUND_ERROR_MSG, L"and");
} else if (bool_type == parse_bool_or) { // this is not allowed
errored = append_syntax_error(
&parse_errors, spec_statement->source_start,
BOOL_AFTER_BACKGROUND_ERROR_MSG, L"or");
errored =
append_syntax_error(&parse_errors, spec_statement->source_start,
BOOL_AFTER_BACKGROUND_ERROR_MSG, L"or");
}
break;
}

View file

@ -123,8 +123,7 @@ static bool is_screen_name_escape_seq(const wchar_t *code, size_t *resulting_len
// Consider just <esc>k to be the code.
*resulting_length = 2;
} else {
const wchar_t *escape_sequence_end =
screen_name_end + wcslen(screen_name_end_sentinel);
const wchar_t *escape_sequence_end = screen_name_end + wcslen(screen_name_end_sentinel);
*resulting_length = escape_sequence_end - code;
}
return true;

View file

@ -55,9 +55,7 @@ struct line_t {
colors.insert(colors.end(), line.colors.begin(), line.colors.end());
}
wcstring to_string() const {
return wcstring(this->text.begin(), this->text.end());
}
wcstring to_string() const { return wcstring(this->text.begin(), this->text.end()); }
};
/// A class representing screen contents.

View file

@ -490,7 +490,8 @@ class wildcard_expander_t {
void add_expansion_result(const wcstring &result) {
// This function is only for the non-completions case.
assert(!static_cast<bool>(this->flags & EXPAND_FOR_COMPLETIONS)); //!OCLINT(multiple unary operator)
assert(!static_cast<bool>(this->flags &
EXPAND_FOR_COMPLETIONS)); //!OCLINT(multiple unary operator)
if (this->completion_set.insert(result).second) {
append_completion(this->resolved_completions, result);
this->did_add = true;