summaryrefslogtreecommitdiff
path: root/readline/examples
diff options
context:
space:
mode:
Diffstat (limited to 'readline/examples')
-rw-r--r--readline/examples/Makefile.in56
-rw-r--r--readline/examples/excallback.c7
-rw-r--r--readline/examples/fileman.c18
-rw-r--r--readline/examples/hist_erasedups.c119
-rw-r--r--readline/examples/hist_purgecmd.c149
-rw-r--r--readline/examples/readlinebuf.h6
-rw-r--r--readline/examples/rl-callbacktest.c115
-rw-r--r--readline/examples/rl.c1
-rw-r--r--readline/examples/rlbasic.c29
-rw-r--r--readline/examples/rlfe/config.h.in6
-rwxr-xr-xreadline/examples/rlfe/configure15
-rw-r--r--readline/examples/rlfe/configure.in4
-rw-r--r--readline/examples/rlfe/extern.h2
-rw-r--r--readline/examples/rlfe/os.h8
-rw-r--r--readline/examples/rlfe/rlfe.c9
-rw-r--r--readline/examples/rlptytest.c14
-rw-r--r--readline/examples/rlversion.c1
17 files changed, 529 insertions, 30 deletions
diff --git a/readline/examples/Makefile.in b/readline/examples/Makefile.in
index c8d937ad0b7..5094c6c5254 100644
--- a/readline/examples/Makefile.in
+++ b/readline/examples/Makefile.in
@@ -53,11 +53,9 @@ CPPFLAGS = @CPPFLAGS@
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
-CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
+CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LDFLAGS = -g -L.. @LDFLAGS@
-PURIFY = @PURIFY@
-
READLINE_LIB = ../libreadline.a
HISTORY_LIB = ../libhistory.a
@@ -68,11 +66,19 @@ TERMCAP_LIB = @TERMCAP_LIB@
$(CC) $(CCFLAGS) -c $<
SOURCES = excallback.c fileman.c histexamp.c manexamp.c rl-fgets.c rl.c \
- rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c
+ rlbasic.c rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c \
+ rl-callbacktest.c hist_erasedups.c hist_purgecmd.c
EXECUTABLES = fileman$(EXEEXT) rltest$(EXEEXT) rl$(EXEEXT) rlcat$(EXEEXT) \
- rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT)
-OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o
+ rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT) \
+ rl-callbacktest$(EXEEXT) rlbasic$(EXEEXT) \
+ hist_erasedups$(EXEEXT) hist_purgecmd$(EXEEXT)
+
+OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o \
+ rl-callbacktest.o rlbasic.o hist_erasedups.o hist_purgecmd.o
+
+OTHEREXE = rlptytest$(EXEEXT)
+OTHEROBJ = rlptytest.o
all: $(EXECUTABLES)
everything: all
@@ -96,32 +102,44 @@ uninstall:
-rmdir $(DESTDIR)$(installdir)
rl$(EXEEXT): rl.o $(READLINE_LIB)
- $(PURIFY) $(CC) $(LDFLAGS) -o $@ rl.o $(READLINE_LIB) $(TERMCAP_LIB)
+ $(CC) $(LDFLAGS) -o $@ rl.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+rlbasic$(EXEEXT): rlbasic.o $(READLINE_LIB)
+ $(CC) $(LDFLAGS) -o $@ rlbasic.o $(READLINE_LIB) $(TERMCAP_LIB)
rlcat$(EXEEXT): rlcat.o $(READLINE_LIB)
- $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlcat.o $(READLINE_LIB) $(TERMCAP_LIB)
+ $(CC) $(LDFLAGS) -o $@ rlcat.o $(READLINE_LIB) $(TERMCAP_LIB)
rlevent$(EXEEXT): rlevent.o $(READLINE_LIB)
- $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlevent.o $(READLINE_LIB) $(TERMCAP_LIB)
+ $(CC) $(LDFLAGS) -o $@ rlevent.o $(READLINE_LIB) $(TERMCAP_LIB)
fileman$(EXEEXT): fileman.o $(READLINE_LIB)
- $(PURIFY) $(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB)
+ $(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB)
rltest$(EXEEXT): rltest.o $(READLINE_LIB)
- $(PURIFY) $(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB)
+ $(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB)
+
+rl-callbacktest$(EXEEXT): rl-callbacktest.o $(READLINE_LIB)
+ $(CC) $(LDFLAGS) -o $@ rl-callbacktest.o $(READLINE_LIB) $(TERMCAP_LIB)
rlptytest$(EXEEXT): rlptytest.o $(READLINE_LIB)
- $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlptytest.o $(READLINE_LIB) $(TERMCAP_LIB)
+ $(CC) $(LDFLAGS) -o $@ rlptytest.o $(READLINE_LIB) $(TERMCAP_LIB) $(LIBUTIL)
rlversion$(EXEEXT): rlversion.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rlversion.o $(READLINE_LIB) $(TERMCAP_LIB)
histexamp$(EXEEXT): histexamp.o $(HISTORY_LIB)
- $(PURIFY) $(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
+ $(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
+
+hist_erasedups$(EXEEXT): hist_erasedups.o $(HISTORY_LIB)
+ $(CC) $(LDFLAGS) -o $@ hist_erasedups.o -lhistory $(TERMCAP_LIB)
+
+hist_purgecmd$(EXEEXT): hist_purgecmd.o $(HISTORY_LIB)
+ $(CC) $(LDFLAGS) -o $@ hist_purgecmd.o -lhistory $(TERMCAP_LIB)
clean mostlyclean:
- $(RM) $(OBJECTS)
- $(RM) $(EXECUTABLES) *.exe
+ $(RM) $(OBJECTS) $(OTHEROBJ)
+ $(RM) $(EXECUTABLES) $(OTHEREXE) *.exe
distclean maintainer-clean: clean
$(RM) Makefile
@@ -131,13 +149,21 @@ rltest.o: rltest.c
rl.o: rl.c
rlversion.o: rlversion.c
histexamp.o: histexamp.c
+hist_erasedups.o: hist_erasedups.c
+hist_purgecmd.o: hist_purgecmd.c
+rlbasic.o: rlbasic.c
rlcat.o: rlcat.c
rlptytest.o: rlptytest.c
+rl-callbacktest.o: rl-callbacktest.c
fileman.o: $(top_srcdir)/readline.h
rltest.o: $(top_srcdir)/readline.h
rl.o: $(top_srcdir)/readline.h
rlversion.o: $(top_srcdir)/readline.h
histexamp.o: $(top_srcdir)/history.h
+hist_erasedups.o: $(top_srcdir)/history.h
+hist_purgecmd.o: $(top_srcdir)/history.h
+rlbasic.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
rlcat.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
rlptytest.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
+rl-callbacktest.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
diff --git a/readline/examples/excallback.c b/readline/examples/excallback.c
index 385492b1b70..4206acfca4a 100644
--- a/readline/examples/excallback.c
+++ b/readline/examples/excallback.c
@@ -40,13 +40,14 @@ Copyright (C) 1999 Jeff Solomon
#include <config.h>
#endif
-#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#include <stdlib.h>
+#include <stdio.h>
#include <termios.h> /* xxx - should make this more general */
#ifdef READLINE_LIBRARY
@@ -55,6 +56,10 @@ Copyright (C) 1999 Jeff Solomon
# include <readline/readline.h>
#endif
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif
+
/* This little examples demonstrates the alternate interface to using readline.
* In the alternate interface, the user maintains control over program flow and
* only calls readline when STDIN is readable. Using the alternate interface,
diff --git a/readline/examples/fileman.c b/readline/examples/fileman.c
index f7eed8a982f..c821df033aa 100644
--- a/readline/examples/fileman.c
+++ b/readline/examples/fileman.c
@@ -63,6 +63,12 @@
extern char *xmalloc PARAMS((size_t));
+void initialize_readline PARAMS((void));
+void too_dangerous PARAMS((char *));
+
+int execute_line PARAMS((char *));
+int valid_argument PARAMS((char *, char *));
+
/* The names of functions that actually do the manipulation. */
int com_list PARAMS((char *));
int com_view PARAMS((char *));
@@ -119,6 +125,7 @@ dupstr (s)
return (r);
}
+int
main (argc, argv)
int argc;
char **argv;
@@ -241,6 +248,7 @@ char **fileman_completion PARAMS((const char *, int, int));
/* Tell the GNU Readline library how to complete. We want to try to complete
on command names if this is the first word in the line, or on filenames
if not. */
+void
initialize_readline ()
{
/* Allow conditional parsing of the ~/.inputrc file. */
@@ -317,6 +325,7 @@ command_generator (text, state)
static char syscom[1024];
/* List the file(s) named in arg. */
+int
com_list (arg)
char *arg;
{
@@ -327,6 +336,7 @@ com_list (arg)
return (system (syscom));
}
+int
com_view (arg)
char *arg;
{
@@ -342,6 +352,7 @@ com_view (arg)
return (system (syscom));
}
+int
com_rename (arg)
char *arg;
{
@@ -349,6 +360,7 @@ com_rename (arg)
return (1);
}
+int
com_stat (arg)
char *arg;
{
@@ -377,6 +389,7 @@ com_stat (arg)
return (0);
}
+int
com_delete (arg)
char *arg;
{
@@ -386,6 +399,7 @@ com_delete (arg)
/* Print out help for ARG, or for all of the commands if ARG is
not present. */
+int
com_help (arg)
char *arg;
{
@@ -425,6 +439,7 @@ com_help (arg)
}
/* Change to the directory ARG. */
+int
com_cd (arg)
char *arg;
{
@@ -439,6 +454,7 @@ com_cd (arg)
}
/* Print out the current working directory. */
+int
com_pwd (ignore)
char *ignore;
{
@@ -456,6 +472,7 @@ com_pwd (ignore)
}
/* The user wishes to quit using this program. Just set DONE non-zero. */
+int
com_quit (arg)
char *arg;
{
@@ -464,6 +481,7 @@ com_quit (arg)
}
/* Function which tells you that you can't do this. */
+void
too_dangerous (caller)
char *caller;
{
diff --git a/readline/examples/hist_erasedups.c b/readline/examples/hist_erasedups.c
new file mode 100644
index 00000000000..2ecee899c3b
--- /dev/null
+++ b/readline/examples/hist_erasedups.c
@@ -0,0 +1,119 @@
+/* hist_erasedups -- remove all duplicate entries from history file */
+
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef READLINE_LIBRARY
+#define READLINE_LIBRARY 1
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef READLINE_LIBRARY
+# include "history.h"
+#else
+# include <readline/history.h>
+#endif
+
+#include <string.h>
+
+#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
+#define STREQN(a, b, n) ((n == 0) ? (1) \
+ : ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
+
+static void
+usage()
+{
+ fprintf (stderr, "hist_erasedups: usage: hist_erasedups [-t] [filename]\n");
+ exit (2);
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ char *fn;
+ int r;
+
+ while ((r = getopt (argc, argv, "t")) != -1)
+ {
+ switch (r)
+ {
+ case 't':
+ history_write_timestamps = 1;
+ break;
+ default:
+ usage ();
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
+ fn = argc ? argv[0] : getenv ("HISTFILE");
+ if (fn == 0)
+ {
+ fprintf (stderr, "hist_erasedups: no history file\n");
+ usage ();
+ }
+
+ if ((r = read_history (fn)) != 0)
+ {
+ fprintf (stderr, "hist_erasedups: read_history: %s: %s\n", fn, strerror (r));
+ exit (1);
+ }
+
+ hist_erasedups ();
+
+ if ((r = write_history (fn)) != 0)
+ {
+ fprintf (stderr, "hist_erasedups: write_history: %s: %s\n", fn, strerror (r));
+ exit (1);
+ }
+
+ exit (0);
+}
+
+int
+hist_erasedups ()
+{
+ int r, n;
+ HIST_ENTRY *h, *temp;
+
+ using_history ();
+ while (h = previous_history ())
+ {
+ r = where_history ();
+ for (n = 0; n < r; n++)
+ {
+ temp = history_get (n+history_base);
+ if (STREQ (h->line, temp->line))
+ {
+ remove_history (n);
+ r--; /* have to get one fewer now */
+ n--; /* compensate for above increment */
+ history_offset--; /* moving backwards in history list */
+ }
+ }
+ }
+ using_history ();
+
+ return r;
+}
diff --git a/readline/examples/hist_purgecmd.c b/readline/examples/hist_purgecmd.c
new file mode 100644
index 00000000000..d836d146ebd
--- /dev/null
+++ b/readline/examples/hist_purgecmd.c
@@ -0,0 +1,149 @@
+/* hist_purgecmd -- remove all instances of command or pattern from history
+ file */
+
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library (Readline), a library for
+ reading lines of text with interactive input and history editing.
+
+ Readline is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Readline is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef READLINE_LIBRARY
+#define READLINE_LIBRARY 1
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <regex.h>
+
+#ifdef READLINE_LIBRARY
+# include "history.h"
+#else
+# include <readline/history.h>
+#endif
+
+#include <string.h>
+
+#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
+#define STREQN(a, b, n) ((n == 0) ? (1) \
+ : ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
+
+#define PURGE_REGEXP 0x01
+
+static void
+usage()
+{
+ fprintf (stderr, "hist_purgecmd: usage: hist_purgecmd [-r] [-t] [-f filename] command-spec\n");
+ exit (2);
+}
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ char *fn;
+ int r, flags;
+
+ flags = 0;
+ fn = 0;
+ while ((r = getopt (argc, argv, "f:rt")) != -1)
+ {
+ switch (r)
+ {
+ case 'f':
+ fn = optarg;
+ break;
+ case 'r':
+ flags |= PURGE_REGEXP;
+ break;
+ case 't':
+ history_write_timestamps = 1;
+ break;
+ default:
+ usage ();
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
+ if (fn == 0)
+ fn = getenv ("HISTFILE");
+ if (fn == 0)
+ {
+ fprintf (stderr, "hist_purgecmd: no history file\n");
+ usage ();
+ }
+
+ if ((r = read_history (fn)) != 0)
+ {
+ fprintf (stderr, "hist_purgecmd: read_history: %s: %s\n", fn, strerror (r));
+ exit (1);
+ }
+
+ for (r = 0; r < argc; r++)
+ hist_purgecmd (argv[r], flags);
+
+ if ((r = write_history (fn)) != 0)
+ {
+ fprintf (stderr, "hist_purgecmd: write_history: %s: %s\n", fn, strerror (r));
+ exit (1);
+ }
+
+ exit (0);
+}
+
+int
+hist_purgecmd (cmd, flags)
+ char *cmd;
+ int flags;
+{
+ int r, n, rflags;
+ HIST_ENTRY *temp;
+ regex_t regex = { 0 };
+
+ if (flags & PURGE_REGEXP)
+ {
+ rflags = REG_EXTENDED|REG_NOSUB;
+ if (regcomp (&regex, cmd, rflags))
+ {
+ fprintf (stderr, "hist_purgecmd: %s: invalid regular expression\n", cmd);
+ return -1;
+ }
+ }
+
+ r = 0;
+ using_history ();
+ r = where_history ();
+ for (n = 0; n < r; n++)
+ {
+ temp = history_get (n+history_base);
+ if (((flags & PURGE_REGEXP) && (regexec (&regex, temp->line, 0, 0, 0) == 0)) ||
+ ((flags & PURGE_REGEXP) == 0 && STREQ (temp->line, cmd)))
+ {
+ remove_history (n);
+ r--; /* have to get one fewer now */
+ n--; /* compensate for above increment */
+ history_offset--; /* moving backwards in history list */
+ }
+ }
+ using_history ();
+
+ if (flags & PURGE_REGEXP)
+ regfree (&regex);
+
+ return r;
+}
diff --git a/readline/examples/readlinebuf.h b/readline/examples/readlinebuf.h
index b9189fbbec3..c8f3a7b41e2 100644
--- a/readline/examples/readlinebuf.h
+++ b/readline/examples/readlinebuf.h
@@ -1,7 +1,7 @@
/*******************************************************************************
- * $Revision$
- * $Date$
- * $Author$
+ * $Revision: 1.2 $
+ * $Date: 2001/09/11 06:19:36 $
+ * $Author: vyzo $
*
* Contents: A streambuf which uses the GNU readline library for line I/O
* (c) 2001 by Dimitris Vyzovitis [vyzo@media.mit.edu]
diff --git a/readline/examples/rl-callbacktest.c b/readline/examples/rl-callbacktest.c
new file mode 100644
index 00000000000..3525ffd9993
--- /dev/null
+++ b/readline/examples/rl-callbacktest.c
@@ -0,0 +1,115 @@
+/* Standard include files. stdio.h is required. */
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <locale.h>
+
+/* Used for select(2) */
+#include <sys/types.h>
+#include <sys/select.h>
+
+#include <signal.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+/* Standard readline include files. */
+#if defined (READLINE_LIBRARY)
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
+
+extern int errno;
+
+static void cb_linehandler (char *);
+static void signandler (int);
+
+int running, sigwinch_received;
+const char *prompt = "rltest$ ";
+
+/* Handle SIGWINCH and window size changes when readline is not active and
+ reading a character. */
+static void
+sighandler (int sig)
+{
+ sigwinch_received = 1;
+}
+
+/* Callback function called for each line when accept-line executed, EOF
+ seen, or EOF character read. This sets a flag and returns; it could
+ also call exit(3). */
+static void
+cb_linehandler (char *line)
+{
+ /* Can use ^D (stty eof) or `exit' to exit. */
+ if (line == NULL || strcmp (line, "exit") == 0)
+ {
+ if (line == 0)
+ printf ("\n");
+ printf ("exit\n");
+ /* This function needs to be called to reset the terminal settings,
+ and calling it from the line handler keeps one extra prompt from
+ being displayed. */
+ rl_callback_handler_remove ();
+
+ running = 0;
+ }
+ else
+ {
+ if (*line)
+ add_history (line);
+ printf ("input line: %s\n", line);
+ free (line);
+ }
+}
+
+int
+main (int c, char **v)
+{
+ fd_set fds;
+ int r;
+
+
+ setlocale (LC_ALL, "");
+
+ /* Handle SIGWINCH */
+ signal (SIGWINCH, sighandler);
+
+ /* Install the line handler. */
+ rl_callback_handler_install (prompt, cb_linehandler);
+
+ /* Enter a simple event loop. This waits until something is available
+ to read on readline's input stream (defaults to standard input) and
+ calls the builtin character read callback to read it. It does not
+ have to modify the user's terminal settings. */
+ running = 1;
+ while (running)
+ {
+ FD_ZERO (&fds);
+ FD_SET (fileno (rl_instream), &fds);
+
+ r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
+ if (r < 0 && errno != EINTR)
+ {
+ perror ("rltest: select");
+ rl_callback_handler_remove ();
+ break;
+ }
+ if (sigwinch_received)
+ {
+ rl_resize_terminal ();
+ sigwinch_received = 0;
+ }
+ if (r < 0)
+ continue;
+
+ if (FD_ISSET (fileno (rl_instream), &fds))
+ rl_callback_read_char ();
+ }
+
+ printf ("rltest: Event loop has exited\n");
+ return 0;
+}
diff --git a/readline/examples/rl.c b/readline/examples/rl.c
index 845a4b176d7..a5cf276cb94 100644
--- a/readline/examples/rl.c
+++ b/readline/examples/rl.c
@@ -28,6 +28,7 @@
# include <config.h>
#endif
+#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
diff --git a/readline/examples/rlbasic.c b/readline/examples/rlbasic.c
new file mode 100644
index 00000000000..6a9601f52a6
--- /dev/null
+++ b/readline/examples/rlbasic.c
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+#if defined (READLINE_LIBRARY)
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
+
+int
+main (int c, char **v)
+{
+ char *input;
+
+ for (;;) {
+ input = readline ((char *)NULL);
+ if (input == 0)
+ break;
+ printf ("%s\n", input);
+ if (strcmp (input, "exit") == 0)
+ break;
+ free (input);
+ }
+ exit (0);
+}
diff --git a/readline/examples/rlfe/config.h.in b/readline/examples/rlfe/config.h.in
index dbfc369663c..a843fecc4ac 100644
--- a/readline/examples/rlfe/config.h.in
+++ b/readline/examples/rlfe/config.h.in
@@ -21,7 +21,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
****************************************************************
- * $Id$ FAU
+ * $Id: config.h.in,v 1.12 1994/05/31 12:31:36 mlschroe Exp $ FAU
*/
@@ -377,3 +377,7 @@
#undef HAVE_SYS_STROPTS_H
#undef HAVE_SYS_WAIT_H
+
+#undef HAVE_SGTTY_H
+
+#undef HAVE_SYS_SELECT_H
diff --git a/readline/examples/rlfe/configure b/readline/examples/rlfe/configure
index 73603b26a75..b6d9b5be46c 100755
--- a/readline/examples/rlfe/configure
+++ b/readline/examples/rlfe/configure
@@ -3705,6 +3705,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+extern char *tgoto();
main()
{
exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
@@ -4341,7 +4342,7 @@ fi
done
-for ac_header in sys/stropts.h sys/wait.h
+for ac_header in sys/stropts.h sys/wait.h sgtty.h sys/select.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -4354,6 +4355,18 @@ fi
done
+for ac_header in term.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "term.h" "ac_cv_header_term_h" "$ac_includes_default"
+if test "x$ac_cv_header_term_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_TERM_H 1
+_ACEOF
+
+fi
+
+done
+
ac_config_files="$ac_config_files Makefile"
diff --git a/readline/examples/rlfe/configure.in b/readline/examples/rlfe/configure.in
index 108cd3f50e3..5c0678ab4d8 100644
--- a/readline/examples/rlfe/configure.in
+++ b/readline/examples/rlfe/configure.in
@@ -225,6 +225,7 @@ AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
AC_MSG_ERROR(!!! no tgetent - no screen))))))
AC_TRY_RUN([
+extern char *tgoto();
main()
{
exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
@@ -437,6 +438,7 @@ main()
fi
-AC_CHECK_HEADERS(sys/stropts.h sys/wait.h)
+AC_CHECK_HEADERS(sys/stropts.h sys/wait.h sgtty.h sys/select.h)
+AC_CHECK_HEADERS(term.h)
AC_OUTPUT(Makefile)
diff --git a/readline/examples/rlfe/extern.h b/readline/examples/rlfe/extern.h
index e9a5d01566b..2fe50250cc4 100644
--- a/readline/examples/rlfe/extern.h
+++ b/readline/examples/rlfe/extern.h
@@ -19,7 +19,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
****************************************************************
- * $Id$ FAU
+ * $Id: extern.h,v 1.18 1994/05/31 12:31:57 mlschroe Exp $ FAU
*/
#if !defined(__GNUC__) || __GNUC__ < 2
diff --git a/readline/examples/rlfe/os.h b/readline/examples/rlfe/os.h
index 734bc8c4308..df06c758099 100644
--- a/readline/examples/rlfe/os.h
+++ b/readline/examples/rlfe/os.h
@@ -19,7 +19,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
****************************************************************
- * $Id$ FAU
+ * $Id: os.h,v 1.10 1994/05/31 12:32:22 mlschroe Exp $ FAU
*/
#include <stdio.h>
@@ -208,7 +208,9 @@ extern int errno;
# include <cytermio.h>
# endif
# else /* TERMIO */
-# include <sgtty.h>
+# if defined (HAVE_SGTTY_H)
+# include <sgtty.h>
+# endif
# endif /* TERMIO */
#endif /* POSIX */
@@ -490,7 +492,7 @@ extern int errno;
* select stuff
*/
-#if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_)
+#if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_) || defined (__INTERIX)
#include <sys/select.h> /* for timeval + FD... */
#endif
diff --git a/readline/examples/rlfe/rlfe.c b/readline/examples/rlfe/rlfe.c
index eacd5abbb7b..f40b2ddaf00 100644
--- a/readline/examples/rlfe/rlfe.c
+++ b/readline/examples/rlfe/rlfe.c
@@ -547,7 +547,14 @@ main(int argc, char** argv)
#endif
t.c_lflag &= ~(ICANON | ISIG | ECHO | ECHOCTL | ECHOE | \
- ECHOK | ECHOKE | ECHONL | ECHOPRT );
+ ECHOK | ECHONL
+#if defined (ECHOKE)
+ | ECHOKE
+#endif
+#if defined (ECHOPRT)
+ | ECHOPRT
+#endif
+ );
t.c_iflag &= ~ICRNL;
t.c_iflag |= IGNBRK;
t.c_cc[VMIN] = 1;
diff --git a/readline/examples/rlptytest.c b/readline/examples/rlptytest.c
index 79257db4005..9c42f8a2795 100644
--- a/readline/examples/rlptytest.c
+++ b/readline/examples/rlptytest.c
@@ -19,7 +19,7 @@
#include <signal.h>
-#if 0 /* LINUX */
+#if 1 /* LINUX */
#include <pty.h>
#else
#include <util.h>
@@ -48,6 +48,13 @@ sigint (s)
exit (0);
}
+void
+sigwinch (s)
+ int s;
+{
+ rl_resize_terminal ();
+}
+
static int
user_input()
{
@@ -316,6 +323,9 @@ main()
if (val == -1)
return -1;
+ signal (SIGWINCH, sigwinch);
+ signal (SIGINT, sigint);
+
val = init_readline (slavefd, slavefd);
if (val == -1)
return -1;
@@ -324,8 +334,6 @@ main()
if (val == -1)
return -1;
- signal (SIGINT, sigint);
-
val = main_loop ();
tty_reset (STDIN_FILENO);
diff --git a/readline/examples/rlversion.c b/readline/examples/rlversion.c
index 88f4cd7fe4f..f36567becf4 100644
--- a/readline/examples/rlversion.c
+++ b/readline/examples/rlversion.c
@@ -41,6 +41,7 @@ extern void exit();
# include <readline/readline.h>
#endif
+int
main()
{
printf ("%s\n", rl_library_version ? rl_library_version : "unknown");