diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Inputrc | 24 | ||||
-rw-r--r-- | examples/Makefile.in | 85 | ||||
-rw-r--r-- | examples/autoconf/BASH_CHECK_LIB_TERMCAP | 40 | ||||
-rw-r--r-- | examples/autoconf/RL_LIB_READLINE_VERSION | 118 | ||||
-rw-r--r-- | examples/autoconf/wi_LIB_READLINE | 76 | ||||
-rw-r--r-- | examples/fileman.c | 29 | ||||
-rw-r--r-- | examples/histexamp.c | 25 | ||||
-rw-r--r-- | examples/manexamp.c | 23 | ||||
-rw-r--r-- | examples/readlinebuf.h | 2 | ||||
-rw-r--r-- | examples/rl.c | 23 | ||||
-rw-r--r-- | examples/rlcat.c | 23 | ||||
-rw-r--r-- | examples/rlevent.c | 166 | ||||
-rw-r--r-- | examples/rlfe/Makefile.in | 2 | ||||
-rw-r--r-- | examples/rlfe/config.h.in | 4 | ||||
-rw-r--r-- | examples/rlfe/configure.in | 2 | ||||
-rw-r--r-- | examples/rlfe/extern.h | 9 | ||||
-rw-r--r-- | examples/rlfe/pty.c | 7 | ||||
-rw-r--r-- | examples/rlfe/rlfe.c | 13 | ||||
-rw-r--r-- | examples/rltest.c | 23 | ||||
-rw-r--r-- | examples/rlversion.c | 23 | ||||
-rw-r--r-- | examples/rlwrap-0.30.tar.gz | bin | 0 -> 184033 bytes |
21 files changed, 588 insertions, 129 deletions
diff --git a/examples/Inputrc b/examples/Inputrc index d7fdb42..a358bc4 100644 --- a/examples/Inputrc +++ b/examples/Inputrc @@ -4,21 +4,21 @@ # on which program is running, or what terminal is active. # -# Copyright (C) 1989-2002 Free Software Foundation, Inc. +# Copyright (C) 1989-2009 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 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. # -# 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. +# 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, see <http://www.gnu.org/licenses/>. # -# 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. # In all programs, all terminals, make sure this is bound. "\C-x\C-r": re-read-init-file diff --git a/examples/Makefile.in b/examples/Makefile.in index e27bbc0..122b7f2 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -1,30 +1,46 @@ # # This is the Makefile for the readline examples subdirectory. # -# Copyright (C) 1994 Free Software Foundation, Inc. +# Copyright (C) 1994,2008,2009 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 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. -# 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. +# 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, see <http://www.gnu.org/licenses/>. -# 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. RL_LIBRARY_VERSION = @LIBVERSION@ SHELL = @MAKE_SHELL@ RM = rm -f +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +datarootdir = @datarootdir@ + +bindir = @bindir@ srcdir = @srcdir@ +datadir = @datadir@ VPATH = .:@srcdir@ top_srcdir = @top_srcdir@ -BUILD_DIR = . +#BUILD_DIR = . +BUILD_DIR = @BUILD_DIR@ +installdir = $(datadir)/readline + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +EXEEXT = @EXEEXT@ +OBJEXT = @OBJEXT@ # Support an alternate destination root directory for package building DESTDIR = @@ -51,31 +67,56 @@ TERMCAP_LIB = @TERMCAP_LIB@ ${RM} $@ $(CC) $(CCFLAGS) -c $< -EXECUTABLES = fileman rltest rl rlcat rlversion histexamp -OBJECTS = fileman.o rltest.o rl.o rlcat.o rlversion.o histexamp.o +SOURCES = excallback.c fileman.c histexamp.c manexamp.c rl-fgets.c rl.c \ + rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c + +EXECUTABLES = fileman$(EXE) rltest$(EXE) rl$(EXE) rlcat$(EXE) rlevent$(EXE) \ + rlversion$(EXE) histexamp$(EXE) +OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o all: $(EXECUTABLES) everything: all -rl: rl.o $(READLINE_LIB) +check: rlversion$(EXE) + @echo Readline version: `rlversion$(EXE)` + +installdirs: + -$(SHELL) $(top_srcdir)/support/mkdirs $(DESTDIR)$(installdir) + +install: installdirs + @for f in $(SOURCES); do \ + $(RM) $(DESTDIR)$(installdir)/$$f ; \ + $(INSTALL_DATA) $$f $(DESTDIR)$(installdir) ; \ + done + +uninstall: + @for f in $(SOURCES); do \ + $(RM) $(DESTDIR)$(installdir)/$$f ; \ + done + -rmdir $(DESTDIR)$(installdir) + +rl$(EXE): rl.o $(READLINE_LIB) $(PURIFY) $(CC) $(LDFLAGS) -o $@ rl.o $(READLINE_LIB) $(TERMCAP_LIB) -rlcat: rlcat.o $(READLINE_LIB) +rlcat$(EXE): rlcat.o $(READLINE_LIB) $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlcat.o $(READLINE_LIB) $(TERMCAP_LIB) -fileman: fileman.o $(READLINE_LIB) +rlevent$(EXE): rlevent.o $(READLINE_LIB) + $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlevent.o $(READLINE_LIB) $(TERMCAP_LIB) + +fileman$(EXE): fileman.o $(READLINE_LIB) $(PURIFY) $(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB) -rltest: rltest.o $(READLINE_LIB) +rltest$(EXE): rltest.o $(READLINE_LIB) $(PURIFY) $(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB) -rlptytest: rlptytest.o $(READLINE_LIB) +rlptytest$(EXE): rlptytest.o $(READLINE_LIB) $(PURIFY) $(CC) $(LDFLAGS) -o $@ rlptytest.o $(READLINE_LIB) $(TERMCAP_LIB) -rlversion: rlversion.o $(READLINE_LIB) +rlversion$(EXE): rlversion.o $(READLINE_LIB) $(CC) $(LDFLAGS) -o $@ rlversion.o $(READLINE_LIB) $(TERMCAP_LIB) -histexamp: histexamp.o $(HISTORY_LIB) +histexamp$(EXE): histexamp.o $(HISTORY_LIB) $(PURIFY) $(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB) clean mostlyclean: diff --git a/examples/autoconf/BASH_CHECK_LIB_TERMCAP b/examples/autoconf/BASH_CHECK_LIB_TERMCAP new file mode 100644 index 0000000..5e89551 --- /dev/null +++ b/examples/autoconf/BASH_CHECK_LIB_TERMCAP @@ -0,0 +1,40 @@ +AC_DEFUN([BASH_CHECK_LIB_TERMCAP], +[ +if test "X$bash_cv_termcap_lib" = "X"; then +_bash_needmsg=yes +else +AC_MSG_CHECKING(which library has the termcap functions) +_bash_needmsg= +fi +AC_CACHE_VAL(bash_cv_termcap_lib, +[AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc, + [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap, + [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo, + [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses, + [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses, + bash_cv_termcap_lib=gnutermcap)])])])])]) +if test "X$_bash_needmsg" = "Xyes"; then +AC_MSG_CHECKING(which library has the termcap functions) +fi +AC_MSG_RESULT(using $bash_cv_termcap_lib) +if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then +LDFLAGS="$LDFLAGS -L./lib/termcap" +TERMCAP_LIB="./lib/termcap/libtermcap.a" +TERMCAP_DEP="./lib/termcap/libtermcap.a" +elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then +TERMCAP_LIB=-ltermcap +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libtinfo; then +TERMCAP_LIB=-ltinfo +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libncurses; then +TERMCAP_LIB=-lncurses +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libc; then +TERMCAP_LIB= +TERMCAP_DEP= +else +TERMCAP_LIB=-lcurses +TERMCAP_DEP= +fi +]) diff --git a/examples/autoconf/RL_LIB_READLINE_VERSION b/examples/autoconf/RL_LIB_READLINE_VERSION new file mode 100644 index 0000000..883942c --- /dev/null +++ b/examples/autoconf/RL_LIB_READLINE_VERSION @@ -0,0 +1,118 @@ +dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB +dnl require: +dnl AC_PROG_CC +dnl BASH_CHECK_LIB_TERMCAP + +AC_DEFUN([RL_LIB_READLINE_VERSION], +[ +AC_REQUIRE([BASH_CHECK_LIB_TERMCAP]) + +AC_MSG_CHECKING([version of installed readline library]) + +# What a pain in the ass this is. + +# save cpp and ld options +_save_CFLAGS="$CFLAGS" +_save_LDFLAGS="$LDFLAGS" +_save_LIBS="$LIBS" + +# Don't set ac_cv_rl_prefix if the caller has already assigned a value. This +# allows the caller to do something like $_rl_prefix=$withval if the user +# specifies --with-installed-readline=PREFIX as an argument to configure + +if test -z "$ac_cv_rl_prefix"; then +test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix} +fi + +eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include +eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib + +LIBS="$LIBS -lreadline ${TERMCAP_LIB}" +CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}" +LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}" + +AC_CACHE_VAL(ac_cv_rl_version, +[AC_TRY_RUN([ +#include <stdio.h> +#include <readline/readline.h> + +extern int rl_gnu_readline_p; + +main() +{ + FILE *fp; + fp = fopen("conftest.rlv", "w"); + if (fp == 0) + exit(1); + if (rl_gnu_readline_p != 1) + fprintf(fp, "0.0\n"); + else + fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); + fclose(fp); + exit(0); +} +], +ac_cv_rl_version=`cat conftest.rlv`, +ac_cv_rl_version='0.0', +ac_cv_rl_version='4.2')]) + +CFLAGS="$_save_CFLAGS" +LDFLAGS="$_save_LDFLAGS" +LIBS="$_save_LIBS" + +RL_MAJOR=0 +RL_MINOR=0 + +# ( +case "$ac_cv_rl_version" in +2*|3*|4*|5*|6*|7*|8*|9*) + RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'` + RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'` + ;; +esac + +# ((( +case $RL_MAJOR in +[[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;; +[[0-9]]) _RL_MAJOR=0$RL_MAJOR ;; +*) _RL_MAJOR=00 ;; +esac + +# ((( +case $RL_MINOR in +[[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;; +[[0-9]]) _RL_MINOR=0$RL_MINOR ;; +*) _RL_MINOR=00 ;; +esac + +RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}" + +# Readline versions greater than 4.2 have these defines in readline.h + +if test $ac_cv_rl_version = '0.0' ; then + AC_MSG_WARN([Could not test version of installed readline library.]) +elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then + # set these for use by the caller + RL_PREFIX=$ac_cv_rl_prefix + RL_LIBDIR=$ac_cv_rl_libdir + RL_INCLUDEDIR=$ac_cv_rl_includedir + AC_MSG_RESULT($ac_cv_rl_version) +else + +AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library]) +AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library]) +AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library]) + +AC_SUBST(RL_VERSION) +AC_SUBST(RL_MAJOR) +AC_SUBST(RL_MINOR) + +# set these for use by the caller +RL_PREFIX=$ac_cv_rl_prefix +RL_LIBDIR=$ac_cv_rl_libdir +RL_INCLUDEDIR=$ac_cv_rl_includedir + +AC_MSG_RESULT($ac_cv_rl_version) + +fi +]) diff --git a/examples/autoconf/wi_LIB_READLINE b/examples/autoconf/wi_LIB_READLINE new file mode 100644 index 0000000..c738322 --- /dev/null +++ b/examples/autoconf/wi_LIB_READLINE @@ -0,0 +1,76 @@ +dnl Borut Razem +dnl +dnl This macro checks for the presence of the readline library. +dnl It works also in cross-compilation environment. +dnl +dnl To get it into the aclocal.m4 dnl file, do this: +dnl aclocal -I . --verbose +dnl +dnl The --verbose will show all of the files that are searched +dnl for .m4 macros. + +AC_DEFUN([wi_LIB_READLINE], [ + dnl check for the readline.h header file + + AC_CHECK_HEADER(readline/readline.h) + + if test "$ac_cv_header_readline_readline_h" = yes; then + dnl check the readline version + + cat > conftest.$ac_ext <<EOF +#include <stdio.h> +#include <readline/readline.h> +wi_LIB_READLINE_VERSION RL_VERSION_MAJOR RL_VERSION_MINOR +EOF + + wi_READLINE_VERSION=$($CPP $CPPFLAGS conftest.$ac_ext | sed -n -e "s/^wi_LIB_READLINE_VERSION *\([[0-9\]][[0-9\]]*\) *\([[0-9\]][[0-9\]]*\)$/\1.\2/p") + rm -rf conftest* + + if test -n "$wi_READLINE_VERSION"; then + wi_MAJOR=$(expr $wi_READLINE_VERSION : '\([[0-9]][[0-9]]*\)\.') + wi_MINOR=$(expr $wi_READLINE_VERSION : '[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*$\)') + if test $wi_MINOR -lt 10; then + wi_MINOR=$(expr $wi_MINOR \* 10) + fi + wi_READLINE_VERSION=$(expr $wi_MAJOR \* 100 + $wi_MINOR) + else + wi_READLINE_VERSION=-1 + fi + + dnl check for the readline library + + ac_save_LIBS="$LIBS" + # Note: $LIBCURSES is permitted to be empty. + + for LIBREADLINE in "-lreadline.dll" "-lreadline" "-lreadline $LIBCURSES" "-lreadline -ltermcap" "-lreadline -lncurses" "-lreadline -lcurses" + do + AC_MSG_CHECKING([for GNU Readline library $LIBREADLINE]) + + LIBS="$ac_save_LIBS $LIBREADLINE" + + AC_TRY_LINK([ + /* includes */ + #include <stdio.h> + #include <readline/readline.h> + ],[ + /* function-body */ + int dummy = rl_completion_append_character; /* rl_completion_append_character appeared in version 2.1 */ + readline(NULL); + ],[ + wi_cv_lib_readline=yes + AC_MSG_RESULT(yes) + ],[ + wi_cv_lib_readline=no + AC_MSG_RESULT(no) + ]) + + if test "$wi_cv_lib_readline" = yes; then + AC_SUBST(LIBREADLINE) + AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, $wi_READLINE_VERSION, [Readline]) + break + fi + done + + LIBS="$ac_save_LIBS" + fi +]) diff --git a/examples/fileman.c b/examples/fileman.c index 340eee7..f7eed8a 100644 --- a/examples/fileman.c +++ b/examples/fileman.c @@ -1,22 +1,23 @@ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* fileman.c - file manager example for readline library. */ - This file is part of the GNU Readline Library, a library for +/* Copyright (C) 1987-2009 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. - The GNU Readline Library 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 + 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. - The GNU Readline Library 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 + 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. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ /* fileman.c -- A tiny application which demonstrates how to use the GNU Readline library. This application interactively allows users @@ -50,6 +51,8 @@ # include <stdlib.h> #endif +#include <time.h> + #ifdef READLINE_LIBRARY # include "readline.h" # include "history.h" @@ -58,7 +61,7 @@ # include <readline/history.h> #endif -extern char *xmalloc (); +extern char *xmalloc PARAMS((size_t)); /* The names of functions that actually do the manipulation. */ int com_list PARAMS((char *)); diff --git a/examples/histexamp.c b/examples/histexamp.c index 4f059c1..3b43674 100644 --- a/examples/histexamp.c +++ b/examples/histexamp.c @@ -1,22 +1,23 @@ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* histexamp.c - history library example program. */ - This file is part of the GNU Readline Library, a library for +/* Copyright (C) 1987-2009 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. - The GNU Readline Library 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 + 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. - The GNU Readline Library 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 + 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. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #include <stdio.h> diff --git a/examples/manexamp.c b/examples/manexamp.c index 9c6cf2c..351c628 100644 --- a/examples/manexamp.c +++ b/examples/manexamp.c @@ -1,24 +1,23 @@ /* manexamp.c -- The examples which appear in the documentation are here. */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library 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 + 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. - The GNU Readline Library 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 + 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. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #include <stdio.h> #include <readline/readline.h> diff --git a/examples/readlinebuf.h b/examples/readlinebuf.h index a8af52c..c8f3a7b 100644 --- a/examples/readlinebuf.h +++ b/examples/readlinebuf.h @@ -8,7 +8,7 @@ * * 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 of the License, or + * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/examples/rl.c b/examples/rl.c index c608c15..845a4b1 100644 --- a/examples/rl.c +++ b/examples/rl.c @@ -5,25 +5,24 @@ * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars] */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library 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 + 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. - The GNU Readline Library 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 + 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. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> diff --git a/examples/rlcat.c b/examples/rlcat.c index 33aea4a..fa9e06f 100644 --- a/examples/rlcat.c +++ b/examples/rlcat.c @@ -4,25 +4,24 @@ * usage: rlcat */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library 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 + 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. - The GNU Readline Library 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 + 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. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> diff --git a/examples/rlevent.c b/examples/rlevent.c new file mode 100644 index 0000000..77f1887 --- /dev/null +++ b/examples/rlevent.c @@ -0,0 +1,166 @@ +/* + * 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] [-n nchars] + */ + +/* Copyright (C) 1987-2009 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/>. +*/ + +#if defined (HAVE_CONFIG_H) +# include <config.h> +#endif + +#include <stdio.h> +#include <sys/types.h> + +#ifdef HAVE_STDLIB_H +# include <stdlib.h> +#else +extern void exit(); +#endif + +#if defined (READLINE_LIBRARY) +# include "posixstat.h" +# include "readline.h" +# include "history.h" +#else +# include <sys/stat.h> +# include <readline/readline.h> +# include <readline/history.h> +#endif + +extern int optind; +extern char *optarg; + +#if !defined (strchr) && !defined (__STDC__) +extern char *strrchr(); +#endif + +static char *progname; +static char *deftext; + +static int +event_hook () +{ + fprintf (stderr, "ding!\n"); + sleep (1); + return 0; +} + +static int +set_deftext () +{ + if (deftext) + { + rl_insert_text (deftext); + deftext = (char *)NULL; + rl_startup_hook = (rl_hook_func_t *)NULL; + } + return 0; +} + +static void +usage() +{ + 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, nch; + FILE *ifp; + + progname = strrchr(argv[0], '/'); + if (progname == 0) + progname = argv[0]; + else + progname++; + + /* defaults */ + prompt = "readline$ "; + fd = nch = 0; + deftext = (char *)0; + + while ((opt = getopt(argc, argv, "p:u:d:n:")) != EOF) + { + switch (opt) + { + case 'p': + prompt = optarg; + break; + case 'u': + fd = atoi(optarg); + if (fd < 0) + { + fprintf (stderr, "%s: bad file descriptor `%s'\n", progname, optarg); + exit (2); + } + break; + 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); + } + } + + if (fd != 0) + { + if (fstat (fd, &sb) < 0) + { + fprintf (stderr, "%s: %d: bad file descriptor\n", progname, fd); + exit (1); + } + ifp = fdopen (fd, "r"); + rl_instream = ifp; + } + + if (deftext && *deftext) + rl_startup_hook = set_deftext; + + if (nch > 0) + rl_num_chars_to_read = nch; + + rl_event_hook = event_hook; + temp = readline (prompt); + + /* Test for EOF. */ + if (temp == 0) + exit (1); + + printf ("%s\n", temp); + exit (0); +} diff --git a/examples/rlfe/Makefile.in b/examples/rlfe/Makefile.in index 70aa6b3..1b49ab9 100644 --- a/examples/rlfe/Makefile.in +++ b/examples/rlfe/Makefile.in @@ -25,7 +25,7 @@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ #LDFLAGS = -L$(READLINE_DIR) LDFLAGS = @LDFLAGS@ -LIBS = -lreadline -lhistory -lncurses @LIBS@ +LIBS = -lreadline -lhistory @LIBS@ CPP=@CPP@ CPP_DEPEND=$(CC) -MM diff --git a/examples/rlfe/config.h.in b/examples/rlfe/config.h.in index 587cee2..ad546b8 100644 --- a/examples/rlfe/config.h.in +++ b/examples/rlfe/config.h.in @@ -373,3 +373,7 @@ #undef PTYRANGE1 #define USEVARARGS + +#undef HAVE_SYS_STROPTS_H + +#undef HAVE_SYS_WAIT_H diff --git a/examples/rlfe/configure.in b/examples/rlfe/configure.in index ad68541..533f9dc 100644 --- a/examples/rlfe/configure.in +++ b/examples/rlfe/configure.in @@ -435,4 +435,6 @@ main() fi +AC_CHECK_HEADERS(sys/stropts.h sys/wait.h) + AC_OUTPUT(Makefile) diff --git a/examples/rlfe/extern.h b/examples/rlfe/extern.h index 37d4275..2fe5025 100644 --- a/examples/rlfe/extern.h +++ b/examples/rlfe/extern.h @@ -27,7 +27,14 @@ #define __attribute__(x) #endif +#if !defined (__P) +# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) +# define __P(protos) protos +# else +# define __P(protos) () +# endif +#endif + /* pty.c */ extern int OpenPTY __P((char **)); extern void InitPTY __P((int)); - diff --git a/examples/rlfe/pty.c b/examples/rlfe/pty.c index f89d44c..5562720 100644 --- a/examples/rlfe/pty.c +++ b/examples/rlfe/pty.c @@ -20,13 +20,15 @@ * **************************************************************** */ +#include "config.h" #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> -#include "config.h" +#include <unistd.h> + #include "screen.h" #ifndef sun @@ -34,7 +36,7 @@ #endif /* for solaris 2.1, Unixware (SVR4.2) and possibly others */ -#ifdef HAVE_SVR4_PTYS +#if defined (HAVE_SVR4_PTYS) && defined (HAVE_SYS_STROPTS_H) # include <sys/stropts.h> #endif @@ -384,4 +386,3 @@ char **ttyn; return -1; } #endif - diff --git a/examples/rlfe/rlfe.c b/examples/rlfe/rlfe.c index 6d747dc..eacd5ab 100644 --- a/examples/rlfe/rlfe.c +++ b/examples/rlfe/rlfe.c @@ -73,6 +73,11 @@ #include <termios.h> #include "config.h" +#include "extern.h" + +#if defined (HAVE_SYS_WAIT_H) +# include <sys/wait.h> +#endif #ifdef READLINE_LIBRARY # include "readline.h" @@ -588,7 +593,7 @@ main(int argc, char** argv) } if (FD_ISSET (in_from_tty_fd, &in_set)) { - extern int readline_echoing_p; + extern int _rl_echoing_p; struct termios term_master; int do_canon = 1; int do_icrnl = 1; @@ -605,9 +610,9 @@ main(int argc, char** argv) { do_canon = (term_master.c_lflag & ICANON) != 0; do_icrnl = (term_master.c_lflag & ICRNL) != 0; - readline_echoing_p = (term_master.c_lflag & ECHO) != 0; + _rl_echoing_p = (term_master.c_lflag & ECHO) != 0; DPRINT1 ("echo,canon,crnl:%03d\n", - 100 * readline_echoing_p + 100 * _rl_echoing_p + 10 * do_canon + 1 * do_icrnl); } @@ -757,7 +762,7 @@ static void set_edit_mode () vi = 1; break; } - shellopts = index (shellopts + 1, ':'); + shellopts = strchr (shellopts + 1, ':'); } if (!vi) diff --git a/examples/rltest.c b/examples/rltest.c index cb67bab..78e2608 100644 --- a/examples/rltest.c +++ b/examples/rltest.c @@ -4,25 +4,24 @@ /* */ /* **************************************************************** */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library 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 + 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. - The GNU Readline Library 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 + 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. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) #include <config.h> diff --git a/examples/rlversion.c b/examples/rlversion.c index 6c86874..88f4cd7 100644 --- a/examples/rlversion.c +++ b/examples/rlversion.c @@ -2,25 +2,24 @@ * rlversion -- print out readline's version number */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009 Free Software Foundation, Inc. - This file is part of the GNU Readline Library, a library for + This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. - The GNU Readline Library 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 + 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. - The GNU Readline Library 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 + 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. - The GNU General Public License is often shipped with GNU software, and - is generally kept in a file called COPYING or LICENSE. If you do not - have a copy of the license, write to the Free Software Foundation, - 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ + You should have received a copy of the GNU General Public License + along with Readline. If not, see <http://www.gnu.org/licenses/>. +*/ #if defined (HAVE_CONFIG_H) # include <config.h> diff --git a/examples/rlwrap-0.30.tar.gz b/examples/rlwrap-0.30.tar.gz Binary files differnew file mode 100644 index 0000000..73381a2 --- /dev/null +++ b/examples/rlwrap-0.30.tar.gz |