diff --git a/contrib/libreadline/CHANGELOG b/contrib/libreadline/CHANGELOG new file mode 100644 index 000000000000..8094590945c4 --- /dev/null +++ b/contrib/libreadline/CHANGELOG @@ -0,0 +1,77 @@ +[Readline-specific changelog. Descriptions of changes to the source are + found in the bash changelog.] + + 6/9 + --- +Makefile.in + - quote value of ${INSTALL_DATA} when passing it to makes in + subdirectories + + 7/1 + --- +Makefile.in + - don't pass INSTALL_DATA to a make in the `doc' subdirectory; let + autoconf set the value itself in the Makefile + - removed a stray `-' before $(RANLIB) in the `install' recipe + +doc/Makefile.in + - add a VPATH assignment so the documentation is not remade if it's + already up-to-date in the distribution + +configure.in + - call AC_SUBST(LOCAL_LDFLAGS), since Makefile.in contains + @LOCAL_LDFLAGS@ + + 7/9 + --- + +config.h.in + - add define lines for STRUCT_WINSIZE_IN_SYS_IOCTL and + STRUCT_WINSIZE_IN_TERMIOS + +configure.in + - call BASH_STRUCT_WINSIZE to look for the definition of + `struct winsize' + + 7/17 + ---- +configure.in + - call AC_MINIX + +config.h.in + - add define line for AC_MINIX + + 7/18 + ---- +Makefile.in + - add `install-shared' and `uninstall-shared' targets + + 8/4 + --- +Makefile.in + - install and uninstall libhistory.a in the `install' and + `uninstall' targets + + 9/4 + --- +configure.in + - bumped LIBVERSION up to 2.1.1, indicating that this is patch + level 1 to release 2.1 + + + 9/16 + ---- +Makefile.in + - `make distclean' now descends into the `examples' subdir + +doc/Makefile.in + - the `distclean' and `maintainer-clean' targets should remove + Makefile + +examples/Makefile.in + - added the various clean targets + + 4/2 + --- +configure.in + - bumped LIBVERSION up to 2.2 diff --git a/contrib/libreadline/CHANGES b/contrib/libreadline/CHANGES new file mode 100644 index 000000000000..29122f99e12a --- /dev/null +++ b/contrib/libreadline/CHANGES @@ -0,0 +1,66 @@ +This document details the changes between this version, readline-2.2, +and the previous version, readline-2.1. + +1. Changes to Readline + +a. Added a missing `extern' to a declaration in readline.h that kept + readline from compiling cleanly on some systems. + +b. The history file is now opened with mode 0600 when it is written for + better security. + +c. Changes were made to the SIGWINCH handling code so that prompt redisplay + is done better. + +d. ^G now interrupts incremental searches correctly. + +e. A bug that caused a core dump when the set of characters to be quoted + when completing words was empty was fixed. + +f. Fixed a problem in the readline test program rltest.c that caused a core + dump. + +g. The code that handles parser directives in inputrc files now displays + more error messages. + +h. The history expansion code was fixed so that the appearance of the + history comment character at the beginning of a word inhibits history + expansion for that word and the rest of the input line. + +i. The code that prints completion listings now behaves better if one or + more of the filenames contains non-printable characters. + +j. The time delay when showing matching parentheses is now 0.5 seconds. + + +2. New Features in Readline + +a. There is now an option for `iterative' yank-last-arg handline, so a user + can keep entering `M-.', yanking the last argument of successive history + lines. + +b. New variable, `print-completions-horizontally', which causes completion + matches to be displayed across the screen (like `ls -x') rather than up + and down the screen (like `ls'). + +c. New variable, `completion-ignore-case', which causes filename completion + and matching to be performed case-insensitively. + +d. There is a new bindable command, `magic-space', which causes history + expansion to be performed on the current readline buffer and a space to + be inserted into the result. + +e. There is a new bindable command, `menu-complete', which enables tcsh-like + menu completion (successive executions of menu-complete insert a single + completion match, cycling through the list of possible completions). + +f. There is a new bindable command, `paste-from-clipboard', for use on Win32 + systems, to insert the text from the Win32 clipboard into the editing + buffer. + +g. The key sequence translation code now understands printf-style backslash + escape sequences, including \NNN octal escapes. These escape sequences + may be used in key sequence definitions or macro values. + +h. An `$include' inputrc file parser directive has been added. + diff --git a/contrib/libreadline/MANIFEST b/contrib/libreadline/MANIFEST index 5e68586f1aab..e9e1c4005f98 100644 --- a/contrib/libreadline/MANIFEST +++ b/contrib/libreadline/MANIFEST @@ -8,13 +8,14 @@ COPYING f README f MANIFEST f INSTALL f +CHANGELOG f +CHANGES f aclocal.m4 f acconfig.h f config.h.in f configure f configure.in f Makefile.in f -ChangeLog f ansi_stdlib.h f chardefs.h f history.h f @@ -27,6 +28,7 @@ readline.h f rlconf.h f rldefs.h f rltty.h f +rlwinsize.h f tcap.h f tilde.h f bind.c f diff --git a/contrib/libreadline/MANIFEST.doc b/contrib/libreadline/MANIFEST.doc new file mode 100644 index 000000000000..ed27cb391074 --- /dev/null +++ b/contrib/libreadline/MANIFEST.doc @@ -0,0 +1,16 @@ +# +# Master Manifest file for documentation-only distribution +# +doc d +MANIFEST.doc f +doc/readline.ps f +doc/history.ps f +doc/readline.dvi f +doc/history.dvi f +doc/readline.info f +doc/history.info f +doc/readline.html f +doc/readline_toc.html f +doc/history.html f +doc/history_toc.html f +doc/readline.0 f diff --git a/contrib/libreadline/Makefile.in b/contrib/libreadline/Makefile.in index 3d2c68fcedc8..f4db3bb430f0 100644 --- a/contrib/libreadline/Makefile.in +++ b/contrib/libreadline/Makefile.in @@ -21,7 +21,7 @@ RL_LIBRARY_NAME = readline srcdir = @srcdir@ VPATH = .:@srcdir@ top_srcdir = @top_srcdir@ -BUILD_DIR = . +BUILD_DIR = @BUILD_DIR@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -88,6 +88,8 @@ MINOR= .0 # The name of the main library target. LIBRARY_NAME = libreadline.a +STATIC_LIBS = libreadline.a libhistory.a + SHARED_READLINE = libreadline.so.$(MAJOR)$(MINOR) SHARED_HISTORY = libhistory.so.$(MAJOR)$(MINOR) SHARED_LIBS = $(SHARED_READLINE) $(SHARED_HISTORY) @@ -130,12 +132,17 @@ DOCSUPPORT = doc/Makefile DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT) CREATED_MAKEFILES = Makefile doc/Makefile examples/Makefile +CREATED_CONFIGURE = config.status config.h config.cache config.log \ + stamp-config stamp-h +CREATED_TAGS = TAGS tags INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h ########################################################################## -all: libreadline.a libhistory.a +all: static + +static: $(STATIC_LIBS) shared: $(SHARED_LIBS) libreadline.a: $(OBJECTS) @@ -183,6 +190,10 @@ documentation: force -test -d doc || mkdir doc -( cd doc && $(MAKE) $(MFLAGS) ) +examples: force + -test -d examples || mkdir examples + -(cd examples && ${MAKE} ${MFLAGS} all ) + force: install: installdirs libreadline.a @@ -191,10 +202,13 @@ install: installdirs libreadline.a done -$(MV) $(libdir)/libreadline.a $(libdir)/libreadline.old $(INSTALL_DATA) libreadline.a $(libdir)/libreadline.a - -test -n "$(RANLIB)" && -$(RANLIB) -t $(libdir)/libreadline.a + -test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libreadline.a + -$(MV) $(libdir)/libreadline.a $(libdir)/libhistory.old + $(INSTALL_DATA) libhistory.a $(libdir)/libhistory.a + -test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libhistory.a -( if test -d doc ; then \ cd doc && \ - ${MAKE} ${MFLAGS} infodir=$(infodir) INSTALL_DATA=$(INSTALL_DATA) $@; \ + ${MAKE} ${MFLAGS} infodir=$(infodir) $@; \ fi ) installdirs: $(srcdir)/support/mkdirs @@ -205,7 +219,16 @@ uninstall: -test -n "$(includedir)" && cd $(includedir)/readline && \ ${RM} ${INSTALLED_HEADERS} -test -n "$(libdir)" && cd $(libdir) && \ - ${RM} libreadline.a libreadline.old $(SHARED_LIBS) + ${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS) + +install-shared: installdirs shared + -$(MV) $(libdir)/$(SHARED_HISTORY) $(libdir)/$(SHARED_HISTORY).old + $(INSTALL_DATA) $(SHARED_HISTORY) $(libdir)/$(SHARED_HISTORY) + -$(MV) $(libdir)/$(SHARED_READLINE) $(libdir)/$(SHARED_READLINE).old + $(INSTALL_DATA) $(SHARED_READLINE) $(libdir)/$(SHARED_READLINE) + +uninstall-shared: + -test -n "$(libdir)" && cd $(libdir) && ${RM} ${SHARED_LIBS} TAGS: force $(ETAGS) $(CSOURCES) $(HSOURCES) @@ -214,19 +237,21 @@ tags: force $(CTAGS) $(CSOURCES) $(HSOURCES) clean: force - $(RM) $(OBJECTS) *.a + $(RM) $(OBJECTS) $(STATIC_LIBS) $(RM) $(SHARED_OBJ) $(SHARED_LIBS) -( cd doc && $(MAKE) $(MFLAGS) $@ ) + -( cd examples && $(MAKE) $(MFLAGS) $@ ) mostlyclean: clean -( cd doc && $(MAKE) $(MFLAGS) $@ ) + -( cd examples && $(MAKE) $(MFLAGS) $@ ) distclean maintainer-clean: clean -( cd doc && $(MAKE) $(MFLAGS) $@ ) + -( cd examples && $(MAKE) $(MFLAGS) $@ ) $(RM) Makefile - $(RM) config.status config.h config.cache config.log - $(RM) stamp-config stamp-h - $(RM) TAGS tags + $(RM) $(CREATED_CONFIGURE) + $(RM) $(CREATED_TAGS) info dvi: -( cd doc && $(MAKE) $(MFLAGS) $@ ) @@ -310,6 +335,8 @@ rltty.o: readline.h keymaps.h chardefs.h tilde.h search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h search.o: readline.h keymaps.h chardefs.h tilde.h search.o: ansi_stdlib.h history.h +shell.o: ${BUILD_DIR}/config.h +shell.o: ansi_stdlib.h signals.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h signals.o: readline.h keymaps.h chardefs.h tilde.h signals.o: history.h @@ -333,6 +360,34 @@ vi_mode.o: history.h ansi_stdlib.h xmalloc.o: ${BUILD_DIR}/config.h xmalloc.o: ansi_stdlib.h +readline.o: $(srcdir)/readline.c +vi_mode.o: $(srcdir)/vi_mode.c +funmap.o: $(srcdir)/funmap.c +keymaps.o: $(srcdir)/keymaps.c +parens.o: $(srcdir)/parens.c +search.o: $(srcdir)/search.c +rltty.o: $(srcdir)/rltty.c +complete.o: $(srcdir)/complete.c +bind.o: $(srcdir)/bind.c +isearch.o: $(srcdir)/isearch.c +display.o: $(srcdir)/display.c +signals.o: $(srcdir)/signals.c +util.o: $(srcdir)/util.c +kill.o: $(srcdir)/kill.c +undo.o: $(srcdir)/undo.c +macro.o: $(srcdir)/macro.c +input.o: $(srcdir)/input.c +callback.o: $(srcdir)/callback.c +terminal.o: $(srcdir)/terminal.c +nls.o: $(srcdir)/nls.c +xmalloc.o: $(srcdir)/xmalloc.c +history.o: $(srcdir)/history.c +histexpand.o: $(srcdir)/histexpand.c +histfile.o: $(srcdir)/histfile.c +histsearch.o: $(srcdir)/histsearch.c +shell.o: $(srcdir)/shell.c +tilde.o: $(srcdir)/tilde.c + bind.so: ansi_stdlib.h posixstat.h bind.so: rldefs.h ${BUILD_DIR}/config.h rlconf.h bind.so: readline.h keymaps.h chardefs.h tilde.h @@ -419,6 +474,34 @@ vi_mode.so: history.h ansi_stdlib.h xmalloc.so: ${BUILD_DIR}/config.h xmalloc.so: ansi_stdlib.h +readline.o: readline.c +vi_mode.o: vi_mode.c +funmap.o: funmap.c +keymaps.o: keymaps.c +parens.o: parens.c +search.o: search.c +rltty.o: rltty.c +complete.o: complete.c +bind.o: bind.c +isearch.o: isearch.c +display.o: display.c +signals.o: signals.c +util.o: util.c +kill.o: kill.c +undo.o: undo.c +macro.o: macro.c +input.o: input.c +callback.o: callback.c +terminal.o: terminal.c +nls.o: nls.c +xmalloc.o: xmalloc.c +history.o: history.c +histexpand.o: histexpand.c +histfile.o: histfile.c +histsearch.o: histsearch.c +shell.o: shell.c +tilde.o: tilde.c + readline.so: $(srcdir)/readline.c vi_mode.so: $(srcdir)/vi_mode.c funmap.so: $(srcdir)/funmap.c @@ -446,3 +529,31 @@ histfile.so: $(srcdir)/histfile.c histsearch.so: $(srcdir)/histsearch.c shell.so: $(srcdir)/shell.c tilde.so: $(srcdir)/tilde.c + +readline.so: readline.c +vi_mode.so: vi_mode.c +funmap.so: funmap.c +keymaps.so: keymaps.c +parens.so: parens.c +search.so: search.c +rltty.so: rltty.c +complete.so: complete.c +bind.so: bind.c +isearch.so: isearch.c +display.so: display.c +signals.so: signals.c +util.so: util.c +kill.so: kill.c +undo.so: undo.c +macro.so: macro.c +input.so: input.c +callback.so: callback.c +terminal.so: terminal.c +nls.so: nls.c +xmalloc.so: xmalloc.c +history.so: history.c +histexpand.so: histexpand.c +histfile.so: histfile.c +histsearch.so: histsearch.c +shell.so: shell.c +tilde.so: tilde.c diff --git a/contrib/libreadline/README b/contrib/libreadline/README index e14aee8bef2f..f19f92560a57 100644 --- a/contrib/libreadline/README +++ b/contrib/libreadline/README @@ -1,7 +1,7 @@ Introduction ============ -This is the Gnu Readline library, version 2.1. +This is the Gnu Readline library, version 2.2 The Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both @@ -89,11 +89,11 @@ Reporting Bugs Bug reports for Readline should be sent to: - bug-readline@prep.ai.mit.edu + bug-readline@gnu.org When reporting a bug, please include the following information: - * the version number and release status of Readline (e.g., 2.1-release) + * the version number and release status of Readline (e.g., 2.2-release) * the machine and OS that it is running on * a list of the compilation flags or the contents of `config.h', if appropriate @@ -102,11 +102,11 @@ When reporting a bug, please include the following information: * a fix for the bug if you have one! If you would like to contact the Readline maintainer directly, send mail -to bash-maintainers@prep.ai.mit.edu. +to bash-maintainers@gnu.org. -Since Readline is developed along with bash, the bug-bash@prep.ai.mit.edu -mailing list (mirrored to the Usenet newsgroup gnu.bash.bug) often contains -Readline bug reports and fixes. +Since Readline is developed along with bash, the bug-bash@gnu.org mailing +list (mirrored to the Usenet newsgroup gnu.bash.bug) often contains +Readline bug reports and fixes. Chet Ramey chet@po.cwru.edu diff --git a/contrib/libreadline/aclocal.m4 b/contrib/libreadline/aclocal.m4 index b852ac0239ed..822ead0ee84a 100644 --- a/contrib/libreadline/aclocal.m4 +++ b/contrib/libreadline/aclocal.m4 @@ -26,7 +26,8 @@ main() exit(fl != 1); } ], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no, - AC_MSG_ERROR(cannot check dup2 if cross compiling)) + [AC_MSG_ERROR(cannot check dup2 if cross compiling -- defaulting to no) + bash_cv_dup2_broken=no]) ]) AC_MSG_RESULT($bash_cv_dup2_broken) if test $bash_cv_dup2_broken = yes; then @@ -128,7 +129,8 @@ main() exit(ok ? 0 : 5); } ], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, - AC_MSG_ERROR(cannot check pgrp synchronization if cross compiling)) + [AC_MSG_ERROR(cannot check pgrp synchronization if cross compiling -- defaulting to no) + bash_cv_pgrp_pipe=no]) ]) AC_MSG_RESULT($bash_cv_pgrp_pipe) if test $bash_cv_pgrp_pipe = yes; then @@ -169,7 +171,8 @@ dnl AC_DEFUN(BASH_RLIMIT_TYPE, [AC_MSG_CHECKING(for size and type of struct rlimit fields) AC_CACHE_VAL(bash_cv_type_rlimit, -[AC_TRY_COMPILE([#include ], +[AC_TRY_COMPILE([#include +#include ], [rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[ AC_TRY_RUN([ #include @@ -184,7 +187,8 @@ main() #endif exit(1); }], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long, - AC_MSG_ERROR(cannot check quad_t if cross compiling))]) + [AC_MSG_ERROR(cannot check quad_t if cross compiling -- defaulting to long) + bash_cv_type_rlimit=long])]) ]) AC_MSG_RESULT($bash_cv_type_rlimit) if test $bash_cv_type_rlimit = quad_t; then @@ -197,8 +201,26 @@ fi dnl dnl Check for sys_siglist[] or _sys_siglist[] dnl +AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST, +[AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h]) +AC_CACHE_VAL(bash_cv_decl_under_sys_siglist, +[AC_TRY_COMPILE([ +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif], [ char *msg = _sys_siglist[2]; ], + bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no, + [AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl +AC_MSG_RESULT($bash_cv_decl_under_sys_siglist) +if test $bash_cv_decl_under_sys_siglist = yes; then +AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED) +fi +]) + AC_DEFUN(BASH_UNDER_SYS_SIGLIST, -[AC_MSG_CHECKING([for _sys_siglist in system C library]) +[AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST]) +AC_MSG_CHECKING([for _sys_siglist in system C library]) AC_CACHE_VAL(bash_cv_under_sys_siglist, [AC_TRY_RUN([ #include @@ -206,16 +228,17 @@ AC_CACHE_VAL(bash_cv_under_sys_siglist, #ifdef HAVE_UNISTD_H #include #endif -#ifndef _sys_siglist +#ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif main() { -char *msg = _sys_siglist[2]; +char *msg = (char *)_sys_siglist[2]; exit(msg == 0); }], -bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no, -AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling))])dnl + bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no, + [AC_MSG_ERROR(cannot check for _sys_siglist[] if cross compiling -- defaulting to no) + bash_cv_under_sys_siglist=no])]) AC_MSG_RESULT($bash_cv_under_sys_siglist) if test $bash_cv_under_sys_siglist = yes; then AC_DEFINE(HAVE_UNDER_SYS_SIGLIST) @@ -240,8 +263,9 @@ main() char *msg = sys_siglist[2]; exit(msg == 0); }], -bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no, -AC_MSG_ERROR(cannot check for sys_siglist if cross compiling))])dnl + bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no, + [AC_MSG_ERROR(cannot check for sys_siglist if cross compiling -- defaulting to no) + bash_cv_sys_siglist=no])]) AC_MSG_RESULT($bash_cv_sys_siglist) if test $bash_cv_sys_siglist = yes; then AC_DEFINE(HAVE_SYS_SIGLIST) @@ -301,7 +325,9 @@ dir = opendir("/tmp/not_a_directory"); unlink("/tmp/not_a_directory"); exit (dir == 0); }], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no, - AC_MSG_ERROR(cannot check opendir if cross compiling))]) + [AC_MSG_ERROR(cannot check opendir if cross compiling -- defaulting to no) + bash_cv_opendir_not_robust=no] +)]) AC_MSG_RESULT($bash_cv_opendir_not_robust) if test $bash_cv_opendir_not_robust = yes; then AC_DEFINE(OPENDIR_NOT_ROBUST) @@ -328,8 +354,116 @@ AC_DEFINE(VOID_SIGHANDLER) fi ]) +AC_DEFUN(BASH_TYPE_INT32_T, +[ +if test "X$bash_cv_type_int32_t" = "X"; then +_bash_needmsg=yes +else +AC_MSG_CHECKING(which builtin C type is 32 bits wide) +_bash_needmsg= +fi +AC_CACHE_VAL(bash_cv_type_int32_t, +[AC_TRY_RUN([ +main() +{ +#if SIZEOF_INT == 4 +exit (0); +#else +# if SIZEOF_LONG == 4 +exit (1); +# else +# error cannot find 32 bit type... +# endif +#endif +}], bash_cv_type_int32_t=int, bash_cv_type_int32_t=long, + [AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int) + bash_cv_type_int32_t=int] +)]) +if test "X$_bash_needmsg" = "Xyes"; then +AC_MSG_CHECKING(which builtin C type is 32 bits wide) +fi +AC_MSG_RESULT($bash_cv_type_int32_t); +if test "$bash_cv_type_int32_t" = "int"; then +AC_DEFINE(int32_t, int) +else +AC_DEFINE(int32_t, long) +fi +]) + +AC_DEFUN(BASH_TYPE_U_INT32_T, +[ +if test "X$bash_cv_type_u_int32_t" = "X"; then +_bash_needmsg=yes +else +AC_MSG_CHECKING(which unsigned builtin C type is 32 bits wide) +_bash_needmsg= +fi +AC_CACHE_VAL(bash_cv_type_u_int32_t, +[AC_TRY_RUN([ +main() +{ +#if SIZEOF_INT == 4 +exit (0); +#else +# if SIZEOF_LONG == 4 +exit (1); +# else +# error cannot find 32 bit type... +# endif +#endif +}], bash_cv_type_u_int32_t=int, bash_cv_type_u_int32_t=long, + [AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int) + bash_cv_type_u_int32_t=int] +)]) +if test "X$_bash_needmsg" = "Xyes"; then +AC_MSG_CHECKING(which unsigned builtin C type is 32 bits wide) +fi +AC_MSG_RESULT($bash_cv_type_u_int32_t); +if test "$bash_cv_type_u_int32_t" = "int"; then +AC_DEFINE(u_int32_t, unsigned int) +else +AC_DEFINE(u_int32_t, unsigned long) +fi +]) + +AC_DEFUN(BASH_TYPE_PTRDIFF_T, +[ +if test "X$bash_cv_type_ptrdiff_t" = "X"; then +_bash_needmsg=yes +else +AC_MSG_CHECKING(which builtin C type is correct for ptrdiff_t) +_bash_needmsg= +fi +AC_CACHE_VAL(bash_cv_type_ptrdiff_t, +[AC_TRY_RUN([ +main() +{ +#if SIZEOF_CHAR_P == SIZEOF_INT +exit (0); +#else +# if SIZEOF_CHAR_P == SIZEOF_LONG +exit (1); +# else +# error cannot find type for pointer arithmetic... +# endif +#endif +}], bash_cv_type_ptrdiff_t=int, bash_cv_type_ptrdiff_t=long, + [AC_MSG_ERROR(cannot check type sizes if cross-compiling -- defaulting to int) + bash_cv_type_ptrdiff_t=int] +)]) +if test "X$_bash_needmsg" = "Xyes"; then +AC_MSG_CHECKING(which builtin C type is correct for ptrdiff_t) +fi +AC_MSG_RESULT($bash_cv_type_ptrdiff_t); +if test "$bash_cv_type_ptrdiff_t" = "int"; then +AC_DEFINE(ptrdiff_t, int) +else +AC_DEFINE(ptrdiff_t, long) +fi +]) + AC_DEFUN(BASH_FUNC_STRSIGNAL, -[AC_MSG_CHECKING([for the existance of strsignal]) +[AC_MSG_CHECKING([for the existence of strsignal]) AC_CACHE_VAL(bash_cv_have_strsignal, [AC_TRY_LINK([#include #include ], @@ -348,7 +482,7 @@ AC_CACHE_CHECK([for lstat], bash_cv_func_lstat, [AC_TRY_LINK([ #include #include -],[ lstat("",(struct stat *)0); ], +],[ lstat(".",(struct stat *)0); ], bash_cv_func_lstat=yes, bash_cv_func_lstat=no)]) if test $bash_cv_func_lstat = yes; then AC_DEFINE(HAVE_LSTAT) @@ -414,7 +548,9 @@ s = getenv("ABCDE"); exit(s == 0); /* force optimizer to leave getenv in */ } ], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no, -AC_MSG_ERROR(cannot check getenv redefinition if cross compiling))]) + [AC_MSG_ERROR(cannot check getenv redefinition if cross compiling -- defaulting to yes) + bash_cv_getenv_redef=yes] +)]) AC_MSG_RESULT($bash_cv_getenv_redef) if test $bash_cv_getenv_redef = yes; then AC_DEFINE(CAN_REDEFINE_GETENV) @@ -434,11 +570,13 @@ typedef int (*_bashfunc)(); main() { _bashfunc pf; -pf = printf; +pf = (_bashfunc) printf; exit(pf == 0); } -],bash_cv_printf_declared=yes, bash_cv_printf_declared=no, -AC_MSG_ERROR(cannot check printf declaration if cross compiling))]) +], bash_cv_printf_declared=yes, bash_cv_printf_declared=no, + [AC_MSG_ERROR(cannot check printf declaration if cross compiling -- defaulting to yes) + bash_cv_printf_declared=yes] +)]) AC_MSG_RESULT($bash_cv_printf_declared) if test $bash_cv_printf_declared = yes; then AC_DEFINE(PRINTF_DECLARED) @@ -454,8 +592,10 @@ main() long maxfds = ulimit(4, 0L); exit (maxfds == -1L); } -],bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no, -AC_MSG_ERROR(cannot check ulimit if cross compiling))]) +], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no, + [AC_MSG_ERROR(cannot check ulimit if cross compiling -- defaulting to no) + bash_cv_ulimit_maxfds=no] +)]) AC_MSG_RESULT($bash_cv_ulimit_maxfds) if test $bash_cv_ulimit_maxfds = yes; then AC_DEFINE(ULIMIT_MAXFDS) @@ -479,7 +619,7 @@ 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; then +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" @@ -550,7 +690,9 @@ main() exit (popen_called); } ], bash_cv_getcwd_calls_popen=no, bash_cv_getcwd_calls_popen=yes, -AC_MSG_ERROR(cannot check whether getcwd calls popen if cross compiling))]) + [AC_MSG_ERROR(cannot check whether getcwd calls popen if cross compiling -- defaulting to no) + bash_cv_getcwd_calls_popen=no] +)]) AC_MSG_RESULT($bash_cv_getcwd_calls_popen) if test $bash_cv_getcwd_calls_popen = yes; then AC_DEFINE(GETCWD_BROKEN) @@ -672,7 +814,9 @@ main() exit(nsigint != 2); } ], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes, -AC_MSG_ERROR(cannot check signal handling if cross compiling))]) + [AC_MSG_ERROR(cannot check signal handling if cross compiling -- defaulting to no) + bash_cv_must_reinstall_sighandlers=no] +)]) AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers) if test $bash_cv_must_reinstall_sighandlers = yes; then AC_DEFINE(MUST_REINSTALL_SIGHANDLERS) @@ -738,9 +882,10 @@ exit(1); #endif exit(0); -}],bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing, - AC_MSG_ERROR(cannot check job control if cross-compiling)) -]) +}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing, + [AC_MSG_ERROR(cannot check job control if cross-compiling -- defaulting to missing) + bash_cv_job_control_missing=missing] +)]) AC_MSG_RESULT($bash_cv_job_control_missing) if test $bash_cv_job_control_missing = missing; then AC_DEFINE(JOB_CONTROL_MISSING) @@ -782,9 +927,10 @@ if (fd == -1) close(fd); unlink ("/tmp/sh-np-autoconf"); exit(0); -}],bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing, - AC_MSG_ERROR(cannot check for named pipes if cross-compiling)) -]) +}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing, + [AC_MSG_ERROR(cannot check for named pipes if cross-compiling -- defaulting to missing) + bash_cv_sys_named_pipes=missing] +)]) AC_MSG_RESULT($bash_cv_sys_named_pipes) if test $bash_cv_sys_named_pipes = missing; then AC_DEFINE(NAMED_PIPES_MISSING) @@ -832,9 +978,10 @@ sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL); siglongjmp(xx, 10); exit(1); #endif -}],bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing, - AC_MSG_ERROR(cannot check for sigsetjmp/siglongjmp if cross-compiling)) -]) +}], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing, + [AC_MSG_ERROR(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing) + bash_cv_func_sigsetjmp=missing] +)]) AC_MSG_RESULT($bash_cv_func_sigsetjmp) if test $bash_cv_func_sigsetjmp = present; then AC_DEFINE(HAVE_POSIX_SIGSETJMP) @@ -854,14 +1001,23 @@ fi ]) AC_DEFUN(BASH_STRUCT_WINSIZE, -[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h) -AC_CACHE_VAL(bash_cv_struct_winsize_in_ioctl, +[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h) +AC_CACHE_VAL(bash_cv_struct_winsize_header, [AC_TRY_COMPILE([#include #include ], [struct winsize x;], - bash_cv_struct_winsize_in_ioctl=yes,bash_cv_struct_winsize_in_ioctl=no)]) -AC_MSG_RESULT($bash_cv_struct_winsize_in_ioctl) -if test $bash_cv_struct_winsize_in_ioctl = yes; then -AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL) + bash_cv_struct_winsize_header=ioctl_h, + [AC_TRY_COMPILE([#include +#include ], [struct winsize x;], + bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other) +])]) +if test $bash_cv_struct_winsize_header = ioctl_h; then + AC_MSG_RESULT(sys/ioctl.h) + AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL) +elif test $bash_cv_struct_winsize_header = termios_h; then + AC_MSG_RESULT(termios.h) + AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS) +else + AC_MSG_RESULT(not found) fi ]) @@ -911,7 +1067,10 @@ AC_DEFUN(BASH_CHECK_GETPW_FUNCS, AC_CACHE_VAL(bash_cv_can_redecl_getpw, [AC_TRY_COMPILE([#include #include -extern struct passwd *getpwent();], [struct passwd *z; z = getpwent();], +extern struct passwd *getpwent(); +extern struct passwd *getpwuid(); +extern struct passwd *getpwnam();], +[struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");], bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)]) AC_MSG_RESULT($bash_cv_can_redecl_getpw) if test $bash_cv_can_redecl_getpw = no; then @@ -994,10 +1153,10 @@ AC_CACHE_VAL(bash_cv_mail_dir, bash_cv_mail_dir=/var/mail elif test -d /usr/mail; then bash_cv_mail_dir=/usr/mail - elif test -d /usr/spool/mail; then - bash_cv_mail_dir=/usr/spool/mail elif test -d /var/spool/mail; then bash_cv_mail_dir=/var/spool/mail + elif test -d /usr/spool/mail; then + bash_cv_mail_dir=/usr/spool/mail else bash_cv_mail_dir=unknown fi @@ -1030,16 +1189,16 @@ AC_CACHE_VAL(bash_cv_kernel_rlimit, int f; f = RLIMIT_DATA; ], bash_cv_kernel_rlimit=no, - [AC_TRY_COMPILE([ - #include - #define _KERNEL - #include - #undef _KERNEL - ], - [ +[AC_TRY_COMPILE([ +#include +#define _KERNEL +#include +#undef _KERNEL +], +[ int f; f = RLIMIT_DATA; - ], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)] +], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)] )]) AC_MSG_RESULT($bash_cv_kernel_rlimit) if test $bash_cv_kernel_rlimit = yes; then @@ -1087,10 +1246,99 @@ char *v[]; exit (r1 > 0 && r2 > 0); } ], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no, - AC_MSG_ERROR(cannot check strcoll if cross compiling)) -]) + [AC_MSG_ERROR(cannot check strcoll if cross compiling -- defaulting to no) + bash_cv_func_strcoll_broken=no] +)]) AC_MSG_RESULT($bash_cv_func_strcoll_broken) if test $bash_cv_func_strcoll_broken = yes; then AC_DEFINE(STRCOLL_BROKEN) fi ]) + +dnl +dnl If available, use support for large files unless the user specified +dnl one of the CPPFLAGS, LDFLAGS, or LIBS variables ( +dnl via GNU patch 2.5) +dnl +AC_DEFUN(BASH_LARGE_FILE_SUPPORT, +[AC_MSG_CHECKING(whether large file support needs explicit enabling) +ac_getconfs='' +ac_result=yes +ac_set='' +ac_shellvars='CPPFLAGS LDFLAGS LIBS' +for ac_shellvar in $ac_shellvars; do + case $ac_shellvar in + CPPFLAGS) ac_lfsvar=LFS_CFLAGS ac_lfs64var=LFS64_CFLAGS ;; + *) ac_lfsvar=LFS_$ac_shellvar ac_lfs64var=LFS64_$ac_shellvar ;; + esac + eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar + (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; } + ac_getconf=`getconf $ac_lfsvar` + ac_getconf64=`getconf $ac_lfs64var` + ac_getconfs=$ac_getconfs$ac_getconf\ $ac_getconf64 + eval ac_test_$ac_shellvar="\$ac_getconf\ \$ac_getconf64" +done +case "$ac_result$ac_getconfs" in +yes) ac_result=no ;; +esac +case "$ac_result$ac_set" in +yes?*) ac_result="yes, but $ac_set is already set, so use its settings" +esac +AC_MSG_RESULT($ac_result) +case $ac_result in +yes) + for ac_shellvar in $ac_shellvars; do + eval $ac_shellvar=\$ac_test_$ac_shellvar + done ;; +esac +]) + +dnl +dnl AC_SYS_RESTARTABLE_SYSCALLS tests only for restarted system calls +dnl after a signal handler has been installed with signal(). Since +dnl Bash uses sigaction() if it is available, we need to check whether +dnl or not a signal handler installed with sigaction and SA_RESTART +dnl causes system calls to be restarted after the signal is caught +dnl +AC_DEFUN(BASH_SYS_RESTARTABLE_SYSCALLS, +[AC_REQUIRE([BASH_SIGNAL_CHECK]) +AC_CACHE_CHECK(for restartable system calls with posix sigaction, +bash_cv_sys_restartable_syscalls, +[AC_TRY_RUN( +[/* Exit 0 (true) if wait returns something other than -1, + i.e. the pid of the child, which means that wait was restarted + after getting the signal. */ +#include +#include +static int caught = 0; +void ucatch (isig) int isig; { caught = 1; } +main () +{ +#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) + exit (1); +#else + struct sigaction act, oact; + int i, status; + + act.sa_handler = ucatch; + /* Might want to add SA_RESTART here, but bash's set_signal_handler + does not. */ + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigemptyset(&oact.sa_mask); + i = fork (); + /* A possible race condition here, but in practice it never happens. */ + if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); } + sigaction(SIGINT, &act, &oact); + status = wait(&i); + if (status == -1) wait(&i); + exit (status == -1); +#endif +} +], bash_cv_sys_restartable_syscalls=yes, bash_cv_sys_restartable_syscalls=no, + AC_MSG_ERROR(cannot check restartable syscalls if cross compiling)) +]) +if test $bash_cv_sys_restartable_syscalls = yes; then + AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS) +fi +]) diff --git a/contrib/libreadline/bind.c b/contrib/libreadline/bind.c index 24c8c48c7008..300530a0781f 100644 --- a/contrib/libreadline/bind.c +++ b/contrib/libreadline/bind.c @@ -70,6 +70,8 @@ extern int _rl_convert_meta_chars_to_ascii; extern int _rl_output_meta_chars; extern int _rl_complete_show_all; extern int _rl_complete_mark_directories; +extern int _rl_print_completions_horizontally; +extern int _rl_completion_case_fold; extern int _rl_enable_keypad; #if defined (PAREN_MATCHING) extern int rl_blink_matching_paren; @@ -105,6 +107,7 @@ Keymap rl_binding_keymap; /* Forward declarations */ void rl_set_keymap_from_edit_mode (); +static int _rl_read_init_file (); static int glean_key_from_name (); static int substring_member_of_array (); @@ -198,6 +201,35 @@ rl_unbind_key_in_map (key, map) return (rl_bind_key_in_map (key, (Function *)NULL, map)); } +/* Unbind all keys bound to FUNCTION in MAP. */ +int +rl_unbind_function_in_map (func, map) + Function *func; + Keymap map; +{ + register int i; + + for (i = 0; i < KEYMAP_SIZE; i++) + { + if (map[i].type == ISFUNC && map[i].function == func) + map[i].function = (Function *)NULL; + } +} + +int +rl_unbind_command_in_map (command, map) + char *command; + Keymap map; +{ + Function *func; + register int i; + + func = rl_named_function (command); + if (func == 0) + return 0; + return (rl_unbind_function_in_map (func, map)); +} + /* Bind the key sequence represented by the string KEYSEQ to FUNCTION. This makes new keymaps as necessary. The initial place to do bindings is in MAP. */ @@ -313,7 +345,7 @@ rl_translate_keyseq (seq, array, len) char *seq, *array; int *len; { - register int i, c, l; + register int i, c, l, temp; for (i = l = 0; c = seq[i]; i++) { @@ -324,7 +356,8 @@ rl_translate_keyseq (seq, array, len) if (c == 0) break; - if (((c == 'C' || c == 'M') && seq[i + 1] == '-') || (c == 'e')) + /* Handle \C- and \M- prefixes. */ + if ((c == 'C' || c == 'M') && seq[i + 1] == '-') { /* Handle special case of backwards define. */ if (strncmp (&seq[i], "C-\\M-", 5) == 0) @@ -332,31 +365,83 @@ rl_translate_keyseq (seq, array, len) array[l++] = ESC; i += 5; array[l++] = CTRL (_rl_to_upper (seq[i])); - if (!seq[i]) + if (seq[i] == '\0') i--; - continue; } - - switch (c) + else if (c == 'M') { - case 'M': i++; array[l++] = ESC; /* XXX */ - break; - - case 'C': + } + else if (c == 'C') + { i += 2; /* Special hack for C-?... */ array[l++] = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i])); - break; - - case 'e': - array[l++] = ESC; } - continue; + } + + /* Translate other backslash-escaped characters. These are the + same escape sequences that bash's `echo' and `printf' builtins + handle, with the addition of \d -> RUBOUT. A backslash + preceding a character that is not special is stripped. */ + switch (c) + { + case 'a': + array[l++] = '\007'; + break; + case 'b': + array[l++] = '\b'; + break; + case 'd': + array[l++] = RUBOUT; /* readline-specific */ + break; + case 'e': + array[l++] = ESC; + break; + case 'f': + array[l++] = '\f'; + break; + case 'n': + array[l++] = NEWLINE; + break; + case 'r': + array[l++] = RETURN; + break; + case 't': + array[l++] = TAB; + break; + case 'v': + array[l++] = 0x0B; + break; + case '\\': + array[l++] = '\\'; + break; + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + i++; + for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++) + c = (c * 8) + OCTVALUE (seq[i]); + i--; /* auto-increment in for loop */ + array[l++] = c % (largest_char + 1); + break; + case 'x': + i++; + for (temp = 3, c = 0; isxdigit (seq[i]) && temp--; i++) + c = (c * 16) + HEXVALUE (seq[i]); + if (temp == 3) + c = 'x'; + i--; /* auto-increment in for loop */ + array[l++] = c % (largest_char + 1); + break; + default: /* backslashes before non-special chars just add the char */ + array[l++] = c; + break; /* the backslash is stripped */ } + continue; } + array[l++] = c; } @@ -541,8 +626,55 @@ static char *last_readline_init_file = (char *)NULL; /* The file we're currently reading key bindings from. */ static char *current_readline_init_file; +static int current_readline_init_include_level; static int current_readline_init_lineno; +/* Read FILENAME into a locally-allocated buffer and return the buffer. + The size of the buffer is returned in *SIZEP. Returns NULL if any + errors were encountered. */ +static char * +_rl_read_file (filename, sizep) + char *filename; + size_t *sizep; +{ + struct stat finfo; + size_t file_size; + char *buffer; + int i, file; + + if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0) + return ((char *)NULL); + + file_size = (size_t)finfo.st_size; + + /* check for overflow on very large files */ + if (file_size != finfo.st_size || file_size + 1 < file_size) + { + if (file >= 0) + close (file); +#if defined (EFBIG) + errno = EFBIG; +#endif + return ((char *)NULL); + } + + /* Read the file into BUFFER. */ + buffer = (char *)xmalloc (file_size + 1); + i = read (file, buffer, file_size); + close (file); + + if (i < file_size) + { + free (buffer); + return ((char *)NULL); + } + + buffer[file_size] = '\0'; + if (sizep) + *sizep = file_size; + return (buffer); +} + /* Re-read the current keybindings file. */ int rl_re_read_init_file (count, ignore) @@ -565,11 +697,6 @@ int rl_read_init_file (filename) char *filename; { - register int i; - char *buffer, *openname, *line, *end; - struct stat finfo; - int file; - /* Default the filename. */ if (filename == 0) { @@ -583,39 +710,37 @@ rl_read_init_file (filename) if (*filename == 0) filename = DEFAULT_INPUTRC; + return (_rl_read_init_file (filename, 0)); +} + +static int +_rl_read_init_file (filename, include_level) + char *filename; + int include_level; +{ + register int i; + char *buffer, *openname, *line, *end; + size_t file_size; + current_readline_init_file = filename; + current_readline_init_include_level = include_level; + openname = tilde_expand (filename); - - if ((stat (openname, &finfo) < 0) || - (file = open (openname, O_RDONLY, 0666)) < 0) + buffer = _rl_read_file (openname, &file_size); + if (buffer == 0) + return (errno); + + if (include_level == 0 && filename != last_readline_init_file) { - free (openname); - return (errno); - } - else - free (openname); - - if (filename != last_readline_init_file) - { - if (last_readline_init_file) - free (last_readline_init_file); - + FREE (last_readline_init_file); last_readline_init_file = savestring (filename); } - /* Read the file into BUFFER. */ - buffer = (char *)xmalloc ((int)finfo.st_size + 1); - i = read (file, buffer, finfo.st_size); - close (file); - - if (i != finfo.st_size) - return (errno); - /* Loop over the lines in the file. Lines that start with `#' are comments; all other lines are commands for readline initialization. */ current_readline_init_lineno = 1; line = buffer; - end = buffer + finfo.st_size; + end = buffer + file_size; while (line < end) { /* Find the end of this line. */ @@ -639,6 +764,7 @@ rl_read_init_file (filename) line += i + 1; current_readline_init_lineno++; } + free (buffer); return (0); } @@ -697,7 +823,7 @@ parser_if (args) if (args[i]) args[i++] = '\0'; - /* Handle "if term=foo" and "if mode=emacs" constructs. If this + /* Handle "$if term=foo" and "$if mode=emacs" constructs. If this isn't term=foo, or mode=emacs, then check to see if the first word in ARGS is the same as the value stored in rl_readline_name. */ if (rl_terminal_name && _rl_strnicmp (args, "term=", 5) == 0) @@ -749,9 +875,9 @@ parser_else (args) { register int i; - if (!if_stack_depth) + if (if_stack_depth == 0) { - /* Error message? */ + _rl_init_file_error ("$else found without matching $if"); return 0; } @@ -775,12 +901,36 @@ parser_endif (args) if (if_stack_depth) _rl_parsing_conditionalized_out = if_stack[--if_stack_depth]; else - { - /* *** What, no error message? *** */ - } + _rl_init_file_error ("$endif without matching $if"); return 0; } +static int +parser_include (args) + char *args; +{ + char *old_init_file, *e; + int old_line_number, old_include_level, r; + + if (_rl_parsing_conditionalized_out) + return (0); + + old_init_file = current_readline_init_file; + old_line_number = current_readline_init_lineno; + old_include_level = current_readline_init_include_level; + + e = strchr (args, '\n'); + if (e) + *e = '\0'; + r = _rl_read_init_file (args, old_include_level + 1); + + current_readline_init_file = old_init_file; + current_readline_init_lineno = old_line_number; + current_readline_init_include_level = old_include_level; + + return r; +} + /* Associate textual names with actual functions. */ static struct { char *name; @@ -789,6 +939,7 @@ static struct { { "if", parser_if }, { "endif", parser_endif }, { "else", parser_else }, + { "include", parser_include }, { (char *)0x0, (Function *)0x0 } }; @@ -825,7 +976,8 @@ handle_parser_directive (statement) return (0); } - /* *** Should an error message be output? */ + /* display an error message about the unknown parser directive */ + _rl_init_file_error ("unknown parser directive"); return (1); } @@ -940,10 +1092,9 @@ rl_parse_and_bind (string) the quoted string delimiter, like the shell. */ if (*funname == '\'' || *funname == '"') { - int delimiter = string[i++]; - int passc = 0; + int delimiter = string[i++], passc; - for (; c = string[i]; i++) + for (passc = 0; c = string[i]; i++) { if (passc) { @@ -981,11 +1132,11 @@ rl_parse_and_bind (string) rl_set_key (). Otherwise, let the older code deal with it. */ if (*string == '"') { - char *seq = xmalloc (1 + strlen (string)); - register int j, k = 0; - int passc = 0; + char *seq; + register int j, k, passc; - for (j = 1; string[j]; j++) + seq = xmalloc (1 + strlen (string)); + for (j = 1, k = passc = 0; string[j]; j++) { /* Allow backslash to quote characters, but leave them in place. This allows a string to end with a backslash quoting another @@ -1078,6 +1229,7 @@ static struct { #if defined (PAREN_MATCHING) { "blink-matching-paren", &rl_blink_matching_paren }, #endif + { "completion-ignore-case", &_rl_completion_case_fold }, { "convert-meta", &_rl_convert_meta_chars_to_ascii }, { "disable-completion", &rl_inhibit_completion }, { "enable-keypad", &_rl_enable_keypad }, @@ -1088,6 +1240,7 @@ static struct { { "mark-modified-lines", &_rl_mark_modified_lines }, { "meta-flag", &_rl_meta_flag }, { "output-meta", &_rl_output_meta_chars }, + { "print-completions-horizontally", &_rl_print_completions_horizontally }, { "show-all-if-ambiguous", &_rl_complete_show_all }, #if defined (VISIBLE_STATS) { "visible-stats", &rl_visible_stats }, @@ -1186,6 +1339,7 @@ rl_variable_bind (name, value) _rl_bell_preference = AUDIBLE_BELL; } + /* For the time being, unknown variable names are simply ignored. */ return 0; } @@ -1338,7 +1492,7 @@ _rl_get_keyname (key) int key; { char *keyname; - int i, c; + int i, c, v; keyname = (char *)xmalloc (8); @@ -1383,6 +1537,18 @@ _rl_get_keyname (key) c = _rl_to_lower (UNCTRL (c)); } + /* XXX experimental code. Turn the characters that are not ASCII or + ISO Latin 1 (128 - 159) into octal escape sequences (\200 - \237). + This changes C. */ + if (c >= 128 && c <= 159) + { + keyname[i++] = '\\'; + keyname[i++] = '2'; + c -= 128; + keyname[i++] = (c / 8) + '0'; + c = (c % 8) + '0'; + } + /* Now, if the character needs to be quoted with a backslash, do that. */ if (c == '\\' || c == '"') keyname[i++] = '\\'; @@ -1692,10 +1858,13 @@ rl_variable_dumper (print_readably) /* bell-style */ switch (_rl_bell_preference) { - case NO_BELL: kname = "none"; break; - case VISIBLE_BELL: kname = "visible"; break; + case NO_BELL: + kname = "none"; break; + case VISIBLE_BELL: + kname = "visible"; break; case AUDIBLE_BELL: - default: kname = "audible"; break; + default: + kname = "audible"; break; } if (print_readably) fprintf (rl_outstream, "set bell-style %s\n", kname); diff --git a/contrib/libreadline/callback.c b/contrib/libreadline/callback.c index 04c5bbd09935..34dbc724611a 100644 --- a/contrib/libreadline/callback.c +++ b/contrib/libreadline/callback.c @@ -55,10 +55,10 @@ extern int rl_visible_prompt_length; things to handle at once, and dispatches them via select(). Call rl_callback_handler_install() with the prompt and a function to call whenever a complete line of input is ready. The user must then - call readline_char() every time some input is available, and - readline_char() will call the user's function with the complete text - read in at each end of line. The terminal is kept prepped and signals - handled all the time, except during calls to the user's function. */ + call rl_callback_read_char() every time some input is available, and + rl_callback_read_char() will call the user's function with the complete + text read in at each end of line. The terminal is kept prepped and + signals handled all the time, except during calls to the user's function. */ VFunction *rl_linefunc; /* user callback function */ static int in_handler; /* terminal_prepped and signals set? */ diff --git a/contrib/libreadline/chardefs.h b/contrib/libreadline/chardefs.h index 8e6f0efe890a..3e9e27377069 100644 --- a/contrib/libreadline/chardefs.h +++ b/contrib/libreadline/chardefs.h @@ -121,7 +121,20 @@ #ifdef ESC #undef ESC #endif - #define ESC CTRL('[') +#ifndef ISOCTAL +#define ISOCTAL(c) ((c) >= '0' && (c) <= '7') +#endif +#define OCTVALUE(c) ((c) - '0') + +#ifndef isxdigit +# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) +#endif + +#define HEXVALUE(c) \ + (((c) >= 'a' && (c) <= 'f') \ + ? (c)-'a'+10 \ + : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0') + #endif /* _CHARDEFS_H_ */ diff --git a/contrib/libreadline/complete.c b/contrib/libreadline/complete.c index 552cb6c63802..985e8981eee6 100644 --- a/contrib/libreadline/complete.c +++ b/contrib/libreadline/complete.c @@ -75,6 +75,7 @@ extern char *tilde_expand (); extern char *rl_copy_text (); extern void _rl_abort_internal (); extern int _rl_qsort_string_compare (); +extern void _rl_replace_text (); extern Function *rl_last_func; extern int rl_editing_mode; @@ -88,19 +89,55 @@ extern int rl_display_fixed; char *filename_completion_function (); char **completion_matches (); +#if defined (VISIBLE_STATS) +# if !defined (X_OK) +# define X_OK 1 +# endif +static int stat_char (); +#endif + static char *rl_quote_filename (); static char *rl_strpbrk (); static char **remove_duplicate_matches (); -static void insert_text (); static void insert_match (); -static void append_to_match (); +static int append_to_match (); static void insert_all_matches (); static void display_matches (); static int compute_lcd_of_matches (); extern char *xmalloc (), *xrealloc (); +/* **************************************************************** */ +/* */ +/* Completion matching, from readline's point of view. */ +/* */ +/* **************************************************************** */ + +/* Variables known only to the readline library. */ + +/* If non-zero, non-unique completions always show the list of matches. */ +int _rl_complete_show_all = 0; + +/* If non-zero, completed directory names have a slash appended. */ +int _rl_complete_mark_directories = 1; + +/* If non-zero, completions are printed horizontally in alphabetical order, + like `ls -x'. */ +int _rl_print_completions_horizontally; + +/* Non-zero means that case is not significant in filename completion. */ +int _rl_completion_case_fold; + +/* Global variables available to applications using readline. */ + +#if defined (VISIBLE_STATS) +/* Non-zero means add an additional character to each filename displayed + during listing completion iff rl_filename_completion_desired which helps + to indicate the type of file being listed. */ +int rl_visible_stats = 0; +#endif /* VISIBLE_STATS */ + /* If non-zero, then this is the address of a function to call when completing on a directory name. The function is called with the address of a string (the current directory name) as an arg. */ @@ -109,34 +146,6 @@ Function *rl_directory_completion_hook = (Function *)NULL; /* Non-zero means readline completion functions perform tilde expansion. */ int rl_complete_with_tilde_expansion = 0; -/* If non-zero, non-unique completions always show the list of matches. */ -int _rl_complete_show_all = 0; - -/* If non-zero, completed directory names have a slash appended. */ -int _rl_complete_mark_directories = 1; - -#if defined (VISIBLE_STATS) -# if !defined (X_OK) -# define X_OK 1 -# endif - -static int stat_char (); - -/* Non-zero means add an additional character to each filename displayed - during listing completion iff rl_filename_completion_desired which helps - to indicate the type of file being listed. */ -int rl_visible_stats = 0; -#endif /* VISIBLE_STATS */ - -/* **************************************************************** */ -/* */ -/* Completion matching, from readline's point of view. */ -/* */ -/* **************************************************************** */ - -/* Local variable states what happened during the last completion attempt. */ -static int completion_changed_buffer; - /* Pointer to the generator function for completion_matches (). NULL means to use filename_completion_function (), the default filename completer. */ @@ -242,6 +251,17 @@ int rl_completion_append_character = ' '; /* If non-zero, inhibit completion (temporarily). */ int rl_inhibit_completion; +/* Variables local to this file. */ + +/* Local variable states what happened during the last completion attempt. */ +static int completion_changed_buffer; + +/*************************************/ +/* */ +/* Bindable completion functions */ +/* */ +/*************************************/ + /* Complete the word at or before point. You have supplied the function that does the initial simple matching selection algorithm (see completion_matches ()). The default is to do filename completion. */ @@ -274,6 +294,33 @@ rl_insert_completions (ignore, invoking_key) return (rl_complete_internal ('*')); } +/************************************/ +/* */ +/* Completion utility functions */ +/* */ +/************************************/ + +/* Find the first occurrence in STRING1 of any character from STRING2. + Return a pointer to the character in STRING1. */ +static char * +rl_strpbrk (string1, string2) + char *string1, *string2; +{ + register char *scan; + + for (; *string1; string1++) + { + for (scan = string2; *scan; scan++) + { + if (*string1 == *scan) + { + return (string1); + } + } + } + return ((char *)NULL); +} + /* The user must press "y" or "n". Non-zero return means "y" pressed. */ static int get_y_or_n () @@ -293,6 +340,63 @@ get_y_or_n () } } +#if defined (VISIBLE_STATS) +/* Return the character which best describes FILENAME. + `@' for symbolic links + `/' for directories + `*' for executables + `=' for sockets + `|' for FIFOs + `%' for character special devices + `#' for block special devices */ +static int +stat_char (filename) + char *filename; +{ + struct stat finfo; + int character, r; + +#if defined (HAVE_LSTAT) && defined (S_ISLNK) + r = lstat (filename, &finfo); +#else + r = stat (filename, &finfo); +#endif + + if (r == -1) + return (0); + + character = 0; + if (S_ISDIR (finfo.st_mode)) + character = '/'; +#if defined (S_ISCHR) + else if (S_ISCHR (finfo.st_mode)) + character = '%'; +#endif /* S_ISCHR */ +#if defined (S_ISBLK) + else if (S_ISBLK (finfo.st_mode)) + character = '#'; +#endif /* S_ISBLK */ +#if defined (S_ISLNK) + else if (S_ISLNK (finfo.st_mode)) + character = '@'; +#endif /* S_ISLNK */ +#if defined (S_ISSOCK) + else if (S_ISSOCK (finfo.st_mode)) + character = '='; +#endif /* S_ISSOCK */ +#if defined (S_ISFIFO) + else if (S_ISFIFO (finfo.st_mode)) + character = '|'; +#endif + else if (S_ISREG (finfo.st_mode)) + { + if (access (filename, X_OK) == 0) + character = '*'; + } + return (character); +} +#endif /* VISIBLE_STATS */ + /* Return the portion of PATHNAME that should be output when listing possible completions. If we are hacking filename completion, we are only interested in the basename, the portion following the @@ -309,26 +413,34 @@ printable_part (pathname) /* Output TO_PRINT to rl_outstream. If VISIBLE_STATS is defined and we are using it, check for and output a single character for `special' - filenames. Return 1 if we printed an extension character, 0 if not. */ + filenames. Return the number of characters we output. */ #define PUTX(c) \ + do { \ if (CTRL_CHAR (c)) \ { \ putc ('^', rl_outstream); \ putc (UNCTRL (c), rl_outstream); \ + printed_len += 2; \ } \ else if (c == RUBOUT) \ { \ putc ('^', rl_outstream); \ putc ('?', rl_outstream); \ + printed_len += 2; \ } \ else \ - putc (c, rl_outstream) + { \ + putc (c, rl_outstream); \ + printed_len++; \ + } \ + } while (0) static int print_filename (to_print, full_pathname) char *to_print, *full_pathname; { + int printed_len = 0; #if !defined (VISIBLE_STATS) char *s; @@ -336,7 +448,6 @@ print_filename (to_print, full_pathname) { PUTX (*s); } - return 0; #else char *s, c, *new_full_pathname; int extension_char, slen, tlen; @@ -381,12 +492,13 @@ print_filename (to_print, full_pathname) free (s); if (extension_char) - putc (extension_char, rl_outstream); - return (extension_char != 0); + { + putc (extension_char, rl_outstream); + printed_len++; + } } - else - return 0; #endif /* VISIBLE_STATS */ + return printed_len; } static char * @@ -636,6 +748,125 @@ remove_duplicate_matches (matches) return (temp_array); } +/* Find the common prefix of the list of matches, and put it into + matches[0]. */ +static int +compute_lcd_of_matches (match_list, matches, text) + char **match_list; + int matches; + char *text; +{ + register int i, c1, c2, si; + int low; /* Count of max-matched characters. */ + + /* If only one match, just use that. Otherwise, compare each + member of the list with the next, finding out where they + stop matching. */ + if (matches == 1) + { + match_list[0] = match_list[1]; + match_list[1] = (char *)NULL; + return 1; + } + + for (i = 1, low = 100000; i < matches; i++) + { + if (_rl_completion_case_fold) + { + for (si = 0; + (c1 = _rl_to_lower(match_list[i][si])) && + (c2 = _rl_to_lower(match_list[i + 1][si])); + si++) + if (c1 != c2) + break; + } + else + { + for (si = 0; + (c1 = match_list[i][si]) && + (c2 = match_list[i + 1][si]); + si++) + if (c1 != c2) + break; + } + + if (low > si) + low = si; + } + + /* If there were multiple matches, but none matched up to even the + first character, and the user typed something, use that as the + value of matches[0]. */ + if (low == 0 && text && *text) + { + match_list[0] = xmalloc (strlen (text) + 1); + strcpy (match_list[0], text); + } + else + { + match_list[0] = xmalloc (low + 1); + strncpy (match_list[0], match_list[1], low); + match_list[0][low] = '\0'; + } + + return matches; +} + +static int +postprocess_matches (text, matchesp, matching_filenames) + char *text; + char ***matchesp; + int matching_filenames; +{ + char *t, **matches, **temp_matches; + int nmatch, i; + + matches = *matchesp; + + /* It seems to me that in all the cases we handle we would like + to ignore duplicate possiblilities. Scan for the text to + insert being identical to the other completions. */ + if (rl_ignore_completion_duplicates) + { + temp_matches = remove_duplicate_matches (matches); + free (matches); + matches = temp_matches; + } + + /* If we are matching filenames, then here is our chance to + do clever processing by re-examining the list. Call the + ignore function with the array as a parameter. It can + munge the array, deleting matches as it desires. */ + if (rl_ignore_some_completions_function && matching_filenames) + { + for (nmatch = 1; matches[nmatch]; nmatch++) + ; + (void)(*rl_ignore_some_completions_function) (matches); + if (matches == 0 || matches[0] == 0) + { + FREE (matches); + ding (); + *matchesp = (char **)0; + return 0; + } + else + { + /* If we removed some matches, recompute the common prefix. */ + for (i = 1; matches[i]; i++) + ; + if (i > 1 && i < nmatch) + { + t = matches[0]; + compute_lcd_of_matches (matches, i - 1, text); + FREE (t); + } + } + } + + *matchesp = matches; + return (1); +} + static void display_matches (matches) char **matches; @@ -718,25 +949,47 @@ display_matches (matches) if (rl_ignore_completion_duplicates == 0) qsort (matches + 1, len, sizeof (char *), _rl_qsort_string_compare); - /* Print the sorted items, up-and-down alphabetically, like ls. */ crlf (); - for (i = 1; i <= count; i++) + if (_rl_print_completions_horizontally == 0) { - for (j = 0, l = i; j < limit; j++) + /* Print the sorted items, up-and-down alphabetically, like ls. */ + for (i = 1; i <= count; i++) { - if (l > len || matches[l] == 0) - break; - else + for (j = 0, l = i; j < limit; j++) { - temp = printable_part (matches[l]); - printed_len = strlen (temp) + print_filename (temp, matches[l]); + if (l > len || matches[l] == 0) + break; + else + { + temp = printable_part (matches[l]); + printed_len = print_filename (temp, matches[l]); - if (j + 1 < limit) + if (j + 1 < limit) + for (k = 0; k < max - printed_len; k++) + putc (' ', rl_outstream); + } + l += count; + } + crlf (); + } + } + else + { + /* Print the sorted items, across alphabetically, like ls -x. */ + for (i = 1; matches[i]; i++) + { + temp = printable_part (matches[i]); + printed_len = print_filename (temp, matches[i]); + /* Have we reached the end of this line? */ + if (matches[i+1]) + { + if (i && (limit > 1) && (i % limit) == 0) + crlf (); + else for (k = 0; k < max - printed_len; k++) putc (' ', rl_outstream); } - l += count; } crlf (); } @@ -749,18 +1002,6 @@ display_matches (matches) #endif } -static void -insert_text (text, start, end) - char *text; - int start, end; -{ - rl_begin_undo_group (); - rl_delete_text (start, end + 1); - rl_point = start; - rl_insert_text (text); - rl_end_undo_group (); -} - static char * make_quoted_replacement (match, mtype, qc) char *match; @@ -833,7 +1074,7 @@ insert_match (match, start, mtype, qc) else if (qc && (*qc != oqc) && start && rl_line_buffer[start - 1] == oqc && replacement[0] != oqc) start--; - insert_text (replacement, start, rl_point - 1); + _rl_replace_text (replacement, start, rl_point - 1); if (replacement != match) free (replacement); } @@ -842,8 +1083,9 @@ insert_match (match, start, mtype, qc) /* Append any necessary closing quote and a separator character to the just-inserted match. If the user has specified that directories should be marked by a trailing `/', append one of those instead. The - default trailing character */ -static void + default trailing character is a space. Returns the number of characters + appended. */ +static int append_to_match (text, delimiter, quote_char) char *text; int delimiter, quote_char; @@ -883,6 +1125,8 @@ append_to_match (text, delimiter, quote_char) if (rl_point == rl_end) rl_insert_text (temp_string); } + + return (temp_string_index); } static void @@ -935,27 +1179,24 @@ int rl_complete_internal (what_to_do) int what_to_do; { - char **matches, **temp_matches; + char **matches; Function *our_func; - int start, end, delimiter, found_quote, nmatch, i; - char *text, *saved_line_buffer, *t; + int start, end, delimiter, found_quote, i; + char *text, *saved_line_buffer; char quote_char; - saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL; - - our_func = rl_completion_entry_function - ? rl_completion_entry_function - : (Function *)filename_completion_function; - /* Only the completion entry function can change these. */ rl_filename_completion_desired = 0; rl_filename_quoting_desired = 1; - rl_completion_type = what_to_do; + saved_line_buffer = rl_line_buffer ? savestring (rl_line_buffer) : (char *)NULL; + our_func = rl_completion_entry_function + ? rl_completion_entry_function + : (Function *)filename_completion_function; + /* We now look backwards for the start of a filename/variable word. */ end = rl_point; - found_quote = delimiter = 0; quote_char = '\0'; @@ -975,50 +1216,19 @@ rl_complete_internal (what_to_do) ding (); FREE (saved_line_buffer); free (text); - return 0; - } - - /* It seems to me that in all the cases we handle we would like - to ignore duplicate possiblilities. Scan for the text to - insert being identical to the other completions. */ - if (rl_ignore_completion_duplicates) - { - temp_matches = remove_duplicate_matches (matches); - free (matches); - matches = temp_matches; + return (0); } - /* If we are matching filenames, then here is our chance to - do clever processing by re-examining the list. Call the - ignore function with the array as a parameter. It can - munge the array, deleting matches as it desires. */ - if (rl_ignore_some_completions_function && - our_func == (Function *)filename_completion_function) + /* If we are matching filenames, our_func will have been set to + filename_completion_function */ + i = our_func == (Function *)filename_completion_function; + if (postprocess_matches (text, &matches, i) == 0) { - for (nmatch = 1; matches[nmatch]; nmatch++) - ; - (void)(*rl_ignore_some_completions_function) (matches); - if (matches == 0 || matches[0] == 0) - { - FREE (matches); - ding (); - FREE (saved_line_buffer); - FREE (text); - return 0; - } - else - { - /* If we removed some matches, recompute the common prefix. */ - for (i = 1; matches[i]; i++) - ; - if (i > 1 && i < nmatch) - { - t = matches[0]; - compute_lcd_of_matches (matches, i - 1, text); - FREE (t); - } - } + FREE (saved_line_buffer); + free (text); + return (0); } + free (text); switch (what_to_do) @@ -1081,191 +1291,11 @@ rl_complete_internal (what_to_do) return 0; } -#if defined (VISIBLE_STATS) -/* Return the character which best describes FILENAME. - `@' for symbolic links - `/' for directories - `*' for executables - `=' for sockets - `|' for FIFOs - `%' for character special devices - `#' for block special devices */ -static int -stat_char (filename) - char *filename; -{ - struct stat finfo; - int character, r; - -#if defined (HAVE_LSTAT) && defined (S_ISLNK) - r = lstat (filename, &finfo); -#else - r = stat (filename, &finfo); -#endif - - if (r == -1) - return (0); - - character = 0; - if (S_ISDIR (finfo.st_mode)) - character = '/'; -#if defined (S_ISCHR) - else if (S_ISCHR (finfo.st_mode)) - character = '%'; -#endif /* S_ISCHR */ -#if defined (S_ISBLK) - else if (S_ISBLK (finfo.st_mode)) - character = '#'; -#endif /* S_ISBLK */ -#if defined (S_ISLNK) - else if (S_ISLNK (finfo.st_mode)) - character = '@'; -#endif /* S_ISLNK */ -#if defined (S_ISSOCK) - else if (S_ISSOCK (finfo.st_mode)) - character = '='; -#endif /* S_ISSOCK */ -#if defined (S_ISFIFO) - else if (S_ISFIFO (finfo.st_mode)) - character = '|'; -#endif - else if (S_ISREG (finfo.st_mode)) - { - if (access (filename, X_OK) == 0) - character = '*'; - } - return (character); -} -#endif /* VISIBLE_STATS */ - -/* A completion function for usernames. - TEXT contains a partial username preceded by a random - character (usually `~'). */ -char * -username_completion_function (text, state) - int state; - char *text; -{ -#if defined (__GO32__) || defined (__WIN32__) - return (char *)NULL; -#else /* !__GO32__ */ - static char *username = (char *)NULL; - static struct passwd *entry; - static int namelen, first_char, first_char_loc; - char *value; - - if (state == 0) - { - FREE (username); - - first_char = *text; - first_char_loc = first_char == '~'; - - username = savestring (&text[first_char_loc]); - namelen = strlen (username); - setpwent (); - } - - while (entry = getpwent ()) - { - /* Null usernames should result in all users as possible completions. */ - if (namelen == 0 || (STREQN (username, entry->pw_name, namelen))) - break; - } - - if (entry == 0) - { - endpwent (); - return ((char *)NULL); - } - else - { - value = xmalloc (2 + strlen (entry->pw_name)); - - *value = *text; - - strcpy (value + first_char_loc, entry->pw_name); - - if (first_char == '~') - rl_filename_completion_desired = 1; - - return (value); - } -#endif /* !__GO32__ */ -} - -/* **************************************************************** */ -/* */ -/* Completion */ -/* */ -/* **************************************************************** */ - -/* Non-zero means that case is not significant in completion. */ -int completion_case_fold = 0; - -/* Find the common prefix of the list of matches, and put it into - matches[0]. */ -static int -compute_lcd_of_matches (match_list, matches, text) - char **match_list; - int matches; - char *text; -{ - register int i, c1, c2, si; - int low; /* Count of max-matched characters. */ - - /* If only one match, just use that. Otherwise, compare each - member of the list with the next, finding out where they - stop matching. */ - if (matches == 1) - { - match_list[0] = match_list[1]; - match_list[1] = (char *)NULL; - return 1; - } - - for (i = 1, low = 100000; i < matches; i++) - { - if (completion_case_fold) - { - for (si = 0; - (c1 = _rl_to_lower(match_list[i][si])) && - (c2 = _rl_to_lower(match_list[i + 1][si])); - si++) - if (c1 != c2) - break; - } - else - { - for (si = 0; - (c1 = match_list[i][si]) && - (c2 = match_list[i + 1][si]); - si++) - if (c1 != c2) - break; - } - - if (low > si) - low = si; - } - - /* If there were multiple matches, but none matched up to even the - first character, and the user typed something, use that as the - value of matches[0]. */ - if (low == 0 && text && *text) - { - match_list[0] = xmalloc (strlen (text) + 1); - strcpy (match_list[0], text); - } - else - { - match_list[0] = xmalloc (low + 1); - strncpy (match_list[0], match_list[1], low); - match_list[0][low] = '\0'; - } - - return matches; -} +/***************************************************************/ +/* */ +/* Application-callable completion match generator functions */ +/* */ +/***************************************************************/ /* Return an array of (char *) which is a list of completions for TEXT. If there are no completions, return a NULL pointer. @@ -1323,6 +1353,62 @@ completion_matches (text, entry_function) return (match_list); } +/* A completion function for usernames. + TEXT contains a partial username preceded by a random + character (usually `~'). */ +char * +username_completion_function (text, state) + int state; + char *text; +{ +#if defined (__GO32__) || defined (__WIN32__) + return (char *)NULL; +#else /* !__GO32__ */ + static char *username = (char *)NULL; + static struct passwd *entry; + static int namelen, first_char, first_char_loc; + char *value; + + if (state == 0) + { + FREE (username); + + first_char = *text; + first_char_loc = first_char == '~'; + + username = savestring (&text[first_char_loc]); + namelen = strlen (username); + setpwent (); + } + + while (entry = getpwent ()) + { + /* Null usernames should result in all users as possible completions. */ + if (namelen == 0 || (STREQN (username, entry->pw_name, namelen))) + break; + } + + if (entry == 0) + { + endpwent (); + return ((char *)NULL); + } + else + { + value = xmalloc (2 + strlen (entry->pw_name)); + + *value = *text; + + strcpy (value + first_char_loc, entry->pw_name); + + if (first_char == '~') + rl_filename_completion_desired = 1; + + return (value); + } +#endif /* !__GO32__ */ +} + /* Okay, now we write the entry_function for filename completion. In the general case. Note that completion in the shell is a little different because of all the pathnames that must be followed when looking up the @@ -1421,10 +1507,20 @@ filename_completion_function (text, state) { /* Otherwise, if these match up to the length of filename, then it is a match. */ - if ((entry->d_name[0] == filename[0]) && - (((int)D_NAMLEN (entry)) >= filename_len) && - (strncmp (filename, entry->d_name, filename_len) == 0)) - break; + if (_rl_completion_case_fold) + { + if ((_rl_to_lower (entry->d_name[0]) == _rl_to_lower (filename[0])) && + (((int)D_NAMLEN (entry)) >= filename_len) && + (_rl_strnicmp (filename, entry->d_name, filename_len) == 0)) + break; + } + else + { + if ((entry->d_name[0] == filename[0]) && + (((int)D_NAMLEN (entry)) >= filename_len) && + (strncmp (filename, entry->d_name, filename_len) == 0)) + break; + } } } @@ -1487,74 +1583,120 @@ filename_completion_function (text, state) } } -/* A function for simple tilde expansion. */ +/* An initial implementation of a menu completion function a la tcsh. The + first time (if the last readline command was not rl_menu_complete), we + generate the list of matches. This code is very similar to the code in + rl_complete_internal -- there should be a way to combine the two. Then, + for each item in the list of matches, we insert the match in an undoable + fashion, with the appropriate character appended (this happens on the + second and subsequent consecutive calls to rl_menu_complete). When we + hit the end of the match list, we restore the original unmatched text, + ring the bell, and reset the counter to zero. */ int -rl_tilde_expand (ignore, key) - int ignore, key; +rl_menu_complete (count, ignore) + int count, ignore; { - register int start, end; - char *homedir, *temp; - int len; + Function *our_func; + int matching_filenames, found_quote; - end = rl_point; - start = end - 1; + static char *orig_text; + static char **matches = (char **)0; + static int match_list_index = 0; + static int match_list_size = 0; + static int orig_start, orig_end; + static char quote_char; + static int delimiter; - if (rl_point == rl_end && rl_line_buffer[rl_point] == '~') + /* The first time through, we generate the list of matches and set things + up to insert them. */ + if (rl_last_func != rl_menu_complete) { - homedir = tilde_expand ("~"); - insert_text (homedir, start, end); + /* Clean up from previous call, if any. */ + FREE (orig_text); + if (matches) + { + for (match_list_index = 0; matches[match_list_index]; match_list_index++) + free (matches[match_list_index]); + free (matches); + } + + match_list_index = match_list_size = 0; + matches = (char **)NULL; + + /* Only the completion entry function can change these. */ + rl_filename_completion_desired = 0; + rl_filename_quoting_desired = 1; + rl_completion_type = '%'; + + our_func = rl_completion_entry_function + ? rl_completion_entry_function + : (Function *)filename_completion_function; + + /* We now look backwards for the start of a filename/variable word. */ + orig_end = rl_point; + found_quote = delimiter = 0; + quote_char = '\0'; + + if (rl_point) + /* This (possibly) changes rl_point. If it returns a non-zero char, + we know we have an open quote. */ + quote_char = find_completion_word (&found_quote, &delimiter); + + orig_start = rl_point; + rl_point = orig_end; + + orig_text = rl_copy_text (orig_start, orig_end); + matches = gen_completion_matches (orig_text, orig_start, orig_end, + our_func, found_quote, quote_char); + + /* If we are matching filenames, our_func will have been set to + filename_completion_function */ + matching_filenames = our_func == (Function *)filename_completion_function; + if (matches == 0 || postprocess_matches (orig_text, &matches, matching_filenames) == 0) + { + ding (); + FREE (matches); + matches = (char **)0; + FREE (orig_text); + orig_text = (char *)0; + completion_changed_buffer = 0; + return (0); + } + + for (match_list_size = 0; matches[match_list_size]; match_list_size++) + ; + /* matches[0] is lcd if match_list_size > 1, but the circular buffer + code below should take care of it. */ + } + + /* Now we have the list of matches. Replace the text between + rl_line_buffer[orig_start] and rl_line_buffer[rl_point] with + matches[match_list_index], and add any necessary closing char. */ + + if (matches == 0 || match_list_size == 0) + { + ding (); + FREE (matches); + matches = (char **)0; + completion_changed_buffer = 0; return (0); } - else if (rl_line_buffer[start] != '~') + + match_list_index = (match_list_index + count) % match_list_size; + if (match_list_index < 0) + match_list_index += match_list_size; + + if (match_list_index == 0) { - for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--) - ; - start++; - } - - end = start; - do - end++; - while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end); - - if (whitespace (rl_line_buffer[end]) || end >= rl_end) - end--; - - /* If the first character of the current word is a tilde, perform - tilde expansion and insert the result. If not a tilde, do - nothing. */ - if (rl_line_buffer[start] == '~') - { - len = end - start + 1; - temp = xmalloc (len + 1); - strncpy (temp, rl_line_buffer + start, len); - temp[len] = '\0'; - homedir = tilde_expand (temp); - free (temp); - - insert_text (homedir, start, end); + ding (); + insert_match (orig_text, orig_start, MULT_MATCH, "e_char); + } + else + { + insert_match (matches[match_list_index], orig_start, SINGLE_MATCH, "e_char); + append_to_match (matches[match_list_index], delimiter, quote_char); } + completion_changed_buffer = 1; return (0); } - -/* Find the first occurrence in STRING1 of any character from STRING2. - Return a pointer to the character in STRING1. */ -static char * -rl_strpbrk (string1, string2) - char *string1, *string2; -{ - register char *scan; - - for (; *string1; string1++) - { - for (scan = string2; *scan; scan++) - { - if (*string1 == *scan) - { - return (string1); - } - } - } - return ((char *)NULL); -} diff --git a/contrib/libreadline/config.h.in b/contrib/libreadline/config.h.in index 45ed5b9db74a..65927a8440d9 100644 --- a/contrib/libreadline/config.h.in +++ b/contrib/libreadline/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated automatically from configure.in by autoheader. */ +/* Define if on MINIX. */ +#undef _MINIX + /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE @@ -92,6 +95,10 @@ #undef GWINSZ_IN_SYS_IOCTL +#undef STRUCT_WINSIZE_IN_SYS_IOCTL + +#undef STRUCT_WINSIZE_IN_TERMIOS + #undef TIOCSTAT_IN_SYS_IOCTL #undef FIONREAD_IN_SYS_IOCTL diff --git a/contrib/libreadline/configure b/contrib/libreadline/configure index 4b7479ddc194..b9bb2b9103f0 100755 --- a/contrib/libreadline/configure +++ b/contrib/libreadline/configure @@ -1,7 +1,19 @@ #! /bin/sh -# From configure.in for Readline 2.1, version 2.04, from autoconf version 2.12 -LIBVERSION=2.1 +# From configure.in for Readline 2.2, version 2.07, from autoconf version 2.12 +LIBVERSION=2.2 + + + + + + + + + + + + @@ -87,6 +99,8 @@ LIBVERSION=2.1 ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help +--with-curses use the curses library instead of the termcap library" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -625,7 +639,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:629: checking host system type" >&5 +echo "configure:643: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -646,13 +660,27 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 +opt_curses=no +opt_shared=no + +# Check whether --with-curses or --without-curses was given. +if test "${with_curses+set}" = set; then + withval="$with_curses" + opt_curses=$withval +fi + + +if test "$opt_curses" = "yes"; then + prefer_curses=yes +fi + # We want these before the checks, so the checks can modify their values. test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:656: checking for $ac_word" >&5 +echo "configure:684: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -681,7 +709,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:685: checking for $ac_word" >&5 +echo "configure:713: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -729,7 +757,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:733: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:761: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -739,11 +767,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -763,12 +791,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:767: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:795: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:772: checking whether we are using GNU C" >&5 +echo "configure:800: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -777,7 +805,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:781: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:809: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -792,7 +820,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:796: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:824: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -819,12 +847,8 @@ else test "${CFLAGS+set}" = set || CFLAGS="-g" fi - -# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS. -test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O" - echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:828: checking how to run the C preprocessor" >&5 +echo "configure:852: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -839,13 +863,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:849: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:873: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : @@ -856,13 +880,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:866: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:890: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then : @@ -884,15 +908,68 @@ else fi echo "$ac_t""$CPP" 1>&6 +ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 +echo "configure:914: checking for minix/config.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:924: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + MINIX=yes +else + echo "$ac_t""no" 1>&6 +MINIX= +fi + +if test "$MINIX" = yes; then + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX_1_SOURCE 2 +EOF + + cat >> confdefs.h <<\EOF +#define _MINIX 1 +EOF + +fi + + +# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS. +test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O" + if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:890: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:967: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP @@ -910,7 +987,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -942,7 +1019,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:946: checking for a BSD compatible install" >&5 +echo "configure:1023: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -994,7 +1071,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:998: checking for $ac_word" >&5 +echo "configure:1075: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1022,12 +1099,12 @@ fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1026: checking return type of signal handlers" >&5 +echo "configure:1103: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1044,7 +1121,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:1048: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1125: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1064,12 +1141,12 @@ EOF echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6 -echo "configure:1068: checking whether stat file-mode macros are broken" >&5 +echo "configure:1145: checking whether stat file-mode macros are broken" >&5 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1124,12 +1201,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -echo "configure:1128: checking for $ac_hdr that defines DIR" >&5 +echo "configure:1205: checking for $ac_hdr that defines DIR" >&5 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> @@ -1137,7 +1214,7 @@ int main() { DIR *dirp = 0; ; return 0; } EOF -if { (eval echo configure:1141: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1218: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "ac_cv_header_dirent_$ac_safe=yes" else @@ -1162,7 +1239,7 @@ done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 -echo "configure:1166: checking for opendir in -ldir" >&5 +echo "configure:1243: checking for opendir in -ldir" >&5 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1170,7 +1247,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1203,7 +1280,7 @@ fi else echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 -echo "configure:1207: checking for opendir in -lx" >&5 +echo "configure:1284: checking for opendir in -lx" >&5 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1211,7 +1288,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1248,12 +1325,12 @@ fi for ac_func in strcasecmp select setenv putenv tcgetattr setlocale lstat do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1252: checking for $ac_func" >&5 +echo "configure:1329: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1302,7 +1379,7 @@ done echo $ac_n "checking for working strcoll""... $ac_c" 1>&6 -echo "configure:1306: checking for working strcoll" >&5 +echo "configure:1383: checking for working strcoll" >&5 if eval "test \"`echo '$''{'ac_cv_func_strcoll_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1310,7 +1387,7 @@ else ac_cv_func_strcoll_works=no else cat > conftest.$ac_ext < main () @@ -1320,7 +1397,7 @@ main () strcoll ("123", "456") >= 0); } EOF -if { (eval echo configure:1324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ac_cv_func_strcoll_works=yes else @@ -1349,17 +1426,17 @@ for ac_hdr in unistd.h stdlib.h varargs.h stdarg.h string.h \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1353: checking for $ac_hdr" >&5 +echo "configure:1430: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1363: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1440: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1388,13 +1465,13 @@ done echo $ac_n "checking for type of signal functions""... $ac_c" 1>&6 -echo "configure:1392: checking for type of signal functions" >&5 +echo "configure:1469: checking for type of signal functions" >&5 if eval "test \"`echo '$''{'bash_cv_signal_vintage'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { @@ -1407,7 +1484,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* bash_cv_signal_vintage=posix else @@ -1416,7 +1493,7 @@ else rm -rf conftest* cat > conftest.$ac_ext < int main() { @@ -1426,7 +1503,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1507: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* bash_cv_signal_vintage=4.2bsd else @@ -1435,7 +1512,7 @@ else rm -rf conftest* cat > conftest.$ac_ext < @@ -1448,7 +1525,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* bash_cv_signal_vintage=svr3 else @@ -1489,15 +1566,17 @@ fi echo $ac_n "checking if signal handlers must be reinstalled when invoked""... $ac_c" 1>&6 -echo "configure:1493: checking if signal handlers must be reinstalled when invoked" >&5 +echo "configure:1570: checking if signal handlers must be reinstalled when invoked" >&5 if eval "test \"`echo '$''{'bash_cv_must_reinstall_sighandlers'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: cannot check signal handling if cross compiling" 1>&2; exit 1; } + { echo "configure: error: cannot check signal handling if cross compiling -- defaulting to no" 1>&2; exit 1; } + bash_cv_must_reinstall_sighandlers=no + else cat > conftest.$ac_ext < @@ -1544,7 +1623,7 @@ main() } EOF -if { (eval echo configure:1548: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then bash_cv_must_reinstall_sighandlers=no else @@ -1569,15 +1648,17 @@ fi echo $ac_n "checking for presence of POSIX-style sigsetjmp/siglongjmp""... $ac_c" 1>&6 -echo "configure:1573: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5 +echo "configure:1652: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5 if eval "test \"`echo '$''{'bash_cv_func_sigsetjmp'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: cannot check for sigsetjmp/siglongjmp if cross-compiling" 1>&2; exit 1; } + { echo "configure: error: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" 1>&2; exit 1; } + bash_cv_func_sigsetjmp=missing + else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then bash_cv_func_sigsetjmp=present else @@ -1630,7 +1711,6 @@ fi rm -fr conftest* fi - fi echo "$ac_t""$bash_cv_func_sigsetjmp" 1>&6 @@ -1642,22 +1722,22 @@ EOF fi echo $ac_n "checking for lstat""... $ac_c" 1>&6 -echo "configure:1646: checking for lstat" >&5 +echo "configure:1726: checking for lstat" >&5 if eval "test \"`echo '$''{'bash_cv_func_lstat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include int main() { - lstat("",(struct stat *)0); + lstat(".",(struct stat *)0); ; return 0; } EOF -if { (eval echo configure:1661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1741: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* bash_cv_func_lstat=yes else @@ -1678,21 +1758,23 @@ EOF fi echo $ac_n "checking whether programs are able to redeclare getpw functions""... $ac_c" 1>&6 -echo "configure:1682: checking whether programs are able to redeclare getpw functions" >&5 +echo "configure:1762: checking whether programs are able to redeclare getpw functions" >&5 if eval "test \"`echo '$''{'bash_cv_can_redecl_getpw'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include extern struct passwd *getpwent(); +extern struct passwd *getpwuid(); +extern struct passwd *getpwnam(); int main() { -struct passwd *z; z = getpwent(); +struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root"); ; return 0; } EOF -if { (eval echo configure:1696: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1778: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_can_redecl_getpw=yes else @@ -1714,15 +1796,17 @@ fi echo $ac_n "checking whether or not strcoll and strcmp differ""... $ac_c" 1>&6 -echo "configure:1718: checking whether or not strcoll and strcmp differ" >&5 +echo "configure:1800: checking whether or not strcoll and strcmp differ" >&5 if eval "test \"`echo '$''{'bash_cv_func_strcoll_broken'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then - { echo "configure: error: cannot check strcoll if cross compiling" 1>&2; exit 1; } + { echo "configure: error: cannot check strcoll if cross compiling -- defaulting to no" 1>&2; exit 1; } + bash_cv_func_strcoll_broken=no + else cat > conftest.$ac_ext < @@ -1761,7 +1845,7 @@ char *v[]; } EOF -if { (eval echo configure:1765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then bash_cv_func_strcoll_broken=yes else @@ -1773,7 +1857,6 @@ fi rm -fr conftest* fi - fi echo "$ac_t""$bash_cv_func_strcoll_broken" 1>&6 @@ -1786,12 +1869,12 @@ fi echo $ac_n "checking whether signal handlers are of type void""... $ac_c" 1>&6 -echo "configure:1790: checking whether signal handlers are of type void" >&5 +echo "configure:1873: checking whether signal handlers are of type void" >&5 if eval "test \"`echo '$''{'bash_cv_void_sighandler'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1806,7 +1889,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:1810: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1893: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_void_sighandler=yes else @@ -1826,12 +1909,12 @@ EOF fi echo $ac_n "checking for TIOCGWINSZ in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:1830: checking for TIOCGWINSZ in sys/ioctl.h" >&5 +echo "configure:1913: checking for TIOCGWINSZ in sys/ioctl.h" >&5 if eval "test \"`echo '$''{'bash_cv_tiocgwinsz_in_ioctl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1839,7 +1922,7 @@ int main() { int x = TIOCGWINSZ; ; return 0; } EOF -if { (eval echo configure:1843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1926: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_tiocgwinsz_in_ioctl=yes else @@ -1860,12 +1943,12 @@ EOF fi echo $ac_n "checking for TIOCSTAT in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:1864: checking for TIOCSTAT in sys/ioctl.h" >&5 +echo "configure:1947: checking for TIOCSTAT in sys/ioctl.h" >&5 if eval "test \"`echo '$''{'bash_cv_tiocstat_in_ioctl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1873,7 +1956,7 @@ int main() { int x = TIOCSTAT; ; return 0; } EOF -if { (eval echo configure:1877: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1960: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_tiocstat_in_ioctl=yes else @@ -1894,12 +1977,12 @@ EOF fi echo $ac_n "checking for FIONREAD in sys/ioctl.h""... $ac_c" 1>&6 -echo "configure:1898: checking for FIONREAD in sys/ioctl.h" >&5 +echo "configure:1981: checking for FIONREAD in sys/ioctl.h" >&5 if eval "test \"`echo '$''{'bash_cv_fionread_in_ioctl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1907,7 +1990,7 @@ int main() { int x = FIONREAD; ; return 0; } EOF -if { (eval echo configure:1911: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1994: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_fionread_in_ioctl=yes else @@ -1928,19 +2011,19 @@ EOF fi echo $ac_n "checking for speed_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:1932: checking for speed_t in sys/types.h" >&5 +echo "configure:2015: checking for speed_t in sys/types.h" >&5 if eval "test \"`echo '$''{'bash_cv_speed_t_in_sys_types'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { speed_t x; ; return 0; } EOF -if { (eval echo configure:1944: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2027: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_speed_t_in_sys_types=yes else @@ -1960,14 +2043,75 @@ EOF fi +echo $ac_n "checking for struct winsize in sys/ioctl.h and termios.h""... $ac_c" 1>&6 +echo "configure:2048: checking for struct winsize in sys/ioctl.h and termios.h" >&5 +if eval "test \"`echo '$''{'bash_cv_struct_winsize_header'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +int main() { +struct winsize x; +; return 0; } +EOF +if { (eval echo configure:2061: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bash_cv_struct_winsize_header=ioctl_h +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + cat > conftest.$ac_ext < +#include +int main() { +struct winsize x; +; return 0; } +EOF +if { (eval echo configure:2077: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bash_cv_struct_winsize_header=termios_h +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bash_cv_struct_winsize_header=other +fi +rm -f conftest* + +fi +rm -f conftest* +fi + +if test $bash_cv_struct_winsize_header = ioctl_h; then + echo "$ac_t""sys/ioctl.h" 1>&6 + cat >> confdefs.h <<\EOF +#define STRUCT_WINSIZE_IN_SYS_IOCTL 1 +EOF + +elif test $bash_cv_struct_winsize_header = termios_h; then + echo "$ac_t""termios.h" 1>&6 + cat >> confdefs.h <<\EOF +#define STRUCT_WINSIZE_IN_TERMIOS 1 +EOF + +else + echo "$ac_t""not found" 1>&6 +fi + echo $ac_n "checking if struct dirent has a d_ino member""... $ac_c" 1>&6 -echo "configure:1966: checking if struct dirent has a d_ino member" >&5 +echo "configure:2110: checking if struct dirent has a d_ino member" >&5 if eval "test \"`echo '$''{'bash_cv_dirent_has_dino'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -1996,7 +2140,7 @@ struct dirent d; int z; z = d.d_ino; ; return 0; } EOF -if { (eval echo configure:2000: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2144: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_dirent_has_dino=yes else @@ -2018,12 +2162,12 @@ fi echo $ac_n "checking if struct dirent has a d_fileno member""... $ac_c" 1>&6 -echo "configure:2022: checking if struct dirent has a d_fileno member" >&5 +echo "configure:2166: checking if struct dirent has a d_fileno member" >&5 if eval "test \"`echo '$''{'bash_cv_dirent_has_d_fileno'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -2052,7 +2196,7 @@ struct dirent d; int z; z = d.d_fileno; ; return 0; } EOF -if { (eval echo configure:2056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2200: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bash_cv_dirent_has_d_fileno=yes else @@ -2073,6 +2217,167 @@ EOF fi +case "$host_os" in +aix*) prefer_curses=yes ;; +esac + +if test "X$bash_cv_termcap_lib" = "X"; then +_bash_needmsg=yes +else +echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6 +echo "configure:2229: checking which library has the termcap functions" >&5 +_bash_needmsg= +fi +if eval "test \"`echo '$''{'bash_cv_termcap_lib'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6 +echo "configure:2236: checking for tgetent in -ltermcap" >&5 +ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ltermcap $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + bash_cv_termcap_lib=libtermcap +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6 +echo "configure:2274: checking for tgetent in -lcurses" >&5 +ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lcurses $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + bash_cv_termcap_lib=libcurses +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6 +echo "configure:2312: checking for tgetent in -lncurses" >&5 +ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lncurses $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + bash_cv_termcap_lib=libncurses +else + echo "$ac_t""no" 1>&6 +bash_cv_termcap_lib=gnutermcap +fi + +fi + +fi + +fi + +if test "X$_bash_needmsg" = "Xyes"; then +echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6 +echo "configure:2360: checking which library has the termcap functions" >&5 +fi +echo "$ac_t""using $bash_cv_termcap_lib" 1>&6 +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 = libncurses; then +TERMCAP_LIB=-lncurses +TERMCAP_DEP= +else +TERMCAP_LIB=-lcurses +TERMCAP_DEP= +fi + +if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then + TERMCAP_LIB=-ltermcap #default +fi + case "$host_cpu" in *cray*) LOCAL_CFLAGS=-DCRAY ;; esac @@ -2081,6 +2386,12 @@ case "$host_os" in isc*) LOCAL_CFLAGS=-Disc386 ;; esac +BUILD_DIR=`pwd` + + + + + @@ -2231,9 +2542,12 @@ s%@CPP@%$CPP%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@RANLIB@%$RANLIB%g +s%@BUILD_DIR@%$BUILD_DIR%g s%@LOCAL_CFLAGS@%$LOCAL_CFLAGS%g +s%@LOCAL_LDFLAGS@%$LOCAL_LDFLAGS%g s%@LOCAL_DEFS@%$LOCAL_DEFS%g s%@LIBVERSION@%$LIBVERSION%g +s%@TERMCAP_LIB@%$TERMCAP_LIB%g CEOF EOF diff --git a/contrib/libreadline/configure.in b/contrib/libreadline/configure.in index 13152b87d307..cab431ad05d3 100644 --- a/contrib/libreadline/configure.in +++ b/contrib/libreadline/configure.in @@ -4,8 +4,8 @@ dnl dnl report bugs to chet@po.cwru.edu dnl dnl Process this file with autoconf to produce a configure script. -AC_REVISION([for Readline 2.1, version 2.04, from autoconf version] AC_ACVERSION) -LIBVERSION=2.1 +AC_REVISION([for Readline 2.2, version 2.07, from autoconf version] AC_ACVERSION) +LIBVERSION=2.2 AC_INIT(readline.h) AC_CONFIG_HEADER(config.h) @@ -17,10 +17,22 @@ AC_CONFIG_AUX_DIR(./support) AC_CANONICAL_HOST +dnl configure defaults +opt_curses=no +opt_shared=no + +dnl arguments to configure +AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval) + +if test "$opt_curses" = "yes"; then + prefer_curses=yes +fi + # We want these before the checks, so the checks can modify their values. test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 AC_PROG_CC +AC_MINIX # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS. test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O" @@ -55,9 +67,19 @@ BASH_HAVE_TIOCGWINSZ BASH_HAVE_TIOCSTAT BASH_HAVE_FIONREAD BASH_MISC_SPEED_T +BASH_STRUCT_WINSIZE BASH_STRUCT_DIRENT_D_INO BASH_STRUCT_DIRENT_D_FILENO +dnl yuck +case "$host_os" in +aix*) prefer_curses=yes ;; +esac +BASH_CHECK_LIB_TERMCAP +if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then + TERMCAP_LIB=-ltermcap #default +fi + case "$host_cpu" in *cray*) LOCAL_CFLAGS=-DCRAY ;; esac @@ -66,8 +88,12 @@ case "$host_os" in isc*) LOCAL_CFLAGS=-Disc386 ;; esac +BUILD_DIR=`pwd` +AC_SUBST(BUILD_DIR) + AC_SUBST(CFLAGS) AC_SUBST(LOCAL_CFLAGS) +AC_SUBST(LOCAL_LDFLAGS) AC_SUBST(LOCAL_DEFS) AC_SUBST(host_cpu) @@ -75,6 +101,8 @@ AC_SUBST(host_os) AC_SUBST(LIBVERSION) +AC_SUBST(TERMCAP_LIB) + AC_OUTPUT([Makefile doc/Makefile examples/Makefile], [ # Makefile uses this timestamp file to record whether config.h is up to date. diff --git a/contrib/libreadline/display.c b/contrib/libreadline/display.c index 609d827f4b4f..edb5b20dc556 100644 --- a/contrib/libreadline/display.c +++ b/contrib/libreadline/display.c @@ -72,7 +72,11 @@ extern int _rl_prefer_visible_bell; /* Variables and functions imported from terminal.c */ extern void _rl_output_some_chars (); +#ifdef _MINIX +extern void _rl_output_character_function (); +#else extern int _rl_output_character_function (); +#endif extern int _rl_backspace (); extern char *term_clreol, *term_clrpag; diff --git a/contrib/libreadline/doc/Makefile.in b/contrib/libreadline/doc/Makefile.in index bbbd5c3a4ad4..63da1be427ed 100644 --- a/contrib/libreadline/doc/Makefile.in +++ b/contrib/libreadline/doc/Makefile.in @@ -2,6 +2,7 @@ # Emacs likes it that way. top_srcdir = @top_srcdir@ srcdir = @srcdir@ +VPATH = .:@srcdir@ prefix = @prefix@ infodir = @infodir@ @@ -38,9 +39,10 @@ DVIOBJ = readline.dvi history.dvi INFOOBJ = readline.info history.info PSOBJ = readline.ps history.ps HTMLOBJ = readline.html history.html +HTMLTOC = readline_toc.html history_toc.html TEXTOBJ = readline.0 -CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(TEXTOBJ) +CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(HTMLTOC) $(TEXTOBJ) .SUFFIXES: .0 .3 .ps .txt .dvi @@ -91,7 +93,7 @@ ps: $(PSOBJ) html: $(HTMLOBJ) text: $(TEXTOBJ) -readline.0: $(srcdir)/readline.3 +readline.0: readline.3 clean: $(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \ @@ -99,11 +101,13 @@ clean: distclean: clean $(RM) $(CREATED_DOCS) + $(RM) Makefile mostlyclean: clean maintainer-clean: clean $(RM) $(CREATED_DOCS) + $(RM) Makefile installdirs: $(top_srcdir)/support/mkdirs -$(SHELL) $(top_srcdir)/support/mkdirs $(infodir) $(man3dir) diff --git a/contrib/libreadline/doc/hist.texinfo b/contrib/libreadline/doc/hist.texinfo index aa04553502ca..be8742f5e66a 100644 --- a/contrib/libreadline/doc/hist.texinfo +++ b/contrib/libreadline/doc/hist.texinfo @@ -7,20 +7,25 @@ @setchapternewpage odd @ignore -last change: Thu Mar 21 16:07:29 EST 1996 +last change: Thu Apr 2 14:38:22 EST 1998 @end ignore -@set EDITION 2.1 -@set VERSION 2.1 -@set UPDATED 21 March 1996 -@set UPDATE-MONTH March 1996 +@set EDITION 2.2 +@set VERSION 2.2 +@set UPDATED 2 April 1998 +@set UPDATE-MONTH April 1998 + +@dircategory Libraries +@direntry +* History: (history). The GNU history library API +@end direntry @ifinfo This document describes the GNU History library, a programming tool that provides a consistent user interface for recalling lines of previously typed input. -Copyright (C) 1988, 1991, 1993, 1995, 1996 Free Software Foundation, Inc. +Copyright (C) 1988, 1991, 1993, 1995, 1996, 1998 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice diff --git a/contrib/libreadline/doc/hsuser.texinfo b/contrib/libreadline/doc/hsuser.texinfo index 6e956494cb99..76cb63b1eeee 100644 --- a/contrib/libreadline/doc/hsuser.texinfo +++ b/contrib/libreadline/doc/hsuser.texinfo @@ -29,7 +29,7 @@ into another language, under the above conditions for modified versions. @ifset BashFeatures This chapter describes how to use the GNU History Library interactively, from a user's standpoint. It should be considered a user's guide. For -information on using the GNU History Library in your own programs, +information on using the GNU History Library in other programs, see the GNU Readline Library Manual. @end ifset @ifclear BashFeatures @@ -43,6 +43,8 @@ information on using the GNU History Library in your own programs, @menu * Bash History Facilities:: How Bash lets you manipulate your command history. +* Bash History Builtins:: The Bash builtin commands that manipulate + the command history. * History Interaction:: What it feels like using History as a user. @end menu @end ifset @@ -84,11 +86,10 @@ not saved. After saving the history, the history file is truncated to contain no more than @code{$HISTFILESIZE} lines. If @code{HISTFILESIZE} is not set, no truncation is performed. -The builtin command @code{fc} (@pxref{Korn Shell Builtins}) -may be used to list or edit and re-execute a portion of -the history list. The @code{history} builtin (@pxref{C Shell Builtins}) -can be used to display or modify the history list and -manipulate the history file. +The builtin command @code{fc} may be used to list or edit and re-execute +a portion of the history list. +The @code{history} builtin can be used to display or modify the history +list and manipulate the history file. When using the command-line editing, search commands are available in each editing mode that provide access to the history list. @@ -104,11 +105,103 @@ semicolons where necessary to preserve syntactic correctness. The @code{lithist} shell option causes the shell to save the command with embedded newlines instead of semicolons. -@xref{Bash Builtins} for a description of @code{shopt}. +@xref{Bash Builtins}, for a description of @code{shopt}. + +@node Bash History Builtins +@section Bash History Builtins +@cindex history builtins + +Bash provides two builtin commands that allow you to manipulate the +history list and history file. + +@table @code + +@item fc +@btindex fc +@example +@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]} +@code{fc -s [@var{pat}=@var{rep}] [@var{command}]} +@end example + +Fix Command. In the first form, a range of commands from @var{first} to +@var{last} is selected from the history list. Both @var{first} and +@var{last} may be specified as a string (to locate the most recent +command beginning with that string) or as a number (an index into the +history list, where a negative number is used as an offset from the +current command number). If @var{last} is not specified it is set to +@var{first}. If @var{first} is not specified it is set to the previous +command for editing and @minus{}16 for listing. If the @samp{-l} flag is +given, the commands are listed on standard output. The @samp{-n} flag +suppresses the command numbers when listing. The @samp{-r} flag +reverses the order of the listing. Otherwise, the editor given by +@var{ename} is invoked on a file containing those commands. If +@var{ename} is not given, the value of the following variable expansion +is used: @code{$@{FCEDIT:-$@{EDITOR:-vi@}@}}. This says to use the +value of the @code{FCEDIT} variable if set, or the value of the +@code{EDITOR} variable if that is set, or @code{vi} if neither is set. +When editing is complete, the edited commands are echoed and executed. + +In the second form, @var{command} is re-executed after each instance +of @var{pat} in the selected command is replaced by @var{rep}. + +A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so +that typing @samp{r cc} runs the last command beginning with @code{cc} +and typing @samp{r} re-executes the last command (@pxref{Aliases}). + +@item history +@btindex history +@example +history [-c] [@var{n}] +history [-anrw] [@var{filename}] +history -ps @var{arg} +@end example + +Display the history list with line numbers. Lines prefixed with +with a @samp{*} have been modified. An argument of @var{n} says +to list only the last @var{n} lines. Options, if supplied, have +the following meanings: + +@table @code +@item -w +Write out the current history to the history file. + +@item -r +Read the current history file and append its contents to +the history list. + +@item -a +Append the new +history lines (history lines entered since the beginning of the +current Bash session) to the history file. + +@item -n +Append the history lines not already read from the history file +to the current history list. These are lines appended to the history +file since the beginning of the current Bash session. + +@item -c +Clear the history list. This may be combined +with the other options to replace the history list completely. + +@item -s +The @var{arg}s are added to the end of +the history list as a single entry. + +@item -p +Perform history substitution on the @var{arg}s and display the result +on the standard output, without storing the results in the history list. +@end table + +When the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} option is +used, if @var{filename} +is given, then it is used as the history file. If not, then +the value of the @code{HISTFILE} variable is used. + +@end table @end ifset @node History Interaction -@section Interactive History Expansion +@section History Expansion @cindex history expansion The History library provides a history expansion feature that is similar @@ -121,14 +214,14 @@ arguments to a previous command into the current input line, or fix errors in previous commands quickly. History expansion takes place in two parts. The first is to determine -which line from the previous history should be used during substitution. +which line from the history list should be used during substitution. The second is to select portions of that line for inclusion into the -current one. The line selected from the previous history is called the +current one. The line selected from the history is called the @dfn{event}, and the portions of that line that are acted upon are called @dfn{words}. Various @dfn{modifiers} are available to manipulate the selected words. The line is broken into words in the same fashion -that Bash does, so that several English (or Unix) words -surrounded by quotes are considered as one word. +that Bash does, so that several words +surrounded by quotes are considered one word. History expansions are introduced by the appearance of the history expansion character, which is @samp{!} by default. @ifset BashFeatures @@ -153,6 +246,7 @@ may be used to see what a history expansion will do before using it. The @samp{-s} option to the @code{history} builtin may be used to add commands to the end of the history list without actually executing them, so that they are available for subsequent recall. +This is most useful in conjunction with Readline. The shell allows control of the various characters used by the history expansion mechanism with the @code{histchars} variable. @@ -176,7 +270,7 @@ history list. @item @code{!} Start a history substitution, except when followed by a space, tab, -the end of the line, @key{=} or @key{(}. +the end of the line, @samp{=} or @samp{(}. @item @code{!@var{n}} Refer to command line @var{n}. @@ -210,7 +304,7 @@ The entire command line typed so far. Word designators are used to select desired words from the event. A @samp{:} separates the event specification from the word designator. It -can be omitted if the word designator begins with a @samp{^}, @samp{$}, +may be omitted if the word designator begins with a @samp{^}, @samp{$}, @samp{*}, @samp{-}, or @samp{%}. Words are numbered from the beginning of the line, with the first word being denoted by 0 (zero). Words are inserted into the current line separated by single spaces. diff --git a/contrib/libreadline/doc/readline.3 b/contrib/libreadline/doc/readline.3 index 3d161689d2d4..bb9f75902587 100644 --- a/contrib/libreadline/doc/readline.3 +++ b/contrib/libreadline/doc/readline.3 @@ -6,9 +6,9 @@ .\" Case Western Reserve University .\" chet@ins.CWRU.Edu .\" -.\" Last Change: Wed Feb 5 14:13:22 EST 1997 +.\" Last Change: Thu Feb 19 10:26:47 EST 1998 .\" -.TH READLINE 3 "1997 Feb 5" GNU +.TH READLINE 3 "1998 Feb 19" GNU .\" .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. @@ -159,7 +159,7 @@ command or the text of a macro and a key sequence to which it should be bound. The name may be specified in one of two ways: as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP prefixes, or as a key sequence. -When using the form \fBkeyname\fP:\fIfunction-name\fP or \fImacro\fP, +When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP, .I keyname is the name of a key spelled out in English. For example: .sp @@ -185,7 +185,7 @@ expressed on the right hand side (that is, to insert the text .I >&output into the line). .PP -In the second form, \fB"keyseq"\fP:\fIfunction\-name\fP or \fImacro\fP, +In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, .B keyseq differs from .B keyname @@ -213,8 +213,9 @@ and .I "ESC [ 1 1 ~" is bound to insert the text .BR "Function Key 1" . -The full set of escape sequences is +The full set of GNU Emacs style escape sequences is .RS +.PD 0 .TP .B \eC\- control prefix @@ -234,11 +235,53 @@ literal " .B \e' literal ' .RE +.PD +.PP +In addition to the GNU Emacs style escape sequences, a second +set of backslash escapes is available: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ed +delete +.TP +.B \ef +form feed +.TP +.B \en +newline +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\fInnn\fP +the character whose ASCII code is the octal value \fInnn\fP +(one to three digits) +.TP +.B \ex\fInnn\fP +the character whose ASCII code is the hexadecimal value \fInnn\fP +(one to three digits) +.RE +.PD .PP When entering the text of a macro, single or double quotes should be used to indicate a macro definition. Unquoted text -is assumed to be a function name. Backslash -will quote any character in the macro text, including " and '. +is assumed to be a function name. +In the macro body, the backslash escapes described above are expanded. +Backslash will quote any other character in the macro text, +including " and '. .PP .B Bash allows the current readline key bindings to be displayed or modified @@ -288,6 +331,10 @@ This command is bound to in emacs mode and to .B # in vi command mode. +.TP +.B completion\-ignore\-case (Off) +If set to \fBOn\fP, readline performs filename matching and completion +in a case\-insensitive fashion. .TP .B completion\-query\-items (100) This determines when the user is queried about viewing @@ -346,7 +393,7 @@ the value of also affects the default keymap. .TP .B mark\-directories (On) -If set to \fBOn\fP, completed directory names have a slash +If set to \fBOn\fP, complete output" @end example -In the above example, @samp{C-u} is bound to the function -@code{universal-argument}, and @samp{C-o} is bound to run the macro +In the above example, @key{C-u} is bound to the function +@code{universal-argument}, and @key{C-o} is bound to run the macro expressed on the right hand side (that is, to insert the text @samp{> output} into the line). @@ -486,12 +498,16 @@ special character names are not recognized. "\e[11~": "Function Key 1" @end example -In the above example, @samp{C-u} is bound to the function +In the above example, @key{C-u} is bound to the function @code{universal-argument} (just as it was in the first example), -@samp{C-x C-r} is bound to the function @code{re-read-init-file}, and -@samp{ESC [ 1 1 ~} is bound to insert the text @samp{Function Key 1}. -The following escape sequences are available when specifying key -sequences: +@samp{@key{C-x} @key{C-r}} is bound to the function @code{re-read-init-file}, +and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert +the text @samp{Function Key 1}. + +@end table + +The following GNU Emacs style escape sequences are available when +specifying key sequences: @table @code @item @kbd{\C-} @@ -508,18 +524,46 @@ backslash @key{'} @end table -When entering the text of a macro, single or double quotes should -be used to indicate a macro definition. Unquoted text -is assumed to be a function name. Backslash -will quote any character in the macro text, including @samp{"} -and @samp{'}. +In addition to the GNU Emacs style escape sequences, a second +set of backslash escapes is available: + +@table @code +@item \a +alert (bell) +@item \b +backspace +@item \d +delete +@item \f +form feed +@item \n +newline +@item \r +carriage return +@item \t +horizontal tab +@item \v +vertical tab +@item \@var{nnn} +the character whose ASCII code is the octal value @var{nnn} +(one to three digits) +@item \x@var{nnn} +the character whose ASCII code is the hexadecimal value @var{nnn} +(one to three digits) +@end table + +When entering the text of a macro, single or double quotes must +be used to indicate a macro definition. +Unquoted text is assumed to be a function name. +In the macro body, the backslash escapes described above are expanded. +Backslash will quote any other character in the macro text, +including @samp{"} and @samp{'}. For example, the following binding will make @samp{C-x \} insert a single @samp{\} into the line: @example "\C-x\\": "\\" @end example -@end table @end table @node Conditional Init Constructs @@ -528,7 +572,7 @@ insert a single @samp{\} into the line: Readline implements a facility similar in spirit to the conditional compilation features of the C preprocessor which allows key bindings and variable settings to be performed as the result -of tests. There are three parser directives used. +of tests. There are four parser directives used. @table @code @item $if @@ -550,8 +594,8 @@ Readline is starting out in @code{emacs} mode. The @code{term=} form may be used to include terminal-specific key bindings, perhaps to bind the key sequences output by the terminal's function keys. The word on the right side of the -@samp{=} is tested against the full name of the terminal and the -portion of the terminal name before the first @samp{-}. This +@samp{=} is tested against both the full name of the terminal and +the portion of the terminal name before the first @samp{-}. This allows @code{sun} to match both @code{sun} and @code{sun-cmd}, for instance. @@ -571,12 +615,19 @@ $endif @end table @item $endif -This command, as you saw in the previous example, terminates an +This command, as seen in the previous example, terminates an @code{$if} command. @item $else Commands in this branch of the @code{$if} directive are executed if the test fails. + +@item $include +This directive takes a single filename as an argument and reads commands +and bindings from that file. +@example +$include /etc/inputrc +@end example @end table @node Sample Init File @@ -593,6 +644,11 @@ binding, variable assignment, and conditional syntax. # # You can re-read the inputrc file with C-x C-r. # Lines beginning with '#' are comments. +# +# First, include any systemwide bindings and variable assignments from +# /etc/Inputrc +$include /etc/Inputrc + # # Set various bindings for emacs mode. @@ -738,8 +794,9 @@ Refresh the current line. By default, this is unbound. @ifset BashFeatures Accept the line regardless of where the cursor is. If this line is non-empty, add it to the history list according to the setting of -the @code{HISTCONTROL} variable. If this line was a history -line, then restore the history line to its original state. +the @code{HISTCONTROL} and @code{HISTIGNORE} variables. +If this line was a history line, then restore the history line to its +original state. @end ifset @ifclear BashFeatures Accept the line regardless of where the cursor is. If this line is @@ -757,7 +814,8 @@ Move `down' through the history list. Move to the first line in the history. @item end-of-history (M->) -Move to the end of the input history, i.e., the line you are entering. +Move to the end of the input history, i.e., the line currently +being entered. @item reverse-search-history (C-r) Search backward starting at the current line and moving `up' through @@ -780,7 +838,7 @@ for a string supplied by the user. @item history-search-forward () Search forward through the history for the string of characters between the start of the current line and the current cursor -position (the `point'). This is a non-incremental search. By +position (the @var{point}). This is a non-incremental search. By default, this command is unbound. @item history-search-backward () @@ -799,6 +857,8 @@ inserts the @var{n}th word from the end of the previous command. Insert last argument to the previous command (the last word of the previous history entry). With an argument, behave exactly like @code{yank-nth-arg}. +Successive calls to @code{yank-last-arg} move back through the history +list, inserting the last argument of each line in turn. @end ftable @@ -809,18 +869,21 @@ argument, behave exactly like @code{yank-nth-arg}. @item delete-char (C-d) Delete the character under the cursor. If the cursor is at the beginning of the line, there are no characters in the line, and -the last character typed was not @kbd{C-d}, then return @code{EOF}. +the last character typed was not bound to @code{delete-char}, then +return @code{EOF}. @item backward-delete-char (Rubout) -Delete the character behind the cursor. A numeric arg says to kill -the characters instead of deleting them. +Delete the character behind the cursor. A numeric argument means +to kill the characters instead of deleting them. @item quoted-insert (C-q, C-v) -Add the next character that you type to the line verbatim. This is +Add the next character typed to the line verbatim. This is how to insert key sequences like @key{C-q}, for example. +@ifclear BashFeatures @item tab-insert (M-TAB) Insert a tab character. +@end ifclear @item self-insert (a, b, A, 1, !, ...) Insert yourself. @@ -831,7 +894,7 @@ the character at the cursor, moving the cursor forward as well. If the insertion point is at the end of the line, then this transposes the last two characters of the line. -Negative argumentss don't work. +Negative arguments don't work. @item transpose-words (M-t) Drag the word behind the cursor past the word in front of the cursor @@ -839,15 +902,15 @@ moving the cursor over that word as well. @item upcase-word (M-u) Uppercase the current (or following) word. With a negative argument, -do the previous word, but do not move the cursor. +uppercase the previous word, but do not move the cursor. @item downcase-word (M-l) Lowercase the current (or following) word. With a negative argument, -do the previous word, but do not move the cursor. +lowercase the previous word, but do not move the cursor. @item capitalize-word (M-c) Capitalize the current (or following) word. With a negative argument, -do the previous word, but do not move the cursor. +capitalize the previous word, but do not move the cursor. @end ftable @@ -864,7 +927,7 @@ Kill backward to the beginning of the line. @item unix-line-discard (C-u) Kill backward from the cursor to the beginning of the current line. -Save the killed text on the kill-ring. +The killed text is saved on the kill-ring. @item kill-whole-line () Kill all characters on the current line, no matter where the @@ -888,19 +951,21 @@ Delete all spaces and tabs around point. By default, this is unbound. @item kill-region () Kill the text between the point and the @emph{mark} (saved -cursor position. This text is referred to as the @var{region}. +cursor position). This text is referred to as the @var{region}. By default, this command is unbound. @item copy-region-as-kill () -Copy the text in the region to the kill buffer, so you can yank it +Copy the text in the region to the kill buffer, so it can be yanked right away. By default, this command is unbound. @item copy-backward-word () Copy the word before point to the kill buffer. +The word boundaries are the same as @code{backward-word}. By default, this command is unbound. @item copy-forward-word () Copy the word following point to the kill buffer. +The word boundaries are the same as @code{forward-word}. By default, this command is unbound. @item yank (C-y) @@ -943,8 +1008,8 @@ By default, this is not bound to a key. Attempt to do completion on the text before the cursor. This is application-specific. Generally, if you are typing a filename argument, you can do filename completion; if you are typing a command, -you can do command completion, if you are typing in a symbol to GDB, you -can do symbol name completion, if you are typing in a variable to Bash, +you can do command completion; if you are typing in a symbol to GDB, you +can do symbol name completion; if you are typing in a variable to Bash, you can do variable name completion, and so on. @ifset BashFeatures Bash attempts completion treating the text as a variable (if the @@ -961,6 +1026,19 @@ List the possible completions of the text before the cursor. Insert all completions of the text before point that would have been generated by @code{possible-completions}. +@item menu-complete () +Similar to @code{complete}, but replaces the word to be completed +with a single match from the list of possible completions. +Repeated execution of @code{menu-complete} steps through the list +of possible completions, inserting each match in turn. +At the end of the list of completions, the bell is rung and the +original text is restored. +An argument of @var{n} moves @var{n} positions forward in the list +of matches; a negative argument may be used to move backward +through the list. +This command is intended to be bound to @code{TAB}, but is unbound +by default. + @ifset BashFeatures @item complete-filename (M-/) Attempt filename completion on the text before point. @@ -997,7 +1075,7 @@ treating it as a hostname. Attempt completion on the text before point, treating it as a command name. Command completion attempts to match the text against aliases, reserved words, shell -functions, builtins, and finally executable filenames, +functions, shell builtins, and finally executable filenames, in that order. @item possible-command-completions (C-x !) @@ -1052,7 +1130,7 @@ If the metafied character @var{x} is lowercase, run the command that is bound to the corresponding uppercase character. @item prefix-meta (ESC) -Make the next character that you type be metafied. This is for people +Make the next character typed be metafied. This is for keyboards without a meta key. Typing @samp{ESC f} is equivalent to typing @samp{M-f}. @@ -1060,7 +1138,7 @@ without a meta key. Typing @samp{ESC f} is equivalent to typing Incremental undo, separately remembered for each line. @item revert-line (M-r) -Undo all changes made to this line. This is like typing the @code{undo} +Undo all changes made to this line. This is like executing the @code{undo} command enough times to get back to the beginning. @item tilde-expand (M-~) @@ -1093,18 +1171,18 @@ This makes the current line a shell comment. @item dump-functions () Print all of the functions and their key bindings to the -readline output stream. If a numeric argument is supplied, +Readline output stream. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an @var{inputrc} file. This command is unbound by default. @item dump-variables () Print all of the settable variables and their values to the -readline output stream. If a numeric argument is supplied, +Readline output stream. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an @var{inputrc} file. This command is unbound by default. @item dump-macros () -Print all of the readline key sequences bound to macros and the +Print all of the Readline key sequences bound to macros and the strings they ouput. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an @var{inputrc} file. This command is unbound by default. @@ -1116,24 +1194,27 @@ and the list of matching file names is inserted, replacing the word. @item glob-list-expansions (C-x g) The list of expansions that would have been generated by -@code{glob-expand-word} -is inserted into the line, replacing the word before point. +@code{glob-expand-word} is displayed, and the line is redrawn. @item display-shell-version (C-x C-v) Display version information about the current instance of Bash. @item shell-expand-line (M-C-e) -Expand the line the way the shell does when it reads it. This -performs alias and history expansion as well as all of the shell -word expansions. +Expand the line as the shell does. +This performs alias and history expansion as well as all of the shell +word expansions (@pxref{Shell Expansions}). @item history-expand-line (M-^) Perform history expansion on the current line. -@item alias-expand-line +@item magic-space () +Perform history expansion on the current line and insert a space +(@pxref{History Interaction}). + +@item alias-expand-line () Perform alias expansion on the current line (@pxref{Aliases}). -@item history-and-alias-expand-line +@item history-and-alias-expand-line () Perform history and alias expansion on the current line. @item insert-last-argument (M-., M-_) diff --git a/contrib/libreadline/examples/Makefile.in b/contrib/libreadline/examples/Makefile.in index 8dd7f6237c22..18486736ec9e 100644 --- a/contrib/libreadline/examples/Makefile.in +++ b/contrib/libreadline/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) -fileman.o: $(srcdir)/fileman.c -rltest.o: $(srcdir)/rltest.c -rl.o: $(srcdir)/rl.c +clean mostlyclean: + $(RM) $(OBJECTS) + $(RM) $(EXECUTABLES) + +distclean maintainer-clean: clean + $(RM) Makefile + +fileman.o: fileman.c +rltest.o: rltest.c +rl.o: rl.c diff --git a/contrib/libreadline/examples/rl.c b/contrib/libreadline/examples/rl.c index 6c2f34313ffd..ccddd0fb752a 100644 --- a/contrib/libreadline/examples/rl.c +++ b/contrib/libreadline/examples/rl.c @@ -12,7 +12,7 @@ #define READLINE_LIBRARY #if defined (HAVE_CONFIG_H) -#include +# include #endif #include @@ -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/contrib/libreadline/examples/rltest.c b/contrib/libreadline/examples/rltest.c index ff3ad5cc9ee9..453f8ec2ada2 100644 --- a/contrib/libreadline/examples/rltest.c +++ b/contrib/libreadline/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); } diff --git a/contrib/libreadline/funmap.c b/contrib/libreadline/funmap.c index 702fabd0c88a..3946e0fc26eb 100644 --- a/contrib/libreadline/funmap.c +++ b/contrib/libreadline/funmap.c @@ -94,11 +94,15 @@ static FUNMAP default_funmap[] = { { "kill-line", rl_kill_line }, { "kill-region", rl_kill_region }, { "kill-word", rl_kill_word }, + { "menu-complete", rl_menu_complete }, { "next-history", rl_get_next_history }, { "non-incremental-forward-search-history", rl_noninc_forward_search }, { "non-incremental-reverse-search-history", rl_noninc_reverse_search }, { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again }, { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again }, +#ifdef __CYGWIN32__ + { "paste-from-clipboard", rl_paste_from_clipboard }, +#endif { "possible-completions", rl_possible_completions }, { "previous-history", rl_get_previous_history }, { "quoted-insert", rl_quoted_insert }, diff --git a/contrib/libreadline/histexpand.c b/contrib/libreadline/histexpand.c index de71d78aa81f..0dc179ac7f65 100644 --- a/contrib/libreadline/histexpand.c +++ b/contrib/libreadline/histexpand.c @@ -35,6 +35,9 @@ #endif /* HAVE_STDLIB_H */ #if defined (HAVE_UNISTD_H) +# ifndef _MINIX +# include +# endif # include #endif @@ -47,6 +50,9 @@ #include "history.h" #include "histlib.h" +#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>" +#define HISTORY_QUOTE_CHARACTERS "\"'`" + static char error_pointer; static char *subst_lhs; @@ -823,8 +829,8 @@ history_expand (hstring, output) only_printing = modified = 0; l = strlen (hstring); - /* Grovel the string. Only backslash can quote the history escape - character. We also handle arg specifiers. */ + /* Grovel the string. Only backslash and single quotes can quote the + history escape character. We also handle arg specifiers. */ /* Before we grovel forever, see if the history_expansion_char appears anywhere within the text. */ @@ -852,7 +858,18 @@ history_expand (hstring, output) for (i = 0; string[i]; i++) { cc = string[i + 1]; - if (string[i] == history_expansion_char) + /* The history_comment_char, if set, appearing that the beginning + of a word signifies that the rest of the line should not have + history expansion performed on it. + Skip the rest of the line and break out of the loop. */ + if (history_comment_char && string[i] == history_comment_char && + (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS))) + { + while (string[i]) + i++; + break; + } + else if (string[i] == history_expansion_char) { if (!cc || member (cc, history_no_expand_chars)) continue; @@ -867,6 +884,8 @@ history_expand (hstring, output) else break; } + /* XXX - at some point, might want to extend this to handle + double quotes as well. */ else if (history_quotes_inhibit_expansion && string[i] == '\'') { /* If this is bash, single quotes inhibit history expansion. */ @@ -904,6 +923,8 @@ history_expand (hstring, output) if (tchar == history_expansion_char) tchar = -3; + else if (tchar == history_comment_char) + tchar = -2; switch (tchar) { @@ -939,6 +960,19 @@ history_expand (hstring, output) break; } + case -2: /* history_comment_char */ + if (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS)) + { + temp = xmalloc (l - i + 1); + strcpy (temp, string + i); + ADD_STRING (temp); + free (temp); + i = l; + } + else + ADD_CHAR (string[i]); + break; + case -3: /* history_expansion_char */ cc = string[i + 1]; @@ -1238,7 +1272,7 @@ history_tokenize_internal (string, wind, indp) /* Get word from string + i; */ - if (member (string[i], "\"'`")) + if (member (string[i], HISTORY_QUOTE_CHARACTERS)) delimiter = string[i++]; for (; string[i]; i++) @@ -1262,10 +1296,10 @@ history_tokenize_internal (string, wind, indp) continue; } - if (!delimiter && (member (string[i], " \t\n;&()|<>"))) + if (!delimiter && (member (string[i], HISTORY_WORD_DELIMITERS))) break; - if (!delimiter && member (string[i], "\"'`")) + if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS)) delimiter = string[i]; } diff --git a/contrib/libreadline/histfile.c b/contrib/libreadline/histfile.c index 9f96f1cdd7a0..81dda57d0fe6 100644 --- a/contrib/libreadline/histfile.c +++ b/contrib/libreadline/histfile.c @@ -32,7 +32,9 @@ #include #include -#include +#ifndef _MINIX +# include +#endif #include #include @@ -129,19 +131,31 @@ read_history_range (filename, from, to) int from, to; { register int line_start, line_end; - char *input, *buffer = (char *)NULL; + char *input, *buffer; int file, current_line; struct stat finfo; + size_t file_size; + buffer = (char *)NULL; input = history_filename (filename); file = open (input, O_RDONLY|O_BINARY, 0666); if ((file < 0) || (fstat (file, &finfo) == -1)) goto error_and_exit; - buffer = xmalloc ((int)finfo.st_size + 1); + file_size = (size_t)finfo.st_size; - if (read (file, buffer, finfo.st_size) != finfo.st_size) + /* check for overflow on very large files */ + if (file_size != finfo.st_size || file_size + 1 < file_size) + { +#if defined (EFBIG) + errno = EFBIG; +#endif + goto error_and_exit; + } + + buffer = xmalloc (file_size + 1); + if (read (file, buffer, file_size) != file_size) { error_and_exit: if (file >= 0) @@ -157,15 +171,15 @@ read_history_range (filename, from, to) /* Set TO to larger than end of file if negative. */ if (to < 0) - to = finfo.st_size; + to = file_size; /* Start at beginning of file, work to end. */ line_start = line_end = current_line = 0; /* Skip lines until we are at FROM. */ - while (line_start < finfo.st_size && current_line < from) + while (line_start < file_size && current_line < from) { - for (line_end = line_start; line_end < finfo.st_size; line_end++) + for (line_end = line_start; line_end < file_size; line_end++) if (buffer[line_end] == '\n') { current_line++; @@ -176,7 +190,7 @@ read_history_range (filename, from, to) } /* If there are lines left to gobble, then gobble them now. */ - for (line_end = line_start; line_end < finfo.st_size; line_end++) + for (line_end = line_start; line_end < file_size; line_end++) if (buffer[line_end] == '\n') { buffer[line_end] = '\0'; @@ -209,6 +223,7 @@ history_truncate_file (fname, lines) int file, chars_read; char *buffer, *filename; struct stat finfo; + size_t file_size; buffer = (char *)NULL; filename = history_filename (fname); @@ -217,8 +232,20 @@ history_truncate_file (fname, lines) if (file == -1 || fstat (file, &finfo) == -1) goto truncate_exit; - buffer = xmalloc ((int)finfo.st_size + 1); - chars_read = read (file, buffer, finfo.st_size); + file_size = (size_t)finfo.st_size; + + /* check for overflow on very large files */ + if (file_size != finfo.st_size || file_size + 1 < file_size) + { + close (file); +#if defined (EFBIG) + errno = EFBIG; +#endif + goto truncate_exit; + } + + buffer = xmalloc (file_size + 1); + chars_read = read (file, buffer, file_size); close (file); if (chars_read <= 0) @@ -248,7 +275,7 @@ history_truncate_file (fname, lines) truncate to. */ if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1)) { - write (file, buffer + i, finfo.st_size - i); + write (file, buffer + i, file_size - i); close (file); } diff --git a/contrib/libreadline/history.c b/contrib/libreadline/history.c index fb9d68e7eccd..24c5a49c3596 100644 --- a/contrib/libreadline/history.c +++ b/contrib/libreadline/history.c @@ -38,6 +38,9 @@ #endif /* HAVE_STDLIB_H */ #if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif # include #endif diff --git a/contrib/libreadline/histsearch.c b/contrib/libreadline/histsearch.c index a72a68bf7649..7e98e950acb1 100644 --- a/contrib/libreadline/histsearch.c +++ b/contrib/libreadline/histsearch.c @@ -33,6 +33,9 @@ # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ #if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif # include #endif #if defined (HAVE_STRING_H) diff --git a/contrib/libreadline/isearch.c b/contrib/libreadline/isearch.c index ce2e58ba9061..7decf9595b0f 100644 --- a/contrib/libreadline/isearch.c +++ b/contrib/libreadline/isearch.c @@ -262,7 +262,7 @@ rl_search_history (direction, invoking_key) break; } - if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('g')) + if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G')) { rl_execute_next (c); break; @@ -298,6 +298,21 @@ rl_search_history (direction, invoking_key) free (lines); return 0; +#if 0 + /* delete character from search string. */ + case -3: + if (search_string_index == 0) + ding (); + else + { + search_string[--search_string_index] = '\0'; + /* This is tricky. To do this right, we need to keep a + stack of search positions for the current search, with + sentinels marking the beginning and end. */ + } + break; +#endif + default: /* Add character to search string and continue search. */ if (search_string_index + 2 >= search_string_size) diff --git a/contrib/libreadline/keymaps.h b/contrib/libreadline/keymaps.h index f8d0e2ef0ab2..f6143f86f262 100644 --- a/contrib/libreadline/keymaps.h +++ b/contrib/libreadline/keymaps.h @@ -39,9 +39,9 @@ typedef char **CPPFunction (); /* A keymap contains one entry for each key in the ASCII set. Each entry consists of a type and a pointer. - POINTER is the address of a function to run, or the + FUNCTION is the address of a function to run, or the address of a keymap to indirect through. - TYPE says which kind of thing POINTER is. */ + TYPE says which kind of thing FUNCTION is. */ typedef struct _keymap_entry { char type; Function *function; diff --git a/contrib/libreadline/kill.c b/contrib/libreadline/kill.c index 352f37deb502..a150e3c28d24 100644 --- a/contrib/libreadline/kill.c +++ b/contrib/libreadline/kill.c @@ -495,17 +495,32 @@ rl_yank_pop (count, key) } } -/* Yank the COUNTth argument from the previous history line. */ -int -rl_yank_nth_arg (count, ignore) - int count, ignore; +/* Yank the COUNTh argument from the previous history line, skipping + HISTORY_SKIP lines before looking for the `previous line'. */ +static int +rl_yank_nth_arg_internal (count, ignore, history_skip) + int count, ignore, history_skip; { register HIST_ENTRY *entry; char *arg; + int i; + + if (history_skip) + { + for (i = 0; i < history_skip; i++) + entry = previous_history (); + } entry = previous_history (); if (entry) - next_history (); + { + if (history_skip) + { + for (i = 0; i < history_skip; i++) + next_history (); + } + next_history (); + } else { ding (); @@ -538,6 +553,14 @@ rl_yank_nth_arg (count, ignore) return 0; } +/* Yank the COUNTth argument from the previous history line. */ +int +rl_yank_nth_arg (count, ignore) + int count, ignore; +{ + return (rl_yank_nth_arg_internal (count, ignore, 0)); +} + /* Yank the last argument from the previous history line. This `knows' how rl_yank_nth_arg treats a count of `$'. With an argument, this behaves the same as rl_yank_nth_arg. */ @@ -545,8 +568,67 @@ int rl_yank_last_arg (count, key) int count, key; { - if (rl_explicit_arg) - return (rl_yank_nth_arg (count, key)); + static int history_skip = 0; + static int explicit_arg_p = 0; + static int count_passed = 1; + static int direction = 1; + + if (rl_last_func != rl_yank_last_arg) + { + history_skip = 0; + explicit_arg_p = rl_explicit_arg; + count_passed = count; + direction = 1; + } else - return (rl_yank_nth_arg ('$', key)); + { + rl_do_undo (); + if (count < 1) + direction = -direction; + history_skip += direction; + if (history_skip < 0) + history_skip = 0; + count_passed = count; + } + + if (explicit_arg_p) + return (rl_yank_nth_arg_internal (count, key, history_skip)); + else + return (rl_yank_nth_arg_internal ('$', key, history_skip)); } + +/* A special paste command for users of Cygnus's cygwin32. */ +#if defined (__CYGWIN32__) +#include + +int +rl_paste_from_clipboard (count, key) + int count, key; +{ + char *data, *ptr; + int len; + + if (OpenClipboard (NULL) == 0) + return (0); + + data = (char *)GetClipboardData (CF_TEXT); + if (data) + { + ptr = strchr (data, '\r'); + if (ptr) + { + len = ptr - data; + ptr = xmalloc (len + 1); + ptr[len] = '\0'; + strncpy (ptr, data, len); + } + else + ptr = data; + rl_insert_text (ptr); + if (ptr != data) + free (ptr); + CloseClipboard (); + } + return (0); +} +#endif /* __CYGWIN32__ */ diff --git a/contrib/libreadline/nls.c b/contrib/libreadline/nls.c index 7a00a5f16513..f2d413d59d5a 100644 --- a/contrib/libreadline/nls.c +++ b/contrib/libreadline/nls.c @@ -69,7 +69,8 @@ static char *legal_lang_values[] = "iso88598", "iso88599", "iso885910", - "koi8r", + "koi8r", + "koi8-r", 0 }; diff --git a/contrib/libreadline/parens.c b/contrib/libreadline/parens.c index 50683f95dc1b..2c7251fd9804 100644 --- a/contrib/libreadline/parens.c +++ b/contrib/libreadline/parens.c @@ -101,7 +101,7 @@ rl_insert_close (count, invoking_key) FD_ZERO (&readfds); FD_SET (fileno (rl_instream), &readfds); - timer.tv_sec = 1; + timer.tv_sec = 0; timer.tv_usec = 500; orig_point = rl_point; diff --git a/contrib/libreadline/readline.3 b/contrib/libreadline/readline.3 index 3d161689d2d4..bb9f75902587 100644 --- a/contrib/libreadline/readline.3 +++ b/contrib/libreadline/readline.3 @@ -6,9 +6,9 @@ .\" Case Western Reserve University .\" chet@ins.CWRU.Edu .\" -.\" Last Change: Wed Feb 5 14:13:22 EST 1997 +.\" Last Change: Thu Feb 19 10:26:47 EST 1998 .\" -.TH READLINE 3 "1997 Feb 5" GNU +.TH READLINE 3 "1998 Feb 19" GNU .\" .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. @@ -159,7 +159,7 @@ command or the text of a macro and a key sequence to which it should be bound. The name may be specified in one of two ways: as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP prefixes, or as a key sequence. -When using the form \fBkeyname\fP:\fIfunction-name\fP or \fImacro\fP, +When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP, .I keyname is the name of a key spelled out in English. For example: .sp @@ -185,7 +185,7 @@ expressed on the right hand side (that is, to insert the text .I >&output into the line). .PP -In the second form, \fB"keyseq"\fP:\fIfunction\-name\fP or \fImacro\fP, +In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, .B keyseq differs from .B keyname @@ -213,8 +213,9 @@ and .I "ESC [ 1 1 ~" is bound to insert the text .BR "Function Key 1" . -The full set of escape sequences is +The full set of GNU Emacs style escape sequences is .RS +.PD 0 .TP .B \eC\- control prefix @@ -234,11 +235,53 @@ literal " .B \e' literal ' .RE +.PD +.PP +In addition to the GNU Emacs style escape sequences, a second +set of backslash escapes is available: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ed +delete +.TP +.B \ef +form feed +.TP +.B \en +newline +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\fInnn\fP +the character whose ASCII code is the octal value \fInnn\fP +(one to three digits) +.TP +.B \ex\fInnn\fP +the character whose ASCII code is the hexadecimal value \fInnn\fP +(one to three digits) +.RE +.PD .PP When entering the text of a macro, single or double quotes should be used to indicate a macro definition. Unquoted text -is assumed to be a function name. Backslash -will quote any character in the macro text, including " and '. +is assumed to be a function name. +In the macro body, the backslash escapes described above are expanded. +Backslash will quote any other character in the macro text, +including " and '. .PP .B Bash allows the current readline key bindings to be displayed or modified @@ -288,6 +331,10 @@ This command is bound to in emacs mode and to .B # in vi command mode. +.TP +.B completion\-ignore\-case (Off) +If set to \fBOn\fP, readline performs filename matching and completion +in a case\-insensitive fashion. .TP .B completion\-query\-items (100) This determines when the user is queried about viewing @@ -346,7 +393,7 @@ the value of also affects the default keymap. .TP .B mark\-directories (On) -If set to \fBOn\fP, completed directory names have a slash +If set to \fBOn\fP, complete #endif -/* Stuff for `struct winsize' on various systems. */ -#if defined (HAVE_SYS_STREAM_H) -# include -#endif /* HAVE_SYS_STREAM_H */ -#if defined (HAVE_SYS_PTEM_H) -# include -# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */ -#endif /* HAVE_SYS_PTEM_H */ -#if defined (HAVE_SYS_PTE_H) -# include -#endif /* HAVE_SYS_PTE_H */ +#include "rlwinsize.h" /* Define _POSIX_VDISABLE if we are not using the `new' tty driver and it is not already defined. It is used both to determine if a diff --git a/contrib/libreadline/rlwinsize.h b/contrib/libreadline/rlwinsize.h new file mode 100644 index 000000000000..92b3de174bfc --- /dev/null +++ b/contrib/libreadline/rlwinsize.h @@ -0,0 +1,58 @@ +/* rlwinsize.h -- an attempt to isolate some of the system-specific defines + for `struct winsize' and TIOCGWINSZ. */ + +/* Copyright (C) 1997 Free Software Foundation, Inc. + + This file contains the Readline Library (the Library), a set of + routines for providing Emacs style line input to programs that ask + for it. + + The 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 1, or (at your option) + any later version. + + The 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 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, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if !defined (_RLWINSIZE_H_) +#define _RLWINSIZE_H_ + +#if defined (HAVE_CONFIG_H) +# include "config.h" +#endif + +/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */ + +#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ) +# include +#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */ + +#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) +# include +#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ + +/* Not in either of the standard places, look around. */ +#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) +# if defined (HAVE_SYS_STREAM_H) +# include +# endif /* HAVE_SYS_STREAM_H */ +# if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */ +# include +# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */ +# endif /* HAVE_SYS_PTEM_H */ +# if defined (HAVE_SYS_PTE_H) /* ??? */ +# include +# endif /* HAVE_SYS_PTE_H */ +#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ + +#endif /* _RL_WINSIZE_H */ + + diff --git a/contrib/libreadline/shell.c b/contrib/libreadline/shell.c index eb99c7276e39..553f3c1cc902 100644 --- a/contrib/libreadline/shell.c +++ b/contrib/libreadline/shell.c @@ -27,6 +27,9 @@ #endif #if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif # include #endif /* HAVE_UNISTD_H */ @@ -36,6 +39,12 @@ # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ +#if defined (HAVE_STRING_H) +# include +#else +# include +#endif /* !HAVE_STRING_H */ + extern char *xmalloc (), *xrealloc (); #if !defined (SHELL) diff --git a/contrib/libreadline/support/config.guess b/contrib/libreadline/support/config.guess index 69e6169fa777..0e11ad86e3a7 100755 --- a/contrib/libreadline/support/config.guess +++ b/contrib/libreadline/support/config.guess @@ -153,11 +153,53 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit 0 ;; # end cases added for Bash alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'` + cat <dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 @@ -171,9 +213,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in amiga:OpenBSD:*:*) echo m68k-cbm-openbsd${UNAME_RELEASE} exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -206,9 +272,21 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; - sun3*:SunOS:*:*) + sun3*:SunOS:*:*|sun:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; @@ -230,6 +308,18 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in mac68k:OpenBSD:*:*) echo m68k-apple-openbsd${UNAME_RELEASE} exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + Power?Macintosh:Rhapsody:*:*) + echo powerpc-apple-nextstep${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-unknown-nextstep${UNAME_RELEASE} + exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; @@ -242,6 +332,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; + 2020:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >dummy.c int main (argc, argv) int argc; char **argv; { @@ -266,7 +359,7 @@ EOF echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerux + echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 @@ -372,12 +465,15 @@ EOF hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; - 9000/[3478]??:HP-UX:*:*) + 9000/[34678]??:HP-UX:*:*) case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; - 9000/8?? ) HP_ARCH=hppa1.0 ;; + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/78? | 9000/80[24] | 9000/8[67]1 | 9000/8[78]9 | 9000/893 ) + HP_ARCH=hppa2.0 ;; + 9000/7?? | 9000/8?[13679] | 9000/892 ) + HP_ARCH=hppa1.1 ;; + 9000/[68]?? ) HP_ARCH=hppa1.0 ;; esac HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} @@ -498,6 +594,9 @@ EOF i*:CYGWIN*:*) echo i386-pc-cygwin32 exit 0 ;; + i*:MINGW*:*) + echo i386-pc-mingw32 + exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin32 exit 0 ;; @@ -505,43 +604,127 @@ EOF echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. ld_help_string=`ld --help 2>&1` - if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then - echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0 - elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then - echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 - elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then - echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 - elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then - echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0 - elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then - echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 - elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then - echo "powerpc-unknown-linux-gnu" ; exit 0 - elif test "${UNAME_MACHINE}" = "alpha" ; then - echo alpha-unknown-linux-gnu ; exit 0 - elif test "${UNAME_MACHINE}" = "sparc" ; then - echo sparc-unknown-linux-gnu ; exit 0 - else - # Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us - # useful --help. Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout. - test ! -d /usr/lib/ldscripts/. \ - && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 - # Determine whether the default compiler is a.out or elf + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + LIBC="" + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + + objdump --private-headers dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >dummy.c < +main(argc, argv) + int argc; + char *argv[]; { #ifdef __ELF__ - printf ("%s-pc-linux-gnu\n", argv[1]); +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif #else - printf ("%s-pc-linux-gnuaout\n", argv[1]); + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); #endif return 0; } @@ -554,7 +737,15 @@ EOF i?86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; - i?86:*:4.*:* | i?86:SYSTEM_V:4.*:* | i[34]86:UNIX_SV:4.*:*) + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:* | i?86:UNIX_SV:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else @@ -575,6 +766,11 @@ EOF echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; + pc:*:*:*) + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; @@ -626,7 +822,7 @@ EOF SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; - RM*:SINIX-*:*:*) + RM*:SINIX-*:*:* | RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) @@ -637,6 +833,10 @@ EOF echo ns32k-sni-sysv fi exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -649,6 +849,9 @@ EOF mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} @@ -707,7 +910,7 @@ main () #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); exit (0); #endif diff --git a/contrib/libreadline/support/config.sub b/contrib/libreadline/support/config.sub index e800bb63f416..7541a125fa67 100755 --- a/contrib/libreadline/support/config.sub +++ b/contrib/libreadline/support/config.sub @@ -152,7 +152,7 @@ case $basic_machine in tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \ | arme[lb] | pyramid \ | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ - | alpha | we32k | ns16k | clipper | i370 | sh \ + | hppa2.0 | alpha | we32k | ns16k | clipper | i370 | sh \ | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \ | pdp11 | mips64el | mips64orion | mips64orionel \ | sparc | sparclet | sparclite | sparc64) @@ -174,7 +174,8 @@ case $basic_machine in | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \ | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \ - | hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* \ + | alpha-* | we32k-* | cydra-* | ns16k-* \ | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* | f301-* \ diff --git a/contrib/libreadline/terminal.c b/contrib/libreadline/terminal.c index 5a8df892d8b0..c28669659b02 100644 --- a/contrib/libreadline/terminal.c +++ b/contrib/libreadline/terminal.c @@ -434,13 +434,21 @@ rl_reset_terminal (terminal_name) } /* A function for the use of tputs () */ +#ifdef _MINIX +void +_rl_output_character_function (c) + int c; +{ + putc (c, _rl_out_stream); +} +#else /* !_MINIX */ int _rl_output_character_function (c) int c; { return putc (c, _rl_out_stream); } - +#endif /* !_MINIX */ /* Write COUNT characters from STRING to the output stream. */ void _rl_output_some_chars (string, count) @@ -519,18 +527,11 @@ ding () /* */ /* **************************************************************** */ -static int -outchar (c) - int c; -{ - return putc (c, rl_outstream); -} - void _rl_enable_meta_key () { if (term_has_meta && term_mm) - tputs (term_mm, 1, outchar); + tputs (term_mm, 1, _rl_output_character_function); } void @@ -538,7 +539,7 @@ _rl_control_keypad (on) int on; { if (on && term_ks) - tputs (term_ks, 1, outchar); + tputs (term_ks, 1, _rl_output_character_function); else if (!on && term_ke) - tputs (term_ke, 1, outchar); + tputs (term_ke, 1, _rl_output_character_function); } diff --git a/contrib/libreadline/tilde.c b/contrib/libreadline/tilde.c index fe263a2605c7..3741f9767b23 100644 --- a/contrib/libreadline/tilde.c +++ b/contrib/libreadline/tilde.c @@ -24,6 +24,9 @@ #endif #if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif # include #endif diff --git a/contrib/libreadline/util.c b/contrib/libreadline/util.c index d96b29e8cdf8..fde012edb617 100644 --- a/contrib/libreadline/util.c +++ b/contrib/libreadline/util.c @@ -166,6 +166,58 @@ rl_extend_line_buffer (len) _rl_set_the_line (); } + +/* A function for simple tilde expansion. */ +int +rl_tilde_expand (ignore, key) + int ignore, key; +{ + register int start, end; + char *homedir, *temp; + int len; + + end = rl_point; + start = end - 1; + + if (rl_point == rl_end && rl_line_buffer[rl_point] == '~') + { + homedir = tilde_expand ("~"); + _rl_replace_text (homedir, start, end); + return (0); + } + else if (rl_line_buffer[start] != '~') + { + for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--) + ; + start++; + } + + end = start; + do + end++; + while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end); + + if (whitespace (rl_line_buffer[end]) || end >= rl_end) + end--; + + /* If the first character of the current word is a tilde, perform + tilde expansion and insert the result. If not a tilde, do + nothing. */ + if (rl_line_buffer[start] == '~') + { + len = end - start + 1; + temp = xmalloc (len + 1); + strncpy (temp, rl_line_buffer + start, len); + temp[len] = '\0'; + homedir = tilde_expand (temp); + free (temp); + + _rl_replace_text (homedir, start, end); + } + + return (0); +} + /* **************************************************************** */ /* */ /* String Utility Functions */ @@ -300,3 +352,13 @@ _rl_digit_value (c) { return (isdigit (c) ? c - '0' : c); } + +/* Backwards compatibility, now that savestring has been removed from + all `public' readline header files. */ +#undef _rl_savestring +char * +_rl_savestring (s) + char *s; +{ + return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s))); +} diff --git a/contrib/libreadline/vi_mode.c b/contrib/libreadline/vi_mode.c index c730296d0a57..2f62ec3d480a 100644 --- a/contrib/libreadline/vi_mode.c +++ b/contrib/libreadline/vi_mode.c @@ -615,6 +615,13 @@ _rl_vi_save_insert (up) { int len, start, end; + if (up == 0) + { + if (vi_insert_buffer_size >= 1) + vi_insert_buffer[0] = '\0'; + return; + } + start = up->start; end = up->end; len = end - start + 1;