OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [VER_5_3/] [gdb-5.3/] [readline/] [examples/] [rltest.c] - Diff between revs 1182 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 1182 Rev 1765
/* **************************************************************** */
/* **************************************************************** */
/*                                                                  */
/*                                                                  */
/*                      Testing Readline                            */
/*                      Testing Readline                            */
/*                                                                  */
/*                                                                  */
/* **************************************************************** */
/* **************************************************************** */
 
 
#if defined (HAVE_CONFIG_H)
#if defined (HAVE_CONFIG_H)
#include <config.h>
#include <config.h>
#endif
#endif
 
 
#include <stdio.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/types.h>
 
 
#ifdef READLINE_LIBRARY
#ifdef READLINE_LIBRARY
#  include "readline.h"
#  include "readline.h"
#  include "history.h"
#  include "history.h"
#else
#else
#  include <readline/readline.h>
#  include <readline/readline.h>
#  include <readline/history.h>
#  include <readline/history.h>
#endif
#endif
 
 
extern HIST_ENTRY **history_list ();
extern HIST_ENTRY **history_list ();
 
 
main ()
main ()
{
{
  char *temp, *prompt;
  char *temp, *prompt;
  int done;
  int done;
 
 
  temp = (char *)NULL;
  temp = (char *)NULL;
  prompt = "readline$ ";
  prompt = "readline$ ";
  done = 0;
  done = 0;
 
 
  while (!done)
  while (!done)
    {
    {
      temp = readline (prompt);
      temp = readline (prompt);
 
 
      /* Test for EOF. */
      /* Test for EOF. */
      if (!temp)
      if (!temp)
        exit (1);
        exit (1);
 
 
      /* If there is anything on the line, print it and remember it. */
      /* If there is anything on the line, print it and remember it. */
      if (*temp)
      if (*temp)
        {
        {
          fprintf (stderr, "%s\r\n", temp);
          fprintf (stderr, "%s\r\n", temp);
          add_history (temp);
          add_history (temp);
        }
        }
 
 
      /* Check for `command' that we handle. */
      /* Check for `command' that we handle. */
      if (strcmp (temp, "quit") == 0)
      if (strcmp (temp, "quit") == 0)
        done = 1;
        done = 1;
 
 
      if (strcmp (temp, "list") == 0)
      if (strcmp (temp, "list") == 0)
        {
        {
          HIST_ENTRY **list;
          HIST_ENTRY **list;
          register int i;
          register int i;
 
 
          list = history_list ();
          list = history_list ();
          if (list)
          if (list)
            {
            {
              for (i = 0; list[i]; i++)
              for (i = 0; list[i]; i++)
                fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
                fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
            }
            }
        }
        }
      free (temp);
      free (temp);
    }
    }
  exit (0);
  exit (0);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.