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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* **************************************************************** */
2
/*                                                                  */
3
/*                      Testing Readline                            */
4
/*                                                                  */
5
/* **************************************************************** */
6
 
7
/*
8
 * Remove the next line if you're compiling this against an installed
9
 * libreadline.a
10
 */
11
#define READLINE_LIBRARY
12
 
13
#if defined (HAVE_CONFIG_H)
14
#include <config.h>
15
#endif
16
 
17
#include <stdio.h>
18
#include <sys/types.h>
19
#include "readline.h"
20
#include "history.h"
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.