mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-02 06:57:57 +08:00
Explicitly handle all enum values in more switch statements
This addresses a few places where -Wswitch-enum showed one or two missing case's for enum values. It did uncover and fix one apparent oversight: $ function asd -p 100 echo foo end $ functions --handlers-type exit Event exit asd It looks like this should be showing a PID before 'asd' just like job_exit handlers show the job id. It was falling through to default: which just printed the function name. $ functions --handlers-type exit Event exit 100 asd
This commit is contained in:
parent
3e8c05e32b
commit
2ae6e5a585
@ -176,6 +176,7 @@ static wcstring functions_def(const wcstring &name) {
|
|||||||
append_format(out, L" --on-event %ls", d.str_param1.c_str());
|
append_format(out, L" --on-event %ls", d.str_param1.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case event_type_t::any:
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected next->type");
|
DIE("unexpected next->type");
|
||||||
break;
|
break;
|
||||||
|
@ -131,9 +131,9 @@ static const wchar_t *math_get_arg(int *argidx, wchar_t **argv, wcstring *storag
|
|||||||
|
|
||||||
static wcstring math_describe_error(te_error_t& error) {
|
static wcstring math_describe_error(te_error_t& error) {
|
||||||
if (error.position == 0) return L"NO ERROR?!?";
|
if (error.position == 0) return L"NO ERROR?!?";
|
||||||
assert(error.type != TE_ERROR_NONE && L"Error has no position");
|
|
||||||
|
|
||||||
switch(error.type) {
|
switch(error.type) {
|
||||||
|
case TE_ERROR_NONE: DIE("Error has no position");
|
||||||
case TE_ERROR_UNKNOWN_VARIABLE: return _(L"Unknown variable");
|
case TE_ERROR_UNKNOWN_VARIABLE: return _(L"Unknown variable");
|
||||||
case TE_ERROR_MISSING_CLOSING_PAREN: return _(L"Missing closing parenthesis");
|
case TE_ERROR_MISSING_CLOSING_PAREN: return _(L"Missing closing parenthesis");
|
||||||
case TE_ERROR_MISSING_OPENING_PAREN: return _(L"Missing opening parenthesis");
|
case TE_ERROR_MISSING_OPENING_PAREN: return _(L"Missing opening parenthesis");
|
||||||
|
17
src/common.h
17
src/common.h
@ -429,7 +429,15 @@ static inline bool match_type_requires_full_replacement(fuzzy_match_type_t t) {
|
|||||||
case fuzzy_match_prefix: {
|
case fuzzy_match_prefix: {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default: { return true; }
|
case fuzzy_match_case_insensitive:
|
||||||
|
case fuzzy_match_prefix_case_insensitive:
|
||||||
|
case fuzzy_match_substring:
|
||||||
|
case fuzzy_match_substring_case_insensitive:
|
||||||
|
case fuzzy_match_subsequence_insertions_only:
|
||||||
|
case fuzzy_match_none:
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,7 +450,12 @@ static inline bool match_type_shares_prefix(fuzzy_match_type_t t) {
|
|||||||
case fuzzy_match_prefix_case_insensitive: {
|
case fuzzy_match_prefix_case_insensitive: {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default: { return false; }
|
case fuzzy_match_substring:
|
||||||
|
case fuzzy_match_substring_case_insensitive:
|
||||||
|
case fuzzy_match_subsequence_insertions_only:
|
||||||
|
case fuzzy_match_none: {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,8 @@ static bool handler_matches(const event_handler_t &classv, const event_t &instan
|
|||||||
case event_type_t::generic: {
|
case event_type_t::generic: {
|
||||||
return classv.desc.str_param1 == instance.desc.str_param1;
|
return classv.desc.str_param1 == instance.desc.str_param1;
|
||||||
}
|
}
|
||||||
default: {
|
case event_type_t::any: {
|
||||||
|
default:
|
||||||
DIE("unexpected classv.type");
|
DIE("unexpected classv.type");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -165,7 +166,7 @@ wcstring event_get_desc(const event_t &evt) {
|
|||||||
-ed.param1.pid);
|
-ed.param1.pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(0 && "Unreachable");
|
DIE("Unreachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
case event_type_t::job_exit: {
|
case event_type_t::job_exit: {
|
||||||
@ -182,6 +183,7 @@ wcstring event_get_desc(const event_t &evt) {
|
|||||||
case event_type_t::generic: {
|
case event_type_t::generic: {
|
||||||
return format_string(_(L"handler for generic event '%ls'"), ed.str_param1.c_str());
|
return format_string(_(L"handler for generic event '%ls'"), ed.str_param1.c_str());
|
||||||
}
|
}
|
||||||
|
case event_type_t::any: { DIE("Unreachable"); }
|
||||||
default:
|
default:
|
||||||
DIE("Unknown event type");
|
DIE("Unknown event type");
|
||||||
}
|
}
|
||||||
@ -409,6 +411,7 @@ void event_print(io_streams_t &streams, maybe_t<event_type_t> type_filter) {
|
|||||||
streams.out.append_format(L"%ls %ls\n", sig2wcs(evt->desc.param1.signal),
|
streams.out.append_format(L"%ls %ls\n", sig2wcs(evt->desc.param1.signal),
|
||||||
evt->function_name.c_str());
|
evt->function_name.c_str());
|
||||||
break;
|
break;
|
||||||
|
case event_type_t::exit:
|
||||||
case event_type_t::job_exit:
|
case event_type_t::job_exit:
|
||||||
streams.out.append_format(L"%d %ls\n", evt->desc.param1,
|
streams.out.append_format(L"%d %ls\n", evt->desc.param1,
|
||||||
evt->function_name.c_str());
|
evt->function_name.c_str());
|
||||||
@ -418,6 +421,7 @@ void event_print(io_streams_t &streams, maybe_t<event_type_t> type_filter) {
|
|||||||
streams.out.append_format(L"%ls %ls\n", evt->desc.str_param1.c_str(),
|
streams.out.append_format(L"%ls %ls\n", evt->desc.str_param1.c_str(),
|
||||||
evt->function_name.c_str());
|
evt->function_name.c_str());
|
||||||
break;
|
break;
|
||||||
|
case event_type_t::any: DIE("Unreachable");
|
||||||
default:
|
default:
|
||||||
streams.out.append_format(L"%ls\n", evt->function_name.c_str());
|
streams.out.append_format(L"%ls\n", evt->function_name.c_str());
|
||||||
break;
|
break;
|
||||||
|
@ -408,7 +408,10 @@ int oflags_for_redirection_type(redirection_type_t type) {
|
|||||||
case redirection_type_t::input: {
|
case redirection_type_t::input: {
|
||||||
return O_RDONLY;
|
return O_RDONLY;
|
||||||
}
|
}
|
||||||
default: { return -1; }
|
case redirection_type_t::fd:
|
||||||
|
default: {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user