summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-23 18:47:16 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-23 18:47:16 -0500
commitdb4c00d880b67af735af9b18835ae900f5be9e53 (patch)
tree8dfe99254425c933b2b9024e06faa506f3640359 /examples
parentfe34a312c8be645944828402351bd1192972586b (diff)
downloadreadline-db4c00d880b67af735af9b18835ae900f5be9e53.tar.gz
Readline-2.2 import
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.in25
-rw-r--r--examples/rl.c4
-rw-r--r--examples/rltest.c23
3 files changed, 35 insertions, 17 deletions
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 8dd7f62..1848673 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -1,5 +1,8 @@
# This is the Makefile for the examples subdirectory of readline. -*- text -*-
#
+SHELL = /bin/sh
+RM = rm -f
+
srcdir = @srcdir@
VPATH = .:@srcdir@
top_srcdir = @top_srcdir@
@@ -16,22 +19,32 @@ INCLUDES = -I $(srcdir) -I $(top_srcdir) -I..
CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
LDFLAGS = -g -L..
+TERMCAP_LIB = @TERMCAP_LIB@
+
.c.o:
$(CC) $(CCFLAGS) -c $<
EXECUTABLES = fileman rltest rl
+OBJECTS = fileman.o rltest.o rl.o
all: $(EXECUTABLES)
rl: rl.o
- $(CC) $(LDFLAGS) -o $@ rl.o -lreadline -ltermcap
+ $(CC) $(LDFLAGS) -o $@ rl.o -lreadline $(TERMCAP_LIB)
fileman: fileman.o
- $(CC) $(LDFLAGS) -o $@ fileman.o -lreadline -ltermcap
+ $(CC) $(LDFLAGS) -o $@ fileman.o -lreadline $(TERMCAP_LIB)
rltest: rltest.o
- $(CC) $(LDFLAGS) -o $@ rltest.o -lreadline -ltermcap
+ $(CC) $(LDFLAGS) -o $@ rltest.o -lreadline $(TERMCAP_LIB)
+
+clean mostlyclean:
+ $(RM) $(OBJECTS)
+ $(RM) $(EXECUTABLES)
+
+distclean maintainer-clean: clean
+ $(RM) Makefile
-fileman.o: $(srcdir)/fileman.c
-rltest.o: $(srcdir)/rltest.c
-rl.o: $(srcdir)/rl.c
+fileman.o: fileman.c
+rltest.o: rltest.c
+rl.o: rl.c
diff --git a/examples/rl.c b/examples/rl.c
index 6c2f343..ccddd0f 100644
--- a/examples/rl.c
+++ b/examples/rl.c
@@ -12,7 +12,7 @@
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
-#include <config.h>
+# include <config.h>
#endif
#include <stdio.h>
@@ -24,7 +24,9 @@
extern int optind;
extern char *optarg;
+#if !defined (strchr) && !defined (__STDC__)
extern char *strrchr();
+#endif
static char *progname;
static char *deftext;
diff --git a/examples/rltest.c b/examples/rltest.c
index ff3ad5c..453f8ec 100644
--- a/examples/rltest.c
+++ b/examples/rltest.c
@@ -19,12 +19,16 @@
#include "readline.h"
#include "history.h"
+extern HIST_ENTRY **history_list ();
+
main ()
{
- HIST_ENTRY **history_list ();
- char *temp = (char *)NULL;
- char *prompt = "readline$ ";
- int done = 0;
+ char *temp, *prompt;
+ int done;
+
+ temp = (char *)NULL;
+ prompt = "readline$ ";
+ done = 0;
while (!done)
{
@@ -47,18 +51,17 @@ main ()
if (strcmp (temp, "list") == 0)
{
- HIST_ENTRY **list = history_list ();
+ HIST_ENTRY **list;
register int i;
+
+ list = history_list ();
if (list)
{
for (i = 0; list[i]; i++)
- {
- fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
- free (list[i]->line);
- }
- free (list);
+ fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
}
}
free (temp);
}
+ exit (0);
}