mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Fix memory leak when displaying bind list.
This also removes duplication from the code.
This commit is contained in:
parent
f5e62f28bc
commit
a7facfb760
1 changed files with 9 additions and 19 deletions
20
builtin.cpp
20
builtin.cpp
|
@ -425,29 +425,19 @@ static void builtin_bind_list(const wchar_t *bind_mode)
|
|||
}
|
||||
|
||||
wcstring tname;
|
||||
if (input_terminfo_get_name(seq, tname))
|
||||
{
|
||||
append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", tname.c_str(), mode.c_str(), sets_mode.c_str());
|
||||
for (size_t i = 0; i < ecmds.size(); i++)
|
||||
{
|
||||
wcstring ecmd = ecmds.at(i);
|
||||
append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
|
||||
}
|
||||
append_format(stdout_buffer, L"\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
const wcstring eseq = escape_string(seq, 1);
|
||||
|
||||
const wcstring eseq = input_terminfo_get_name(seq, tname) ? tname : escape_string(seq, 1);
|
||||
append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", eseq.c_str(), mode.c_str(), sets_mode.c_str());
|
||||
for (size_t i = 0; i < ecmds.size(); i++)
|
||||
{
|
||||
wcstring ecmd = ecmds.at(i);
|
||||
append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
|
||||
wchar_t *escaped = escape(ecmd.c_str(), 1);
|
||||
append_format(stdout_buffer, L" %ls", escaped);
|
||||
free(escaped);
|
||||
}
|
||||
append_format(stdout_buffer, L"\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Print terminfo key binding names to string buffer used for standard output.
|
||||
|
|
Loading…
Reference in a new issue