mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-15 08:14:28 +08:00
client: Check for RL_STATE_DONE before trying to print
This commit is contained in:
parent
6934437fc7
commit
e3069721d4
@ -36,22 +36,29 @@
|
||||
void rl_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
bool save_input;
|
||||
char *saved_line;
|
||||
int saved_point;
|
||||
|
||||
saved_point = rl_point;
|
||||
saved_line = rl_copy_text(0, rl_end);
|
||||
rl_save_prompt();
|
||||
rl_replace_line("", 0);
|
||||
rl_redisplay();
|
||||
save_input = !RL_ISSTATE(RL_STATE_DONE);
|
||||
|
||||
if (save_input) {
|
||||
saved_point = rl_point;
|
||||
saved_line = rl_copy_text(0, rl_end);
|
||||
rl_save_prompt();
|
||||
rl_replace_line("", 0);
|
||||
rl_redisplay();
|
||||
}
|
||||
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
rl_restore_prompt();
|
||||
rl_replace_line(saved_line, 0);
|
||||
rl_point = saved_point;
|
||||
rl_redisplay();
|
||||
free(saved_line);
|
||||
if (save_input) {
|
||||
rl_restore_prompt();
|
||||
rl_replace_line(saved_line, 0);
|
||||
rl_point = saved_point;
|
||||
rl_redisplay();
|
||||
free(saved_line);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user