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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [readline/] [examples/] [rltest.c] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
/* **************************************************************** */
2
/*                                                                  */
3
/*                      Testing Readline                            */
4
/*                                                                  */
5
/* **************************************************************** */
6
 
7
#if defined (HAVE_CONFIG_H)
8
#include <config.h>
9
#endif
10
 
11
#include <stdio.h>
12
#include <sys/types.h>
13
 
14
#ifdef READLINE_LIBRARY
15
#  include "readline.h"
16
#  include "history.h"
17
#else
18
#  include <readline/readline.h>
19
#  include <readline/history.h>
20
#endif
21
 
22
extern HIST_ENTRY **history_list ();
23
 
24
main ()
25
{
26
  char *temp, *prompt;
27
  int done;
28
 
29
  temp = (char *)NULL;
30
  prompt = "readline$ ";
31
  done = 0;
32
 
33
  while (!done)
34
    {
35
      temp = readline (prompt);
36
 
37
      /* Test for EOF. */
38
      if (!temp)
39
        exit (1);
40
 
41
      /* If there is anything on the line, print it and remember it. */
42
      if (*temp)
43
        {
44
          fprintf (stderr, "%s\r\n", temp);
45
          add_history (temp);
46
        }
47
 
48
      /* Check for `command' that we handle. */
49
      if (strcmp (temp, "quit") == 0)
50
        done = 1;
51
 
52
      if (strcmp (temp, "list") == 0)
53
        {
54
          HIST_ENTRY **list;
55
          register int i;
56
 
57
          list = history_list ();
58
          if (list)
59
            {
60
              for (i = 0; list[i]; i++)
61
                fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
62
            }
63
        }
64
      free (temp);
65
    }
66
  exit (0);
67
}

powered by: WebSVN 2.1.0

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