From 2ca96c58673afb1df494ae5b5b00256c140ce3d6 Mon Sep 17 00:00:00 2001 From: jaortega Date: Thu, 22 Mar 2001 02:33:58 +0000 Subject: minor changes --- mixutils/mixvm_command.c | 17 +++++++++++++++-- mixutils/mixvm_loop.c | 26 +++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) (limited to 'mixutils') diff --git a/mixutils/mixvm_command.c b/mixutils/mixvm_command.c index 516bd68..e1c03bf 100644 --- a/mixutils/mixvm_command.c +++ b/mixutils/mixvm_command.c @@ -24,8 +24,15 @@ #include #include #include -#include -#include + +#include + +#ifdef HAVE_LIBREADLINE +# include +# include +#else + typedef int Function (); +#endif /* HAVE_LIBREADLINE */ #include #include @@ -70,6 +77,7 @@ static const char *mix_commands_[ALL_COMMANDS_NO_] = {NULL}; +#ifdef HAVE_LIBREADLINE /* readline functions */ static char * mixvm_cmd_generator_ (char *text, int state); @@ -125,6 +133,7 @@ mixvm_cmd_generator_ (char *text, int state) /* If no names matched, then return NULL. */ return ((char *)NULL); } +#endif /* HAVE_LIBREADLINE */ /* command functions */ static COMMAND * @@ -281,8 +290,12 @@ mixvm_cmd_init (char *arg, gboolean use_emacs) for (k = 0; k < MIX_CMD_INVALID; ++k) mix_commands_[k + LOCAL_COMANDS_NO_] = mix_vm_command_to_string (k); mix_commands_[ALL_COMMANDS_NO_ - 1] = NULL; + +#ifdef HAVE_LIBREADLINE /* Tell the completer that we want a crack first. */ rl_attempted_completion_function = (CPPFunction *)mixvm_cmd_completion_; +#endif /* HAVE_LIBREADLINE */ + /* initialise the dispatcher */ dis_ = mix_vm_cmd_dispatcher_new (stdout, stderr); diff --git a/mixutils/mixvm_loop.c b/mixutils/mixvm_loop.c index 8a571d8..a565832 100644 --- a/mixutils/mixvm_loop.c +++ b/mixutils/mixvm_loop.c @@ -20,13 +20,33 @@ */ +#define _GNU_SOURCE 1 +#include #include -#include -#include -#include #include "mixvm_command.h" +#ifdef HAVE_LIBHISTORY +# include +#else +# define add_history(x) ((void)0) +#endif + +#ifdef HAVE_LIBREADLINE +# include +#else /* !HAVE_LIBREADLINE */ +static char * +readline (char *prompt) +{ + char *line = NULL; + size_t s = 0; + + printf ("%s", prompt); + getline (&line, &s, stdin); + return line; +} +#endif /* HAVE_LIBREADLINE */ + /* A static variable for holding the line. */ static char *line_read = (char *)NULL; static const char *PROMPT = N_("MIX > "); -- cgit v1.2.3