vsh: Introduce wrapper for add_history()

This allows us to drop include of readline header files from
virsh.c and virt-admin.c because they needed it only because of
the add_history() function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik
2020-09-03 10:02:52 +02:00
parent 028d6c0513
commit f123412b53
4 changed files with 18 additions and 16 deletions

View File

@@ -24,11 +24,6 @@
#include <unistd.h>
#include <getopt.h>
#if WITH_READLINE
# include <readline/readline.h>
# include <readline/history.h>
#endif
#include "internal.h"
#include "virt-admin.h"
#include "viralloc.h"
@@ -1597,9 +1592,8 @@ main(int argc, char **argv)
if (ctl->cmdstr == NULL)
break; /* EOF */
if (*ctl->cmdstr) {
#if WITH_READLINE
add_history(ctl->cmdstr);
#endif
vshReadlineHistoryAdd(ctl->cmdstr);
if (vshCommandStringParse(ctl, ctl->cmdstr, NULL))
vshCommandRun(ctl, ctl->cmd);
}