Clean up input_terminfo_get_sequence

This commit is contained in:
ridiculousfish 2019-09-14 14:59:01 -07:00
parent 5ebcd3de98
commit 5afcc439a5

View file

@ -678,25 +678,20 @@ bool input_terminfo_get_sequence(const wchar_t *name, wcstring *out_seq) {
ASSERT_IS_MAIN_THREAD(); ASSERT_IS_MAIN_THREAD();
assert(s_input_initialized); assert(s_input_initialized);
assert(name && "null name"); assert(name && "null name");
const char *res = 0;
int err = ENOENT;
for (const terminfo_mapping_t &m : *s_terminfo_mappings) { for (const terminfo_mapping_t &m : *s_terminfo_mappings) {
if (!std::wcscmp(name, m.name)) { if (!std::wcscmp(name, m.name)) {
res = m.seq; // Found the mapping.
err = EILSEQ; if (!m.seq) {
break; errno = EILSEQ;
return false;
} else {
*out_seq = str2wcstring(m.seq);
return true;
}
} }
} }
errno = ENOENT;
if (!res) { return false;
errno = err;
return false;
}
*out_seq = format_string(L"%s", res);
return true;
} }
bool input_terminfo_get_name(const wcstring &seq, wcstring *out_name) { bool input_terminfo_get_name(const wcstring &seq, wcstring *out_name) {