aboutsummaryrefslogtreecommitdiff
path: root/readline/examples
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-08-12 10:24:03 -0600
committerTom Tromey <tom@tromey.com>2019-08-12 10:57:56 -0600
commitcb41b9e70e6fbd1cb603bb9ba4372fbb8ae87b20 (patch)
tree6b03a978514e9f7df56c1243a3796776ecc65198 /readline/examples
parentca2589f3bbad1e151abbb293d4c43a87b7a4d5ec (diff)
downloadgdb-cb41b9e70e6fbd1cb603bb9ba4372fbb8ae87b20.zip
gdb-cb41b9e70e6fbd1cb603bb9ba4372fbb8ae87b20.tar.gz
gdb-cb41b9e70e6fbd1cb603bb9ba4372fbb8ae87b20.tar.bz2
Import readline 8.0
This imports readline 8.0. readline/ChangeLog.gdb 2019-08-12 Tom Tromey <tom@tromey.com> * Imported readline 8.0.
Diffstat (limited to 'readline/examples')
-rw-r--r--readline/examples/Makefile.in29
-rw-r--r--readline/examples/hist_erasedups.c2
-rw-r--r--readline/examples/hist_purgecmd.c2
-rw-r--r--readline/examples/histexamp.c3
-rw-r--r--readline/examples/rlcat.c2
-rw-r--r--readline/examples/rlevent.c7
-rw-r--r--readline/examples/rlkeymaps.c61
-rw-r--r--readline/examples/rltest.c1
8 files changed, 101 insertions, 6 deletions
diff --git a/readline/examples/Makefile.in b/readline/examples/Makefile.in
index 5094c6c..4a7c39e 100644
--- a/readline/examples/Makefile.in
+++ b/readline/examples/Makefile.in
@@ -53,8 +53,12 @@ CPPFLAGS = @CPPFLAGS@
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
-CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
-LDFLAGS = -g -L.. @LDFLAGS@
+CCFLAGS = $(ASAN_CFLAGS) $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(CPPFLAGS) \
+ $(CFLAGS)
+LDFLAGS = -g -L.. @LDFLAGS@ $(ASAN_LDFLAGS)
+
+ASAN_XCFLAGS = -fsanitize=address -fno-omit-frame-pointer
+ASAN_XLDFLAGS = -fsanitize=address
READLINE_LIB = ../libreadline.a
HISTORY_LIB = ../libhistory.a
@@ -67,15 +71,18 @@ TERMCAP_LIB = @TERMCAP_LIB@
SOURCES = excallback.c fileman.c histexamp.c manexamp.c rl-fgets.c rl.c \
rlbasic.c rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c \
- rl-callbacktest.c hist_erasedups.c hist_purgecmd.c
+ rltest2.c rl-callbacktest.c hist_erasedups.c hist_purgecmd.c \
+ rlkeymaps.c
EXECUTABLES = fileman$(EXEEXT) rltest$(EXEEXT) rl$(EXEEXT) rlcat$(EXEEXT) \
rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT) \
rl-callbacktest$(EXEEXT) rlbasic$(EXEEXT) \
- hist_erasedups$(EXEEXT) hist_purgecmd$(EXEEXT)
+ hist_erasedups$(EXEEXT) hist_purgecmd$(EXEEXT) \
+ rlkeymaps$(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
+ rltest2.o rl-callbacktest.o rlbasic.o hist_erasedups.o hist_purgecmd.o \
+ rlkeymaps.o
OTHEREXE = rlptytest$(EXEEXT)
OTHEROBJ = rlptytest.o
@@ -83,6 +90,9 @@ OTHEROBJ = rlptytest.o
all: $(EXECUTABLES)
everything: all
+asan:
+ ${MAKE} ${MFLAGS} ASAN_CFLAGS='${ASAN_XCFLAGS}' ASAN_LDFLAGS='${ASAN_XLDFLAGS}' all
+
check: rlversion$(EXEEXT)
@echo Readline version: `rlversion$(EXEEXT)`
@@ -113,12 +123,18 @@ rlcat$(EXEEXT): rlcat.o $(READLINE_LIB)
rlevent$(EXEEXT): rlevent.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rlevent.o $(READLINE_LIB) $(TERMCAP_LIB)
+rlkeymaps$(EXEEXT): rlkeymaps.o $(READLINE_LIB)
+ $(CC) $(LDFLAGS) -o $@ rlkeymaps.o $(READLINE_LIB) $(TERMCAP_LIB)
+
fileman$(EXEEXT): fileman.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB)
rltest$(EXEEXT): rltest.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB)
+rltest2$(EXEEXT): rltest2.o $(READLINE_LIB)
+ $(CC) $(LDFLAGS) -o $@ rltest2.o $(READLINE_LIB) $(TERMCAP_LIB)
+
rl-callbacktest$(EXEEXT): rl-callbacktest.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rl-callbacktest.o $(READLINE_LIB) $(TERMCAP_LIB)
@@ -146,18 +162,21 @@ distclean maintainer-clean: clean
fileman.o: fileman.c
rltest.o: rltest.c
+rltest2.o: rltest2.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
+rlkeymaps.o: rlkeymaps.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
+rltest2.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
rl.o: $(top_srcdir)/readline.h
rlversion.o: $(top_srcdir)/readline.h
histexamp.o: $(top_srcdir)/history.h
diff --git a/readline/examples/hist_erasedups.c b/readline/examples/hist_erasedups.c
index 2ecee89..f820eba 100644
--- a/readline/examples/hist_erasedups.c
+++ b/readline/examples/hist_erasedups.c
@@ -38,6 +38,8 @@
#define STREQN(a, b, n) ((n == 0) ? (1) \
: ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
+int hist_erasedups (void);
+
static void
usage()
{
diff --git a/readline/examples/hist_purgecmd.c b/readline/examples/hist_purgecmd.c
index d836d14..7992d81 100644
--- a/readline/examples/hist_purgecmd.c
+++ b/readline/examples/hist_purgecmd.c
@@ -43,6 +43,8 @@
#define PURGE_REGEXP 0x01
+int hist_purgecmd (char *, int);
+
static void
usage()
{
diff --git a/readline/examples/histexamp.c b/readline/examples/histexamp.c
index 3b43674..309d769 100644
--- a/readline/examples/histexamp.c
+++ b/readline/examples/histexamp.c
@@ -27,8 +27,11 @@
# include <readline/history.h>
#endif
+#include <unistd.h>
+#include <stdlib.h>
#include <string.h>
+int
main (argc, argv)
int argc;
char **argv;
diff --git a/readline/examples/rlcat.c b/readline/examples/rlcat.c
index fa9e06f..b494241 100644
--- a/readline/examples/rlcat.c
+++ b/readline/examples/rlcat.c
@@ -137,7 +137,7 @@ fcopy(fp)
if (vflag && isascii ((unsigned char)c) && isprint((unsigned char)c) == 0)
{
x = rl_untranslate_keyseq (c);
- if (fputs (x, stdout) != 0)
+ if (fputs (x, stdout) == EOF)
return 1;
}
else if (putchar (c) == EOF)
diff --git a/readline/examples/rlevent.c b/readline/examples/rlevent.c
index 77f1887..8143cb0 100644
--- a/readline/examples/rlevent.c
+++ b/readline/examples/rlevent.c
@@ -28,6 +28,13 @@
# include <config.h>
#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#else
+extern int getopt();
+extern int sleep();
+#endif
+
#include <stdio.h>
#include <sys/types.h>
diff --git a/readline/examples/rlkeymaps.c b/readline/examples/rlkeymaps.c
new file mode 100644
index 0000000..fef77b3
--- /dev/null
+++ b/readline/examples/rlkeymaps.c
@@ -0,0 +1,61 @@
+#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)
+{
+ Keymap nmap, emacsmap, newemacs;
+ int r, errs;
+
+ errs = 0;
+ nmap = rl_make_keymap ();
+
+ r = rl_set_keymap_name ("emacs", nmap);
+ if (r >= 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: able to rename `emacs' keymap\n");
+ errs++;
+ }
+
+ emacsmap = rl_get_keymap_by_name ("emacs");
+ r = rl_set_keymap_name ("newemacs", emacsmap);
+ if (r >= 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: able to set new name for emacs keymap\n");
+ errs++;
+ }
+
+ r = rl_set_keymap_name ("newemacs", nmap);
+ if (r < 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: newemacs: could not set keymap name\n");
+ errs++;
+ }
+
+ newemacs = rl_copy_keymap (emacsmap);
+ r = rl_set_keymap_name ("newemacs", newemacs);
+ if (r < 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: newemacs: could not set `newemacs' keymap to new map\n");
+ errs++;
+ }
+
+ r = rl_set_keymap_name ("emacscopy", newemacs);
+ if (r < 0)
+ {
+ fprintf (stderr, "rlkeymaps: error: emacscopy: could not rename created keymap\n");
+ errs++;
+ }
+
+ exit (errs);
+}
diff --git a/readline/examples/rltest.c b/readline/examples/rltest.c
index 78e2608..65abe87 100644
--- a/readline/examples/rltest.c
+++ b/readline/examples/rltest.c
@@ -46,6 +46,7 @@ extern void exit();
extern HIST_ENTRY **history_list ();
+int
main ()
{
char *temp, *prompt;