mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Simplify error case of token_type_description and keyword_description
Simply return a constant string, since in practice the error case is not hit
This commit is contained in:
parent
a40f491c93
commit
05d569ee44
1 changed files with 2 additions and 11 deletions
|
@ -123,23 +123,14 @@ void parse_error_offset_source_start(parse_error_list_t *errors, size_t amt) {
|
|||
const wchar_t *token_type_description(parse_token_type_t type) {
|
||||
const wchar_t *description = enum_to_str(type, token_enum_map);
|
||||
if (description) return description;
|
||||
return L"unknown_token_type";
|
||||
|
||||
// This leaks memory but it should never be run unless we have a bug elsewhere in the code.
|
||||
const wcstring d = format_string(L"unknown_token_type_%ld", static_cast<long>(type));
|
||||
wchar_t *d2 = new wchar_t[d.size() + 1];
|
||||
// cppcheck-suppress memleak
|
||||
return std::wcscpy(d2, d.c_str());
|
||||
}
|
||||
|
||||
const wchar_t *keyword_description(parse_keyword_t type) {
|
||||
const wchar_t *keyword = enum_to_str(type, keyword_enum_map);
|
||||
if (keyword) return keyword;
|
||||
|
||||
// This leaks memory but it should never be run unless we have a bug elsewhere in the code.
|
||||
const wcstring d = format_string(L"unknown_keyword_%ld", static_cast<long>(type));
|
||||
wchar_t *d2 = new wchar_t[d.size() + 1];
|
||||
// cppcheck-suppress memleak
|
||||
return std::wcscpy(d2, d.c_str());
|
||||
return L"unknown_keyword";
|
||||
}
|
||||
|
||||
static wcstring token_type_user_presentable_description(
|
||||
|
|
Loading…
Reference in a new issue