diff options
Diffstat (limited to 'mixutils')
| -rw-r--r-- | mixutils/mixvm_command.c | 17 | ||||
| -rw-r--r-- | mixutils/mixvm_loop.c | 26 | 
2 files changed, 38 insertions, 5 deletions
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 <stdio.h>  #include <stdlib.h>  #include <ctype.h> -#include <readline/readline.h> -#include <readline/history.h> + +#include <mixlib/mix.h> + +#ifdef HAVE_LIBREADLINE +#  include <readline/readline.h> +#  include <readline/history.h> +#else +  typedef int Function (); +#endif /* HAVE_LIBREADLINE */  #include <mixlib/mix_vm.h>  #include <mixlib/mix_vm_dump.h> @@ -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 <stdio.h>  #include <mixlib/mix.h> -#include <stdio.h> -#include <readline/readline.h> -#include <readline/history.h>  #include "mixvm_command.h" +#ifdef HAVE_LIBHISTORY +#  include <readline/history.h> +#else +#  define add_history(x) ((void)0) +#endif + +#ifdef HAVE_LIBREADLINE +#  include <readline/readline.h> +#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 > ");  | 
