diff options
author | Kurtis Rader <krader@skepticism.us> | 2016-05-03 16:23:30 -0700 |
---|---|---|
committer | Kurtis Rader <krader@skepticism.us> | 2016-05-03 17:14:56 -0700 |
commit | fc44cffac50e6096528f2bde456d91a4e40ea7c9 (patch) | |
tree | 3c6c928aa0a8568b6e37a0698deb464575ba3fe2 /src/parse_util.cpp | |
parent | 5c8763be0e68bbdec3fdd1edb5754f4c421098e1 (diff) |
restyle switch blocks to match project style
I missed restyling a few "switch" blocks to make them consistent with the rest
of the code base. This fixes that oversight. This should be the final step in
restyling the C++ code to have a consistent style. This also includes a few
trivial cleanups elsewhere.
I also missed restyling the "complete" module when working my way from a to z
so this final change includes restyling that module.
Total lint errors decreased 36%. Cppcheck errors went from 47 to 24. Oclint P2
errors went from 819 to 778. Oclint P3 errors went from 3252 to 1842.
Resolves #2902.
Diffstat (limited to 'src/parse_util.cpp')
-rw-r--r-- | src/parse_util.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 85016244..821669ed 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -540,13 +540,15 @@ wcstring parse_util_escape_string_with_quote(const wcstring &cmd, wchar_t quote) case L'\n': case L'\t': case L'\b': - case L'\r': + case L'\r': { unescapable = true; break; - default: + } + default: { if (c == quote) result.push_back(L'\\'); result.push_back(c); break; + } } } @@ -815,21 +817,25 @@ static wcstring truncate_string(const wcstring &str) { /// For example, if wc is @, then the variable name was $@ and we suggest $argv. static const wchar_t *error_format_for_character(wchar_t wc) { switch (wc) { - case L'?': + case L'?': { return ERROR_NOT_STATUS; - case L'#': + } + case L'#': { return ERROR_NOT_ARGV_COUNT; - case L'@': + } + case L'@': { return ERROR_NOT_ARGV_AT; - case L'*': + } + case L'*': { return ERROR_NOT_ARGV_STAR; + } case L'$': case VARIABLE_EXPAND: case VARIABLE_EXPAND_SINGLE: - case VARIABLE_EXPAND_EMPTY: + case VARIABLE_EXPAND_EMPTY: { return ERROR_NOT_PID; - default: - return ERROR_BAD_VAR_CHAR1; + } + default: { return ERROR_BAD_VAR_CHAR1; } } } @@ -1156,7 +1162,6 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, BACKGROUND_IN_CONDITIONAL_ERROR_MSG); break; } - case symbol_job_list: { // This isn't very complete, e.g. we don't catch 'foo & ; not and bar'. assert(node_tree.get_child(*job_parent, 0) == &node); @@ -1195,9 +1200,7 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, } break; } - - default: - break; + default: { break; } } } } else if (node.type == symbol_plain_statement) { @@ -1268,23 +1271,24 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, if (loop_or_function_header != NULL) { switch (loop_or_function_header->type) { case symbol_while_header: - case symbol_for_header: + case symbol_for_header: { // This is a loop header, so we can break or continue. found_loop = true; end_search = true; break; - - case symbol_function_header: + } + case symbol_function_header: { // This is a function header, so we cannot break or // continue. We stop our search here. found_loop = false; end_search = true; break; - - default: + } + default: { // Most likely begin / end style block, which makes no // difference. break; + } } } ancestor = node_tree.get_parent(*ancestor); |