diff options
Diffstat (limited to 'readline/examples')
-rw-r--r-- | readline/examples/ChangeLog.Cygnus | 6 | ||||
-rw-r--r-- | readline/examples/Makefile.in | 38 | ||||
-rw-r--r-- | readline/examples/fileman.c | 26 | ||||
-rw-r--r-- | readline/examples/rl.c | 39 | ||||
-rw-r--r-- | readline/examples/rltest.c | 16 | ||||
-rw-r--r-- | readline/examples/rlversion.c | 8 |
6 files changed, 96 insertions, 37 deletions
diff --git a/readline/examples/ChangeLog.Cygnus b/readline/examples/ChangeLog.Cygnus new file mode 100644 index 00000000000..43adfc10356 --- /dev/null +++ b/readline/examples/ChangeLog.Cygnus @@ -0,0 +1,6 @@ +2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com> + + * Import of readline 4.1. + + New files: excallback.c, rlfe.c. + diff --git a/readline/examples/Makefile.in b/readline/examples/Makefile.in index 879aa49555b..7246e75f8ce 100644 --- a/readline/examples/Makefile.in +++ b/readline/examples/Makefile.in @@ -1,5 +1,22 @@ -# This is the Makefile for the examples subdirectory of readline. -*- text -*- # +# This is the Makefile for the readline examples subdirectory. +# +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program 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 2, or (at your option) +# any later version. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. + SHELL = @MAKE_SHELL@ RM = rm -f @@ -11,7 +28,7 @@ BUILD_DIR = . DEFS = @DEFS@ CC = @CC@ CFLAGS = @CFLAGS@ -LOCAL_CFLAGS = @LOCAL_CFLAGS@ +LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DREADLINE_LIBRARY CPPFLAGS = @CPPFLAGS@ INCLUDES = -I$(srcdir) -I$(top_srcdir) -I.. @@ -19,6 +36,9 @@ INCLUDES = -I$(srcdir) -I$(top_srcdir) -I.. CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS) LDFLAGS = -g -L.. +READLINE_LIB = ../libreadline.a +HISTORY_LIB = ../libhistory.a + TERMCAP_LIB = @TERMCAP_LIB@ .c.o: @@ -39,12 +59,12 @@ fileman: fileman.o rltest: rltest.o $(CC) $(LDFLAGS) -o $@ rltest.o -lreadline $(TERMCAP_LIB) -rlversion: rlversion.o +rlversion: rlversion.o $(READLINE_LIB) $(CC) $(LDFLAGS) -o $@ rlversion.o -lreadline $(TERMCAP_LIB) clean mostlyclean: $(RM) $(OBJECTS) - $(RM) $(EXECUTABLES) + $(RM) $(EXECUTABLES) *.exe distclean maintainer-clean: clean $(RM) Makefile @@ -53,3 +73,13 @@ fileman.o: fileman.c rltest.o: rltest.c rl.o: rl.c rlversion.o: rlversion.c + +# Stuff for Per Bothner's `rlfe' program + +rlfe: rlfe.o $(READLINE_LIB) $(HISTORY_LIB) + $(CC) $(LDFLAGS) -o $@ rlfe.o -lreadline -lhistory ${TERMCAP_LIB} + +rlfe.o: rlfe.c + +rlfe.o: $(top_srcdir)/readline.h +rlfe.o: $(top_srcdir)/history.h diff --git a/readline/examples/fileman.c b/readline/examples/fileman.c index 0702a5badc7..dc29a40104f 100644 --- a/readline/examples/fileman.c +++ b/readline/examples/fileman.c @@ -1,22 +1,22 @@ /* fileman.c -- A tiny application which demonstrates how to use the GNU Readline library. This application interactively allows users to manipulate files and their modes. */ -/* - * Remove the next line if you're compiling this against an installed - * libreadline.a - */ -#define READLINE_LIBRARY #ifdef HAVE_CONFIG_H -#include <config.h> +# include <config.h> #endif #include <sys/types.h> #ifdef HAVE_SYS_FILE_H -#include <sys/file.h> +# include <sys/file.h> #endif #include <sys/stat.h> +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +#include <fcntl.h> #include <stdio.h> #include <errno.h> @@ -26,6 +26,10 @@ # include <strings.h> #endif /* !HAVE_STRING_H */ +#ifdef HAVE_STDLIB_H +# include <stdlib.h> +#endif + #ifdef READLINE_LIBRARY # include "readline.h" # include "history.h" @@ -34,7 +38,6 @@ # include <readline/history.h> #endif -extern char *getwd (); extern char *xmalloc (); /* The names of functions that actually do the manipulation. */ @@ -300,7 +303,12 @@ com_view (arg) if (!valid_argument ("view", arg)) return 1; +#if defined (__MSDOS__) + /* more.com doesn't grok slashes in pathnames */ + sprintf (syscom, "less %s", arg); +#else sprintf (syscom, "more %s", arg); +#endif return (system (syscom)); } @@ -406,7 +414,7 @@ com_pwd (ignore) { char dir[1024], *s; - s = getwd (dir); + s = getcwd (dir, sizeof(dir) - 1); if (s == 0) { printf ("Error getting pwd: %s\n", dir); diff --git a/readline/examples/rl.c b/readline/examples/rl.c index 17a63434f24..2d1d17e600d 100644 --- a/readline/examples/rl.c +++ b/readline/examples/rl.c @@ -2,15 +2,9 @@ * rl - command-line interface to read a line from the standard input * (or another fd) using readline. * - * usage: rl [-p prompt] [-u unit] [-d default] + * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars] */ -/* - * Remove the next line if you're compiling this against an installed - * libreadline.a - */ -#define READLINE_LIBRARY - #if defined (HAVE_CONFIG_H) # include <config.h> #endif @@ -18,8 +12,14 @@ #include <stdio.h> #include <sys/types.h> #include "posixstat.h" -#include "readline.h" -#include "history.h" + +#if defined (READLINE_LIBRARY) +# include "readline.h" +# include "history.h" +#else +# include <readline/readline.h> +# include <readline/history.h> +#endif extern int optind; extern char *optarg; @@ -40,22 +40,24 @@ set_deftext () deftext = (char *)NULL; rl_startup_hook = (Function *)NULL; } + return 0; } static void usage() { - fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default]\n", + fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n", progname, progname); } +int main (argc, argv) int argc; char **argv; { char *temp, *prompt; struct stat sb; - int opt, fd; + int opt, fd, nch; FILE *ifp; progname = strrchr(argv[0], '/'); @@ -66,10 +68,10 @@ main (argc, argv) /* defaults */ prompt = "readline$ "; - fd = 0; + fd = nch = 0; deftext = (char *)0; - while ((opt = getopt(argc, argv, "p:u:d:")) != EOF) + while ((opt = getopt(argc, argv, "p:u:d:n:")) != EOF) { switch (opt) { @@ -87,6 +89,14 @@ main (argc, argv) case 'd': deftext = optarg; break; + case 'n': + nch = atoi(optarg); + if (nch < 0) + { + fprintf (stderr, "%s: bad value for -n: `%s'\n", progname, optarg); + exit (2); + } + break; default: usage (); exit (2); @@ -107,6 +117,9 @@ main (argc, argv) if (deftext && *deftext) rl_startup_hook = set_deftext; + if (nch > 0) + rl_num_chars_to_read = nch; + temp = readline (prompt); /* Test for EOF. */ diff --git a/readline/examples/rltest.c b/readline/examples/rltest.c index 453f8ec2ada..6250f900d42 100644 --- a/readline/examples/rltest.c +++ b/readline/examples/rltest.c @@ -4,20 +4,20 @@ /* */ /* **************************************************************** */ -/* - * Remove the next line if you're compiling this against an installed - * libreadline.a - */ -#define READLINE_LIBRARY - #if defined (HAVE_CONFIG_H) #include <config.h> #endif #include <stdio.h> #include <sys/types.h> -#include "readline.h" -#include "history.h" + +#ifdef READLINE_LIBRARY +# include "readline.h" +# include "history.h" +#else +# include <readline/readline.h> +# include <readline/history.h> +#endif extern HIST_ENTRY **history_list (); diff --git a/readline/examples/rlversion.c b/readline/examples/rlversion.c index 2d73a96c386..652d37ccb88 100644 --- a/readline/examples/rlversion.c +++ b/readline/examples/rlversion.c @@ -2,8 +2,6 @@ * rlversion -- print out readline's version number */ -#define READLINE_LIBRARY - #if defined (HAVE_CONFIG_H) # include <config.h> #endif @@ -12,7 +10,11 @@ #include <sys/types.h> #include "posixstat.h" -#include "readline.h" +#ifdef READLINE_LIBRARY +# include "readline.h" +#else +# include <readline/readline.h> +#endif main() { |