From: Chet Ramey Date: Wed, 5 Jan 2022 16:05:15 +0000 (-0500) Subject: new readline custom LS_COLORS suffix; fuzzing fixes; completion-display-length changes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5d497730cf7708b6dcb85479f8bdfc748d23ff8;p=thirdparty%2Freadline.git new readline custom LS_COLORS suffix; fuzzing fixes; completion-display-length changes --- diff --git a/CHANGELOG b/CHANGELOG index 51b70df..a18c96d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1431,3 +1431,12 @@ configure.ac, config.h.in - AC_USE_SYSTEM_EXTENSIONS: use instead of AC_AIX and AC_MINIX - AC_HEADER_STDC: removed - BASH_FUNC_CTYPE_NONASCII: removed + + 11/25 + ----- +history.pc.in + - pkgconfig file for history library. From Siteshwar Vashisht + + +configure.ac,MANIFEST,Makefile.in + - support for creating history.pc diff --git a/MANIFEST b/MANIFEST index 5af8d0f..6a7f4f5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -21,6 +21,7 @@ configure f configure.ac f Makefile.in f readline.pc.in f +history.pc.in f ansi_stdlib.h f chardefs.h f colors.h f diff --git a/Makefile.in b/Makefile.in index c57db60..2120daa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -149,7 +149,7 @@ DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT) CREATED_MAKEFILES = Makefile doc/Makefile examples/Makefile shlib/Makefile CREATED_CONFIGURE = config.status config.h config.cache config.log \ - stamp-config stamp-h readline.pc + stamp-config stamp-h readline.pc history.pc CREATED_TAGS = TAGS tags INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h \ @@ -243,10 +243,11 @@ maybe-uninstall-headers: uninstall-headers install-pc: installdirs -$(INSTALL_DATA) $(BUILD_DIR)/readline.pc $(DESTDIR)$(pkgconfigdir)/readline.pc + -$(INSTALL_DATA) $(BUILD_DIR)/history.pc $(DESTDIR)$(pkgconfigdir)/history.pc uninstall-pc: -test -n "$(pkgconfigdir)" && cd $(DESTDIR)$(pkgconfigdir) && \ - ${RM} readline.pc + ${RM} readline.pc history.pc maybe-uninstall-pc: uninstall-pc @@ -324,6 +325,9 @@ distclean maintainer-clean: clean readline.pc: config.status $(srcdir)/readline.pc.in $(SHELL) config.status +history.pc: config.status $(srcdir)/history.pc.in + $(SHELL) config.status + info dvi html pdf ps: -( cd doc && $(MAKE) $(MFLAGS) $@ ) diff --git a/aclocal.m4 b/aclocal.m4 index be478a2..15d9143 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -3,55 +3,8 @@ dnl Bash specific tests dnl dnl Some derived from PDKSH 5.1.3 autoconf tests dnl - -AC_DEFUN(BASH_C_LONG_LONG, -[AC_CACHE_CHECK(for long long, ac_cv_c_long_long, -[if test "$GCC" = yes; then - ac_cv_c_long_long=yes -else -AC_TRY_RUN([ -#include -int -main() -{ -long long foo = 0; -exit(sizeof(long long) < sizeof(long)); -} -], ac_cv_c_long_long=yes, ac_cv_c_long_long=no) -fi]) -if test $ac_cv_c_long_long = yes; then - AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the `long long' type works.]) -fi -]) - +dnl Copyright (C) 1987-2021 Free Software Foundation, Inc. dnl -dnl This is very similar to AC_C_LONG_DOUBLE, with the fix for IRIX -dnl (< changed to <=) added. -dnl -AC_DEFUN(BASH_C_LONG_DOUBLE, -[AC_CACHE_CHECK(for long double, ac_cv_c_long_double, -[if test "$GCC" = yes; then - ac_cv_c_long_double=yes -else -AC_TRY_RUN([ -#include -int -main() -{ - /* The Stardent Vistra knows sizeof(long double), but does not - support it. */ - long double foo = 0.0; - /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ - /* On IRIX 5.3, the compiler converts long double to double with a warning, - but compiles this successfully. */ - exit(sizeof(long double) <= sizeof(double)); -} -], ac_cv_c_long_double=yes, ac_cv_c_long_double=no) -fi]) -if test $ac_cv_c_long_double = yes; then - AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if the `long double' type works.]) -fi -]) dnl dnl Check for . This is separated out so that it can be @@ -108,30 +61,13 @@ dnl AC_DEFUN(BASH_CHECK_DECL, [ AC_REQUIRE([BASH_HEADER_INTTYPES]) -AC_CACHE_CHECK([for declaration of $1], bash_cv_decl_$1, -[AC_TRY_LINK( -[ -#if HAVE_STDLIB_H -# include -#endif -#if HAVE_INTTYPES_H -# include -#endif -], -[return !$1;], -bash_cv_decl_$1=yes, bash_cv_decl_$1=no)]) -bash_tr_func=HAVE_DECL_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` -if test $bash_cv_decl_$1 = yes; then - AC_DEFINE_UNQUOTED($bash_tr_func, 1) -else - AC_DEFINE_UNQUOTED($bash_tr_func, 0) -fi +AC_CHECK_DECLS([$1]) ]) AC_DEFUN(BASH_DECL_PRINTF, [AC_MSG_CHECKING(for declaration of printf in ) AC_CACHE_VAL(bash_cv_printf_declared, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #ifdef __STDC__ typedef int (*_bashfunc)(const char *, ...); @@ -146,7 +82,7 @@ _bashfunc pf; pf = (_bashfunc) printf; exit(pf == 0); } -], bash_cv_printf_declared=yes, bash_cv_printf_declared=no, +]])], [bash_cv_printf_declared=yes], [bash_cv_printf_declared=no], [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes) bash_cv_printf_declared=yes] )]) @@ -173,13 +109,13 @@ 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([ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #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, +#endif]], [[ char *msg = _sys_siglist[2]; ]])], + [bash_cv_decl_under_sys_siglist=yes], [bash_cv_decl_under_sys_siglist=no], [AC_MSG_WARN(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 @@ -191,7 +127,7 @@ AC_DEFUN(BASH_UNDER_SYS_SIGLIST, [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([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #ifdef HAVE_UNISTD_H @@ -206,10 +142,12 @@ main() { char *msg = (char *)_sys_siglist[2]; exit(msg == 0); -}], - bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no, +} +]])], + [bash_cv_under_sys_siglist=yes], [bash_cv_under_sys_siglist=no], [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no) - bash_cv_under_sys_siglist=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) @@ -231,7 +169,7 @@ AC_DEFUN(BASH_SYS_SIGLIST, [AC_REQUIRE([BASH_DECL_SYS_SIGLIST]) AC_MSG_CHECKING([for sys_siglist in system C library]) AC_CACHE_VAL(bash_cv_sys_siglist, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #ifdef HAVE_UNISTD_H @@ -246,10 +184,11 @@ main() { char *msg = sys_siglist[2]; exit(msg == 0); -}], - bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no, +} +]])], [bash_cv_sys_siglist=yes], [bash_cv_sys_siglist=no], [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no) - bash_cv_sys_siglist=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) @@ -274,11 +213,15 @@ dnl Check for sys_errlist[] and sys_nerr, check for declaration AC_DEFUN(BASH_SYS_ERRLIST, [AC_MSG_CHECKING([for sys_errlist and sys_nerr]) AC_CACHE_VAL(bash_cv_sys_errlist, -[AC_TRY_LINK([#include ], -[extern char *sys_errlist[]; - extern int sys_nerr; - char *msg = sys_errlist[sys_nerr - 1];], - bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]],[[ +extern char *sys_errlist[]; +extern int sys_nerr; +char *msg = sys_errlist[sys_nerr - 1]; +]] )], +[bash_cv_sys_errlist=yes], [bash_cv_sys_errlist=no] +)]) AC_MSG_RESULT($bash_cv_sys_errlist) if test $bash_cv_sys_errlist = yes; then AC_DEFINE(HAVE_SYS_ERRLIST) @@ -291,7 +234,7 @@ dnl AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK, [AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag) AC_CACHE_VAL(bash_cv_dup2_broken, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -309,10 +252,10 @@ main() /* fl will be 1 if dup2 did not reset the close-on-exec flag. */ exit(fl != 1); } -], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no, +]])], [bash_cv_dup2_broken=yes], [bash_cv_dup2_broken=no], [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no) - bash_cv_dup2_broken=no]) -]) + bash_cv_dup2_broken=no] +)]) AC_MSG_RESULT($bash_cv_dup2_broken) if test $bash_cv_dup2_broken = yes; then AC_DEFINE(DUP2_BROKEN) @@ -322,11 +265,12 @@ fi AC_DEFUN(BASH_FUNC_STRSIGNAL, [AC_MSG_CHECKING([for the existence of strsignal]) AC_CACHE_VAL(bash_cv_have_strsignal, -[AC_TRY_LINK([#include +[AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include #include -#include ], -[char *s = (char *)strsignal(2);], - bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)]) +#include ]], +[[char *s = (char *)strsignal(2);]])], + [bash_cv_have_strsignal=yes], [bash_cv_have_strsignal=no])]) AC_MSG_RESULT($bash_cv_have_strsignal) if test $bash_cv_have_strsignal = yes; then AC_DEFINE(HAVE_STRSIGNAL) @@ -338,7 +282,7 @@ AC_DEFUN(BASH_FUNC_OPENDIR_CHECK, [AC_REQUIRE([AC_HEADER_DIRENT])dnl AC_MSG_CHECKING(if opendir() opens non-directories) AC_CACHE_VAL(bash_cv_opendir_not_robust, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -381,7 +325,8 @@ dir = opendir("bash-aclocal/not_a_directory"); unlink("bash-aclocal/not_a_directory"); rmdir("bash-aclocal"); exit (dir == 0); -}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no, +} +]])], [bash_cv_opendir_not_robust=yes], [bash_cv_opendir_not_robust=no], [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no) bash_cv_opendir_not_robust=no] )]) @@ -391,26 +336,6 @@ AC_DEFINE(OPENDIR_NOT_ROBUST) fi ]) -dnl -AC_DEFUN(BASH_TYPE_SIGHANDLER, -[AC_MSG_CHECKING([whether signal handlers are of type void]) -AC_CACHE_VAL(bash_cv_void_sighandler, -[AC_TRY_COMPILE([#include -#include -#ifdef signal -#undef signal -#endif -#ifdef __cplusplus -extern "C" -#endif -void (*signal ()) ();], -[int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl -AC_MSG_RESULT($bash_cv_void_sighandler) -if test $bash_cv_void_sighandler = yes; then -AC_DEFINE(VOID_SIGHANDLER) -fi -]) - dnl dnl A signed 16-bit integer quantity dnl @@ -498,82 +423,98 @@ else fi ]) -AC_DEFUN(BASH_TYPE_LONG_LONG, -[ -AC_CACHE_CHECK([for long long], bash_cv_type_long_long, -[AC_TRY_LINK([ -long long ll = 1; int i = 63;], -[ -long long llm = (long long) -1; -return ll << i | ll >> i | llm / ll | llm % ll; -], bash_cv_type_long_long='long long', bash_cv_type_long_long='long')]) -if test "$bash_cv_type_long_long" = 'long long'; then - AC_DEFINE(HAVE_LONG_LONG, 1) -fi +AC_DEFUN(BASH_SIZEOF_RLIMIT, +[AC_MSG_CHECKING(for size of struct rlimit fields) +AC_CACHE_VAL(bash_cv_sizeof_rlim_cur, +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#ifdef HAVE_SYS_TIME_H +#include +#endif +#include +#include +main() +{ +struct rlimit r; +exit(sizeof (r.rlim_cur)); +} +]])], [bash_cv_sizeof_rlim_cur=$?], [bash_cv_sizeof_rlim_cur=$?], + [AC_MSG_WARN(cannot check size of rlimit fields if cross compiling -- defaulting to long) + bash_cv_sizeof_rlim_cur=$ac_cv_sizeof_long] +)]) +AC_MSG_RESULT($bash_cv_sizeof_rlim_cur) ]) -AC_DEFUN(BASH_TYPE_UNSIGNED_LONG_LONG, -[ -AC_CACHE_CHECK([for unsigned long long], bash_cv_type_unsigned_long_long, -[AC_TRY_LINK([ -unsigned long long ull = 1; int i = 63;], -[ -unsigned long long ullmax = (unsigned long long) -1; -return ull << i | ull >> i | ullmax / ull | ullmax % ull; -], bash_cv_type_unsigned_long_long='unsigned long long', - bash_cv_type_unsigned_long_long='unsigned long')]) -if test "$bash_cv_type_unsigned_long_long" = 'unsigned long long'; then - AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1) -fi +AC_DEFUN(BASH_SIZEOF_QUAD_T, +[AC_MSG_CHECKING(for size of quad_t) +AC_CACHE_VAL(bash_cv_sizeof_quad_t, +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif + +main() +{ +#if HAVE_QUAD_T +quad_t x; +exit(sizeof (x)); +#else +exit (0); +#endif +} +]])], [bash_cv_sizeof_quad_t=$?], [bash_cv_sizeof_quad_t=$?], + [AC_MSG_WARN(cannot check size of quad_t if cross compiling -- defaulting to 0) + bash_cv_sizeof_quad_t=0] +)]) +AC_MSG_RESULT($bash_cv_sizeof_quad_t) ]) dnl -dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0) -dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use -dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3). To simplify -dnl matters, this just checks for rlim_t, quad_t, or long. +dnl Type of struct rlimit fields: updated to check POSIX rlim_t and +dnl if it doesn't exist determine the best guess based on sizeof(r.rlim_cur) dnl AC_DEFUN(BASH_TYPE_RLIMIT, -[AC_MSG_CHECKING(for size and type of struct rlimit fields) +[AC_MSG_CHECKING(for type of struct rlimit fields) AC_CACHE_VAL(bash_cv_type_rlimit, -[AC_TRY_COMPILE([#include -#include ], -[rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[ -AC_TRY_RUN([ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include -#include -#include -#include -int -main() -{ -#ifdef HAVE_QUAD_T - struct rlimit rl; - if (sizeof(rl.rlim_cur) == sizeof(quad_t)) - exit(0); -#endif - exit(1); -}], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long, - [AC_MSG_WARN(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 -AC_DEFINE(RLIMTYPE, quad_t) -elif test $bash_cv_type_rlimit = rlim_t; then -AC_DEFINE(RLIMTYPE, rlim_t) +#include ]], +[[rlim_t xxx;]] +)], + [bash_cv_type_rlimit=rlim_t], [ +BASH_SIZEOF_RLIMIT +BASH_SIZEOF_QUAD_T +if test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long; then + bash_cv_type_rlimit='unsigned long' +elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_long_long; then + bash_cv_type_rlimit='unsigned long long' +elif test $bash_cv_sizeof_rlim_cur = $ac_cv_sizeof_int; then + bash_cv_type_rlimit='unsigned int' +elif test $bash_cv_sizeof_rlim_cur = $bash_cv_sizeof_quad_t; then + bash_cv_type_rlimit='quad_t' +else + bash_cv_type_rlimit='unsigned long' fi +] +)]) +AC_MSG_RESULT($bash_cv_type_rlimit) +AC_DEFINE_UNQUOTED([RLIMTYPE], [$bash_cv_type_rlimit]) ]) AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T, [AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t, -[AC_TRY_LINK([ -#include -],[ sig_atomic_t x; ], -ac_cv_have_sig_atomic_t=yes, ac_cv_have_sig_atomic_t=no)]) +[AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ #include ]], + [[ sig_atomic_t x; ]])], + [ac_cv_have_sig_atomic_t=yes],[ac_cv_have_sig_atomic_t=no])]) if test "$ac_cv_have_sig_atomic_t" = "no" then - AC_CHECK_TYPE(sig_atomic_t,int) + BASH_CHECK_TYPE(sig_atomic_t, [#include ], int) fi ]) @@ -581,11 +522,13 @@ AC_DEFUN(BASH_FUNC_LSTAT, [dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an dnl inline function in . AC_CACHE_CHECK([for lstat], bash_cv_func_lstat, -[AC_TRY_LINK([ -#include -#include -],[ lstat(".",(struct stat *)0); ], -bash_cv_func_lstat=yes, bash_cv_func_lstat=no)]) +[AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ + #include + #include + ]], + [[ 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) fi @@ -594,12 +537,12 @@ fi AC_DEFUN(BASH_FUNC_INET_ATON, [ AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton, -[AC_TRY_LINK([ +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include #include -struct in_addr ap;], [ inet_aton("127.0.0.1", &ap); ], -bash_cv_func_inet_aton=yes, bash_cv_func_inet_aton=no)]) +struct in_addr ap;]], [[ inet_aton("127.0.0.1", &ap); ]])], +[bash_cv_func_inet_aton=yes], [bash_cv_func_inet_aton=no])]) if test $bash_cv_func_inet_aton = yes; then AC_DEFINE(HAVE_INET_ATON) else @@ -610,7 +553,7 @@ fi AC_DEFUN(BASH_FUNC_GETENV, [AC_MSG_CHECKING(to see if getenv can be redefined) AC_CACHE_VAL(bash_cv_getenv_redef, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #ifdef HAVE_UNISTD_H # include #endif @@ -643,7 +586,7 @@ exit(1); s = getenv("ABCDE"); exit(s == 0); /* force optimizer to leave getenv in */ } -], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no, +]])], [bash_cv_getenv_redef=yes], [bash_cv_getenv_redef=no], [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes) bash_cv_getenv_redef=yes] )]) @@ -658,7 +601,7 @@ AC_DEFUN(BASH_FUNC_STD_PUTENV, [ AC_REQUIRE([AC_C_PROTOTYPES]) AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv, -[AC_TRY_LINK([ +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_STDLIB_H #include #endif @@ -675,9 +618,8 @@ extern int putenv (char *); #else extern int putenv (); #endif -], -[return (putenv == 0);], -bash_cv_std_putenv=yes, bash_cv_std_putenv=no +]], [[return (putenv == 0);]] )], +[bash_cv_std_putenv=yes], [bash_cv_std_putenv=no] )]) if test $bash_cv_std_putenv = yes; then AC_DEFINE(HAVE_STD_PUTENV) @@ -689,7 +631,7 @@ AC_DEFUN(BASH_FUNC_STD_UNSETENV, [ AC_REQUIRE([AC_C_PROTOTYPES]) AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv, -[AC_TRY_LINK([ +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #if HAVE_STDLIB_H #include #endif @@ -706,9 +648,8 @@ extern int unsetenv (const char *); #else extern int unsetenv (); #endif -], -[return (unsetenv == 0);], -bash_cv_std_unsetenv=yes, bash_cv_std_unsetenv=no +]], [[return (unsetenv == 0);]] )], +[bash_cv_std_unsetenv=yes], [bash_cv_std_unsetenv=no] )]) if test $bash_cv_std_unsetenv = yes; then AC_DEFINE(HAVE_STD_UNSETENV) @@ -718,7 +659,7 @@ fi AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS, [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize) AC_CACHE_VAL(bash_cv_ulimit_maxfds, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #ifdef HAVE_ULIMIT_H #include @@ -729,7 +670,7 @@ main() long maxfds = ulimit(4, 0L); exit (maxfds == -1L); } -], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no, +]])], [bash_cv_ulimit_maxfds=yes], [bash_cv_ulimit_maxfds=no], [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no) bash_cv_ulimit_maxfds=no] )]) @@ -742,7 +683,7 @@ fi AC_DEFUN(BASH_FUNC_GETCWD, [AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size]) AC_CACHE_VAL(bash_cv_getcwd_malloc, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #ifdef HAVE_UNISTD_H #include @@ -756,7 +697,7 @@ main() xpwd = getcwd(0, 0); exit (xpwd == 0); } -], bash_cv_getcwd_malloc=yes, bash_cv_getcwd_malloc=no, +]])], [bash_cv_getcwd_malloc=yes], [bash_cv_getcwd_malloc=no], [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no) bash_cv_getcwd_malloc=no] )]) @@ -769,7 +710,7 @@ fi dnl dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every -dnl system, we can't use AC_PREREQ +dnl system, we can't use AC_PREREQ. Only called if we need the socket library dnl AC_DEFUN(BASH_FUNC_GETHOSTBYNAME, [if test "X$bash_cv_have_gethostbyname" = "X"; then @@ -779,11 +720,14 @@ AC_MSG_CHECKING(for gethostbyname in socket library) _bash_needmsg= fi AC_CACHE_VAL(bash_cv_have_gethostbyname, -[AC_TRY_LINK([#include ], -[ struct hostent *hp; - hp = gethostbyname("localhost"); -], bash_cv_have_gethostbyname=yes, bash_cv_have_gethostbyname=no)] -) +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ +struct hostent *hp; +hp = gethostbyname("localhost"); +]] )], +[bash_cv_have_gethostbyname=yes], [bash_cv_have_gethostbyname=no] +)]) if test "X$_bash_needmsg" = Xyes; then AC_MSG_CHECKING(for gethostbyname in socket library) fi @@ -796,7 +740,7 @@ fi AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH, [AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH) AC_CACHE_VAL(bash_cv_fnm_extmatch, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include int @@ -808,10 +752,10 @@ main() return (1); #endif } -], bash_cv_fnm_extmatch=yes, bash_cv_fnm_extmatch=no, +]])], [bash_cv_fnm_extmatch=yes], [bash_cv_fnm_extmatch=no], [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no) - bash_cv_fnm_extmatch=no]) -]) + bash_cv_fnm_extmatch=no] +)]) AC_MSG_RESULT($bash_cv_fnm_extmatch) if test $bash_cv_fnm_extmatch = yes; then AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH) @@ -822,7 +766,7 @@ AC_DEFUN(BASH_FUNC_POSIX_SETJMP, [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp) AC_CACHE_VAL(bash_cv_func_sigsetjmp, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #ifdef HAVE_UNISTD_H #include #endif @@ -839,21 +783,30 @@ exit (1); #else int code; -sigset_t set, oset; +sigset_t set, oset, nset; sigjmp_buf xx; /* get the mask */ sigemptyset(&set); sigemptyset(&oset); -sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set); + sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset); +/* paranoia -- make sure SIGINT is not blocked */ +sigdelset (&oset, SIGINT); +sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); /* save it */ code = sigsetjmp(xx, 1); if (code) - exit(0); /* could get sigmask and compare to oset here. */ +{ + sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &nset); + /* could compare nset to oset here, but we just look for SIGINT */ + if (sigismember (&nset, SIGINT)) + exit(1); + exit(0); +} -/* change it */ +/* change it so that SIGINT is blocked */ sigaddset(&set, SIGINT); sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL); @@ -861,9 +814,14 @@ 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_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing) - bash_cv_func_sigsetjmp=missing] +} +]])], [bash_cv_func_sigsetjmp=present], [bash_cv_func_sigsetjmp=missing], + [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to $bash_cv_posix_signals) + if test "$bash_cv_posix_signals" = "yes" ; then + bash_cv_func_sigsetjmp=present + else + bash_cv_func_sigsetjmp=missing + fi] )]) AC_MSG_RESULT($bash_cv_func_sigsetjmp) if test $bash_cv_func_sigsetjmp = present; then @@ -872,10 +830,9 @@ fi ]) AC_DEFUN(BASH_FUNC_STRCOLL, -[ -AC_MSG_CHECKING(whether or not strcoll and strcmp differ) +[AC_MSG_CHECKING(whether or not strcoll and strcmp differ) AC_CACHE_VAL(bash_cv_func_strcoll_broken, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #if defined (HAVE_LOCALE_H) #include @@ -913,7 +870,7 @@ char *v[]; in the default locale. */ exit (r1 > 0 && r2 > 0); } -], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no, +]])], [bash_cv_func_strcoll_broken=yes], [bash_cv_func_strcoll_broken=no], [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no) bash_cv_func_strcoll_broken=no] )]) @@ -926,7 +883,7 @@ fi AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT, [AC_MSG_CHECKING([for printf floating point output in hex notation]) AC_CACHE_VAL(bash_cv_printf_a_format, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -940,7 +897,7 @@ main() sprintf(abuf, "%A", y); exit(strchr(abuf, 'P') == (char *)0); } -], bash_cv_printf_a_format=yes, bash_cv_printf_a_format=no, +]])], [bash_cv_printf_a_format=yes], [bash_cv_printf_a_format=no], [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no) bash_cv_printf_a_format=no] )]) @@ -977,12 +934,10 @@ AC_DEFUN(BASH_STRUCT_ST_BLOCKS, [ AC_MSG_CHECKING([for struct stat.st_blocks]) AC_CACHE_VAL(bash_cv_struct_stat_st_blocks, -[AC_TRY_COMPILE( -[ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include -], -[ +]], [[ int main() { @@ -990,7 +945,7 @@ static struct stat a; if (a.st_blocks) return 0; return 0; } -], bash_cv_struct_stat_st_blocks=yes, bash_cv_struct_stat_st_blocks=no) +]])], [bash_cv_struct_stat_st_blocks=yes], [bash_cv_struct_stat_st_blocks=no]) ]) AC_MSG_RESULT($bash_cv_struct_stat_st_blocks) if test "$bash_cv_struct_stat_st_blocks" = "yes"; then @@ -1090,11 +1045,12 @@ if test $bash_cv_have_socklib = yes; then fi ]) -AC_DEFUN(BASH_STRUCT_DIRENT_D_INO, -[AC_REQUIRE([AC_HEADER_DIRENT]) -AC_MSG_CHECKING(for struct dirent.d_ino) -AC_CACHE_VAL(bash_cv_dirent_has_dino, -[AC_TRY_COMPILE([ +dnl like _AC_STRUCT_DIRENT(MEMBER) but public +AC_DEFUN(BASH_STRUCT_DIRENT, +[ +AC_REQUIRE([AC_HEADER_DIRENT]) +AC_CHECK_MEMBERS(struct dirent.$1, bash_cv_dirent_has_$1=yes, bash_cv_dirent_has_$1=no, +[[ #include #include #ifdef HAVE_UNISTD_H @@ -1114,11 +1070,15 @@ AC_CACHE_VAL(bash_cv_dirent_has_dino, # include # endif #endif /* HAVE_DIRENT_H */ -],[ -struct dirent d; int z; z = d.d_ino; -], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)]) -AC_MSG_RESULT($bash_cv_dirent_has_dino) -if test $bash_cv_dirent_has_dino = yes; then +]]) +]) + +AC_DEFUN(BASH_STRUCT_DIRENT_D_INO, +[AC_REQUIRE([AC_HEADER_DIRENT]) +AC_MSG_CHECKING(for struct dirent.d_ino) +AC_CACHE_VAL(bash_cv_dirent_has_d_ino, [BASH_STRUCT_DIRENT([d_ino])]) +AC_MSG_RESULT($bash_cv_dirent_has_d_ino) +if test $bash_cv_dirent_has_d_ino = yes; then AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO) fi ]) @@ -1126,30 +1086,7 @@ fi AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO, [AC_REQUIRE([AC_HEADER_DIRENT]) AC_MSG_CHECKING(for struct dirent.d_fileno) -AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, -[AC_TRY_COMPILE([ -#include -#include -#ifdef HAVE_UNISTD_H -# include -#endif /* HAVE_UNISTD_H */ -#if defined(HAVE_DIRENT_H) -# include -#else -# define dirent direct -# ifdef HAVE_SYS_NDIR_H -# include -# endif /* SYSNDIR */ -# ifdef HAVE_SYS_DIR_H -# include -# endif /* SYSDIR */ -# ifdef HAVE_NDIR_H -# include -# endif -#endif /* HAVE_DIRENT_H */ -],[ -struct dirent d; int z; z = d.d_fileno; -], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)]) +AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, [BASH_STRUCT_DIRENT([d_fileno])]) AC_MSG_RESULT($bash_cv_dirent_has_d_fileno) if test $bash_cv_dirent_has_d_fileno = yes; then AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO) @@ -1159,30 +1096,7 @@ fi AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN, [AC_REQUIRE([AC_HEADER_DIRENT]) AC_MSG_CHECKING(for struct dirent.d_namlen) -AC_CACHE_VAL(bash_cv_dirent_has_d_namlen, -[AC_TRY_COMPILE([ -#include -#include -#ifdef HAVE_UNISTD_H -# include -#endif /* HAVE_UNISTD_H */ -#if defined(HAVE_DIRENT_H) -# include -#else -# define dirent direct -# ifdef HAVE_SYS_NDIR_H -# include -# endif /* SYSNDIR */ -# ifdef HAVE_SYS_DIR_H -# include -# endif /* SYSDIR */ -# ifdef HAVE_NDIR_H -# include -# endif -#endif /* HAVE_DIRENT_H */ -],[ -struct dirent d; int z; z = d.d_namlen; -], bash_cv_dirent_has_d_namlen=yes, bash_cv_dirent_has_d_namlen=no)]) +AC_CACHE_VAL(bash_cv_dirent_has_d_namlen, [BASH_STRUCT_DIRENT([d_namlen])]) AC_MSG_RESULT($bash_cv_dirent_has_d_namlen) if test $bash_cv_dirent_has_d_namlen = yes; then AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN) @@ -1226,16 +1140,47 @@ if test $bash_cv_struct_timezone = yes; then fi ]) +AC_DEFUN(BASH_CHECK_WINSIZE_IOCTL, +[AC_CACHE_VAL(bash_cv_struct_winsize_ioctl, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +]], +[[ +struct winsize x; +if (sizeof (x) > 0) return (0); +]] )], [bash_cv_struct_winsize_ioctl=yes], [bash_cv_struct_winsize_ioctl=no]) +]) +]) + +AC_DEFUN(BASH_CHECK_WINSIZE_TERMIOS, +[AC_CACHE_VAL(bash_cv_struct_winsize_termios, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +]], +[[ +struct winsize x; +if (sizeof (x) > 0) return (0); +]] )], [bash_cv_struct_winsize_termios=yes], [bash_cv_struct_winsize_termios=no]) +]) +]) + AC_DEFUN(BASH_STRUCT_WINSIZE, [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_header=ioctl_h, - [AC_TRY_COMPILE([#include -#include ], [struct winsize x;], - bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other) -])]) +[ +BASH_CHECK_WINSIZE_IOCTL +BASH_CHECK_WINSIZE_TERMIOS + +if test $bash_cv_struct_winsize_ioctl = yes; then + bash_cv_struct_winsize_header=ioctl_h +elif test $bash_cv_struct_winsize_termios = yes; then + bash_cv_struct_winsize_header=termios_h +else + bash_cv_struct_winsize_header=other +fi +]) if test $bash_cv_struct_winsize_header = ioctl_h; then AC_MSG_RESULT(sys/ioctl.h) AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL) @@ -1247,35 +1192,68 @@ else fi ]) -dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7) -AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE, -[AC_REQUIRE([AC_TYPE_SIGNAL]) -AC_MSG_CHECKING(for type of signal functions) -AC_CACHE_VAL(bash_cv_signal_vintage, -[ - AC_TRY_LINK([#include ],[ +AC_DEFUN(BASH_HAVE_POSIX_SIGNALS, +[AC_CACHE_VAL(bash_cv_posix_signals, +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ sigset_t ss; struct sigaction sa; sigemptyset(&ss); sigsuspend(&ss); sigaction(SIGINT, &sa, (struct sigaction *) 0); sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0); - ], bash_cv_signal_vintage=posix, - [ - AC_TRY_LINK([#include ], [ - int mask = sigmask(SIGINT); - sigsetmask(mask); sigblock(mask); sigpause(mask); - ], bash_cv_signal_vintage=4.2bsd, - [ - AC_TRY_LINK([ - #include - RETSIGTYPE foo() { }], [ - int mask = sigmask(SIGINT); - sigset(SIGINT, foo); sigrelse(SIGINT); - sighold(SIGINT); sigpause(SIGINT); - ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7 - )] - )] -) +]] )], +[bash_cv_posix_signals=yes], [bash_cv_posix_signals=no] +)]) +]) + +AC_DEFUN(BASH_HAVE_BSD_SIGNALS, +[AC_CACHE_VAL(bash_cv_bsd_signals, +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ +int mask = sigmask(SIGINT); +sigsetmask(mask); sigblock(mask); sigpause(mask); +]] )], +[bash_cv_bsd_signals=yes], [bash_cv_bsd_signals=no] +)]) +]) + +AC_DEFUN(BASH_HAVE_SYSV_SIGNALS, +[AC_CACHE_VAL(bash_cv_sysv_signals, +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +void foo() { } +]], [[ +int mask = sigmask(SIGINT); +sigset(SIGINT, foo); sigrelse(SIGINT); +sighold(SIGINT); sigpause(SIGINT); +]] )], +[bash_cv_sysv_signals=yes], [bash_cv_sysv_signals=no] +)]) +]) + +dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7) +AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE, +[AC_MSG_CHECKING(for type of signal functions) +AC_CACHE_VAL(bash_cv_signal_vintage, +[ +BASH_HAVE_POSIX_SIGNALS +if test $bash_cv_posix_signals = yes; then + bash_cv_signal_vintage=posix +else + BASH_HAVE_BSD_SIGNALS + if test $bash_cv_bsd_signals = yes; then + bash_cv_signal_vintage=4.2bsd + else + BASH_HAVE_SYSV_SIGNALS + if test $bash_cv_sysv_signals = yes; then + bash_cv_signal_vintage=svr3 + else + bash_cv_signal_vintage=v7 + fi + fi +fi ]) AC_MSG_RESULT($bash_cv_signal_vintage) if test "$bash_cv_signal_vintage" = posix; then @@ -1292,7 +1270,7 @@ AC_DEFUN(BASH_SYS_PGRP_SYNC, [AC_REQUIRE([AC_FUNC_GETPGRP]) AC_MSG_CHECKING(whether pgrps need synchronization) AC_CACHE_VAL(bash_cv_pgrp_pipe, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #ifdef HAVE_UNISTD_H # include #endif @@ -1345,10 +1323,10 @@ main() wait(&status); exit(ok ? 0 : 5); } -], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, +]])], [bash_cv_pgrp_pipe=no], [bash_cv_pgrp_pipe=yes], [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no) - bash_cv_pgrp_pipe=no]) -]) + bash_cv_pgrp_pipe=no] +)]) AC_MSG_RESULT($bash_cv_pgrp_pipe) if test $bash_cv_pgrp_pipe = yes; then AC_DEFINE(PGRP_PIPE) @@ -1356,18 +1334,17 @@ fi ]) AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS, -[AC_REQUIRE([AC_TYPE_SIGNAL]) -AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) +[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked]) AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #ifdef HAVE_UNISTD_H #include #endif #include -typedef RETSIGTYPE sigfunc(); +typedef void sigfunc(); volatile int nsigint; @@ -1389,7 +1366,7 @@ set_signal_handler(sig, handler) #define set_signal_handler(s, h) signal(s, h) #endif -RETSIGTYPE +void sigint(s) int s; { @@ -1405,7 +1382,7 @@ main() kill((int)getpid(), SIGINT); exit(nsigint != 2); } -], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes, +]])], [bash_cv_must_reinstall_sighandlers=no], [bash_cv_must_reinstall_sighandlers=yes], [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no) bash_cv_must_reinstall_sighandlers=no] )]) @@ -1420,7 +1397,7 @@ AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING, [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) AC_MSG_CHECKING(for presence of necessary job control definitions) AC_CACHE_VAL(bash_cv_job_control_missing, -[AC_TRY_COMPILE([ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #ifdef HAVE_SYS_WAIT_H #include @@ -1461,7 +1438,8 @@ AC_CACHE_VAL(bash_cv_job_control_missing, #error #endif -], , bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing +]], [[ int x; ]] )], +[bash_cv_job_control_missing=present], [bash_cv_job_control_missing=missing] )]) AC_MSG_RESULT($bash_cv_job_control_missing) if test $bash_cv_job_control_missing = missing; then @@ -1474,7 +1452,7 @@ dnl this requires a previous check for mkfifo, but that is awkward to specify AC_DEFUN(BASH_SYS_NAMED_PIPES, [AC_MSG_CHECKING(for presence of named pipes) AC_CACHE_VAL(bash_cv_sys_named_pipes, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #ifdef HAVE_UNISTD_H @@ -1514,7 +1492,8 @@ close(fd); unlink ("bash-aclocal/sh-np-autoconf"); rmdir ("bash-aclocal"); exit(0); -}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing, +} +]])], [bash_cv_sys_named_pipes=present], [bash_cv_sys_named_pipes=missing], [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing) bash_cv_sys_named_pipes=missing] )]) @@ -1546,9 +1525,11 @@ AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir") AC_DEFUN(BASH_HAVE_TIOCGWINSZ, [AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h) AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl, -[AC_TRY_COMPILE([#include -#include ], [int x = TIOCGWINSZ;], - bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)]) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include ]], [[int x = TIOCGWINSZ;]] )], + [bash_cv_tiocgwinsz_in_ioctl=yes], [bash_cv_tiocgwinsz_in_ioctl=no] +)]) AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl) if test $bash_cv_tiocgwinsz_in_ioctl = yes; then AC_DEFINE(GWINSZ_IN_SYS_IOCTL) @@ -1558,9 +1539,11 @@ fi AC_DEFUN(BASH_HAVE_TIOCSTAT, [AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h) AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl, -[AC_TRY_COMPILE([#include -#include ], [int x = TIOCSTAT;], - bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)]) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include ]], [[int x = TIOCSTAT;]] )], + [bash_cv_tiocstat_in_ioctl=yes], [bash_cv_tiocstat_in_ioctl=no] +)]) AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl) if test $bash_cv_tiocstat_in_ioctl = yes; then AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL) @@ -1570,9 +1553,11 @@ fi AC_DEFUN(BASH_HAVE_FIONREAD, [AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h) AC_CACHE_VAL(bash_cv_fionread_in_ioctl, -[AC_TRY_COMPILE([#include -#include ], [int x = FIONREAD;], - bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)]) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include ]], [[int x = FIONREAD;]] )], + [bash_cv_fionread_in_ioctl=yes], [bash_cv_fionread_in_ioctl=no] +)]) AC_MSG_RESULT($bash_cv_fionread_in_ioctl) if test $bash_cv_fionread_in_ioctl = yes; then AC_DEFINE(FIONREAD_IN_SYS_IOCTL) @@ -1588,8 +1573,11 @@ dnl AC_DEFUN(BASH_CHECK_SPEED_T, [AC_MSG_CHECKING(for speed_t in sys/types.h) AC_CACHE_VAL(bash_cv_speed_t_in_sys_types, -[AC_TRY_COMPILE([#include ], [speed_t x;], - bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)]) +[AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[speed_t x;]])], + [bash_cv_speed_t_in_sys_types=yes],[bash_cv_speed_t_in_sys_types=no])]) AC_MSG_RESULT($bash_cv_speed_t_in_sys_types) if test $bash_cv_speed_t_in_sys_types = yes; then AC_DEFINE(SPEED_T_IN_SYS_TYPES) @@ -1659,31 +1647,41 @@ if test $bash_cv_dev_stdin = "present"; then fi ]) + +AC_DEFUN(BASH_CHECK_RLIMIT, +[AC_CACHE_VAL(bash_cv_rlimit, +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +]], +[[ + int f; + f = RLIMIT_DATA; +]] )], +[bash_cv_rlimit=yes], [bash_cv_rlimit=no] +)]) +]) + dnl dnl Check if HPUX needs _KERNEL defined for RLIMIT_* definitions dnl AC_DEFUN(BASH_CHECK_KERNEL_RLIMIT, [AC_MSG_CHECKING([whether $host_os needs _KERNEL for RLIMIT defines]) AC_CACHE_VAL(bash_cv_kernel_rlimit, -[AC_TRY_COMPILE([ -#include -#include -], -[ - int f; - f = RLIMIT_DATA; -], bash_cv_kernel_rlimit=no, -[AC_TRY_COMPILE([ +[BASH_CHECK_RLIMIT +if test $bash_cv_rlimit = no; then +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #define _KERNEL #include #undef _KERNEL -], -[ - int f; - f = RLIMIT_DATA; -], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)] -)]) +]], +[[ + int f; + f = RLIMIT_DATA; +]] )], [bash_cv_kernel_rlimit=yes], [bash_cv_kernel_rlimit=no] ) +fi +]) AC_MSG_RESULT($bash_cv_kernel_rlimit) if test $bash_cv_kernel_rlimit = yes; then AC_DEFINE(RLIMIT_NEEDS_KERNEL) @@ -1698,14 +1696,15 @@ dnl sizeof(off_t) is > 4. dnl AC_DEFUN(BASH_CHECK_OFF_T_64, [AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64, -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_UNISTD_H #include #endif #include -],[ +]],[[ switch (0) case 0: case (sizeof (off_t) <= 4):; -], bash_cv_off_t_64=no, bash_cv_off_t_64=yes)) +]] )], [bash_cv_off_t_64=no], [bash_cv_off_t_64=yes] +)) if test $bash_cv_off_t_64 = yes; then AC_DEFINE(HAVE_OFF_T_64) fi]) @@ -1713,7 +1712,7 @@ fi]) AC_DEFUN(BASH_CHECK_RTSIGS, [AC_MSG_CHECKING(for unusable real-time signals due to large values) AC_CACHE_VAL(bash_cv_unusable_rtsigs, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -1733,7 +1732,8 @@ main () #endif exit(rtmin < n_sigs); -}], bash_cv_unusable_rtsigs=yes, bash_cv_unusable_rtsigs=no, +} +]])], [bash_cv_unusable_rtsigs=yes], [bash_cv_unusable_rtsigs=no], [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes) bash_cv_unusable_rtsigs=yes] )]) @@ -1780,48 +1780,43 @@ fi AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype) -AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset, -[AC_TRY_LINK( -[#include ], -[char* cs = nl_langinfo(CODESET);], -bash_cv_langinfo_codeset=yes, bash_cv_langinfo_codeset=no)]) -if test $bash_cv_langinfo_codeset = yes; then - AC_DEFINE(HAVE_LANGINFO_CODESET) -fi +AC_REQUIRE([AM_LANGINFO_CODESET]) dnl check for wchar_t in AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t, -[AC_TRY_COMPILE( -[#include -], -[ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +[#include ]], +[[ wchar_t foo; foo = 0; -], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)]) +]] )], [bash_cv_type_wchar_t=yes], [bash_cv_type_wchar_t=no] +)]) if test $bash_cv_type_wchar_t = yes; then AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here]) fi dnl check for wctype_t in AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t, -[AC_TRY_COMPILE( -[#include ], -[ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +[#include ]], +[[ wctype_t foo; foo = 0; -], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)]) +]] )], [bash_cv_type_wctype_t=yes], [bash_cv_type_wctype_t=no] +)]) if test $bash_cv_type_wctype_t = yes; then AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here]) fi dnl check for wint_t in AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t, -[AC_TRY_COMPILE( -[#include ], -[ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +[#include ]], +[[ wint_t foo; foo = 0; -], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)]) +]] )], [bash_cv_type_wint_t=yes], [bash_cv_type_wint_t=no] +)]) if test $bash_cv_type_wint_t = yes; then AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here]) fi @@ -1829,7 +1824,7 @@ fi dnl check for broken wcwidth AC_CACHE_CHECK([for wcwidth broken with unicode combining characters], bash_cv_wcwidth_broken, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -1848,8 +1843,9 @@ char **v; w = wcwidth (0x0301); exit (w == 0); /* exit 0 if wcwidth broken */ } -], -bash_cv_wcwidth_broken=yes, bash_cv_wcwidth_broken=no, bash_cv_wcwidth_broken=no)]) +]])], [bash_cv_wcwidth_broken=yes], [bash_cv_wcwidth_broken=no], + [bash_cv_wcwidth_broken=no] +)]) if test "$bash_cv_wcwidth_broken" = yes; then AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken]) fi @@ -1899,7 +1895,7 @@ CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}" LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}" AC_CACHE_VAL(ac_cv_rl_version, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -1920,10 +1916,11 @@ main() fclose(fp); exit(0); } -], -ac_cv_rl_version=`cat conftest.rlv`, -ac_cv_rl_version='0.0', -ac_cv_rl_version='8.0')]) +]])], +[ac_cv_rl_version=`cat conftest.rlv`], +[ac_cv_rl_version='0.0'], +[ac_cv_rl_version='8.0'] +)]) CFLAGS="$_save_CFLAGS" LDFLAGS="$_save_LDFLAGS" @@ -1986,57 +1983,11 @@ AC_MSG_RESULT($ac_cv_rl_version) fi ]) -AC_DEFUN(BASH_FUNC_CTYPE_NONASCII, -[ -AC_MSG_CHECKING(whether the ctype macros accept non-ascii characters) -AC_CACHE_VAL(bash_cv_func_ctype_nonascii, -[AC_TRY_RUN([ -#ifdef HAVE_LOCALE_H -#include -#endif -#include -#include -#include - -int -main(c, v) -int c; -char *v[]; -{ - char *deflocale; - unsigned char x; - int r1, r2; - -#ifdef HAVE_SETLOCALE - /* We take a shot here. If that locale is not known, try the - system default. We try this one because '\342' (226) is - known to be a printable character in that locale. */ - deflocale = setlocale(LC_ALL, "en_US.ISO8859-1"); - if (deflocale == 0) - deflocale = setlocale(LC_ALL, ""); -#endif - - x = '\342'; - r1 = isprint(x); - x -= 128; - r2 = isprint(x); - exit (r1 == 0 || r2 == 0); -} -], bash_cv_func_ctype_nonascii=yes, bash_cv_func_ctype_nonascii=no, - [AC_MSG_WARN(cannot check ctype macros if cross compiling -- defaulting to no) - bash_cv_func_ctype_nonascii=no] -)]) -AC_MSG_RESULT($bash_cv_func_ctype_nonascii) -if test $bash_cv_func_ctype_nonascii = yes; then -AC_DEFINE(CTYPE_NON_ASCII) -fi -]) - AC_DEFUN(BASH_CHECK_WCONTINUED, [ AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken) AC_CACHE_VAL(bash_cv_wcontinued_broken, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -2057,7 +2008,7 @@ main() else exit (0); } -], bash_cv_wcontinued_broken=no,bash_cv_wcontinued_broken=yes, +]])], [bash_cv_wcontinued_broken=no], [bash_cv_wcontinued_broken=yes], [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no) bash_cv_wcontinued_broken=no] )]) @@ -2110,7 +2061,7 @@ AC_DEFUN([BASH_FUNC_SNPRINTF], AC_CHECK_FUNCS_ONCE([snprintf]) if test X$ac_cv_func_snprintf = Xyes; then AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf], - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include @@ -2121,7 +2072,7 @@ main() n = snprintf (0, 0, "%s", "0123456"); exit(n != 7); } -], bash_cv_func_snprintf=yes, bash_cv_func_snprintf=no, +]])], [bash_cv_func_snprintf=yes], [bash_cv_func_snprintf=no], [AC_MSG_WARN([cannot check standard snprintf if cross-compiling]) bash_cv_func_snprintf=yes] )]) @@ -2140,7 +2091,7 @@ AC_DEFUN([BASH_FUNC_VSNPRINTF], AC_CHECK_FUNCS_ONCE([vsnprintf]) if test X$ac_cv_func_vsnprintf = Xyes; then AC_CACHE_CHECK([for standard-conformant vsnprintf], [bash_cv_func_vsnprintf], - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #if HAVE_STDARG_H #include #else @@ -2178,7 +2129,7 @@ main() n = foo("%s", "0123456"); exit(n != 7); } -], bash_cv_func_vsnprintf=yes, bash_cv_func_vsnprintf=no, +]])], [bash_cv_func_vsnprintf=yes], [bash_cv_func_vsnprintf=no], [AC_MSG_WARN([cannot check standard vsnprintf if cross-compiling]) bash_cv_func_vsnprintf=yes] )]) @@ -2195,7 +2146,7 @@ main() AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET, [AC_MSG_CHECKING(for offset of exit status in return status from wait) AC_CACHE_VAL(bash_cv_wexitstatus_offset, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include @@ -2229,7 +2180,7 @@ main(c, v) exit (254); } -], bash_cv_wexitstatus_offset=0, bash_cv_wexitstatus_offset=$?, +]])], [bash_cv_wexitstatus_offset=0], [bash_cv_wexitstatus_offset=$?], [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0) bash_cv_wexitstatus_offset=0] )]) @@ -2245,13 +2196,15 @@ AC_DEFUN([BASH_FUNC_SBRK], [ AC_MSG_CHECKING([for sbrk]) AC_CACHE_VAL(ac_cv_func_sbrk, - [AC_TRY_LINK([#include ], - [ void *x = sbrk (4096); ], - ac_cv_func_sbrk=yes, ac_cv_func_sbrk=no)]) + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[ void *x = sbrk (4096); ]])], + [ac_cv_func_sbrk=yes],[ac_cv_func_sbrk=no])]) AC_MSG_RESULT($ac_cv_func_sbrk) if test X$ac_cv_func_sbrk = Xyes; then AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk], - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include @@ -2263,10 +2216,9 @@ main(int c, char **v) x = sbrk (4096); exit ((x == (void *)-1) ? 1 : 0); } -], bash_cv_func_sbrk=yes, bash_cv_func_snprintf=sbrk, - [AC_MSG_WARN([cannot check working sbrk if cross-compiling]) - bash_cv_func_sbrk=yes] -)]) +]])],[bash_cv_func_sbrk=yes],[bash_cv_func_sbrk=no],[AC_MSG_WARN([cannot check working sbrk if cross-compiling]) + bash_cv_func_sbrk=yes +])]) if test $bash_cv_func_sbrk = no; then ac_cv_func_sbrk=no fi @@ -2280,7 +2232,7 @@ main(int c, char **v) AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK, [AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes) AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -2300,8 +2252,7 @@ main (int c, char **v) exit (0); exit (1); } - -], bash_cv_fnmatch_equiv_fallback=yes, bash_cv_fnmatch_equiv_fallback=no, +]])], [bash_cv_fnmatch_equiv_fallback=yes], [bash_cv_fnmatch_equiv_fallback=no], [AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no) bash_cv_fnmatch_equiv_fallback=no] )]) diff --git a/chardefs.h b/chardefs.h index dfbdf31..24a25f1 100644 --- a/chardefs.h +++ b/chardefs.h @@ -1,6 +1,6 @@ /* chardefs.h -- Character definitions for readline. */ -/* Copyright (C) 1994-2015 Free Software Foundation, Inc. +/* Copyright (C) 1994-2021 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. diff --git a/colors.c b/colors.c index d615d70..dba81a2 100644 --- a/colors.c +++ b/colors.c @@ -73,6 +73,8 @@ static bool is_colored (enum indicator_no type); static void restore_default_color (void); +#define RL_COLOR_PREFIX_EXTENSION "readline-colored-completion-prefix" + COLOR_EXT_TYPE *_rl_color_ext_list = 0; /* Output a color indicator (which may contain nulls). */ @@ -110,13 +112,28 @@ _rl_set_normal_color (void) } } +static struct bin_str * +_rl_custom_readline_prefix (void) +{ + size_t len; + COLOR_EXT_TYPE *ext; + + len = strlen (RL_COLOR_PREFIX_EXTENSION); + for (ext = _rl_color_ext_list; ext; ext = ext->next) + if (ext->ext.len == len && STREQN (ext->ext.string, RL_COLOR_PREFIX_EXTENSION, len)) + return (&ext->seq); + return (NULL); +} + bool _rl_print_prefix_color (void) { struct bin_str *s; /* What do we want to use for the prefix? Let's try cyan first, see colors.h */ - s = &_rl_color_indicator[C_PREFIX]; + s = _rl_custom_readline_prefix (); + if (s == 0) + s = &_rl_color_indicator[C_PREFIX]; if (s->string != NULL) { if (is_colored (C_NORM)) diff --git a/complete.c b/complete.c index 3f80c1c..1e4dfa3 100644 --- a/complete.c +++ b/complete.c @@ -835,7 +835,8 @@ fnprint (const char *to_print, int prefix_bytes, const char *real_pathname) colored_stat_start (real_pathname); #endif - if (prefix_bytes && _rl_completion_prefix_display_length > 0) + if (prefix_bytes && _rl_completion_prefix_display_length > 0 && + prefix_bytes > _rl_completion_prefix_display_length) { char ellipsis; @@ -1548,7 +1549,7 @@ rl_display_match_list (char **matches, int len, int max) if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN) max -= common_length - ELLIPSIS_LEN; - else + else if (_rl_colored_completion_prefix <= 0) common_length = sind = 0; } #if defined (COLOR_SUPPORT) diff --git a/configure.ac b/configure.ac index 13aa7c0..9306539 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ dnl Process this file with autoconf to produce a configure script. # You should have received a copy of the GNU General Public License # along with this program. If not, see . -AC_REVISION([for Readline 8.1, version 2.94]) +AC_REVISION([for Readline 8.1, version 2.95]) AC_INIT(readline, 8.1, bug-readline@gnu.org) @@ -323,7 +323,7 @@ AC_SUBST(LIBVERSION) AC_SUBST(TERMCAP_LIB) AC_SUBST(TERMCAP_PKG_CONFIG_LIB) -AC_CONFIG_FILES([Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc]) +AC_CONFIG_FILES([Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc history.pc]) dnl Makefile uses this timestamp file to record whether config.h is up to date. AC_CONFIG_COMMANDS([stamp-h], [echo > stamp-h]) diff --git a/display.c b/display.c index 29fb018..e38bfce 100644 --- a/display.c +++ b/display.c @@ -356,7 +356,7 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp) { char *r, *ret, *p, *igstart, *nprompt, *ms; int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; - int mlen, newlines, newlines_guess, bound; + int mlen, newlines, newlines_guess, bound, can_add_invis; int mb_cur_max; /* We only expand the mode string for the last line of a multiline prompt @@ -372,6 +372,7 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp) else nprompt = pmt; + can_add_invis = 0; mb_cur_max = MB_CUR_MAX; if (_rl_screenwidth == 0) @@ -434,6 +435,11 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp) else if (ignoring && *p == RL_PROMPT_END_IGNORE) { ignoring = 0; + /* If we have a run of invisible characters, adjust local_prompt_newlines + to add them, since update_line expects them to be counted before + wrapping the line. */ + if (can_add_invis) + local_prompt_newlines[newlines] = r - ret; if (p != (igstart + 1)) last = r - ret - 1; continue; @@ -498,10 +504,17 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp) new = r - ret; local_prompt_newlines[++newlines] = new; } + + /* What if a physical character of width >= 2 is split? There is + code that wraps before the physical screen width if the character + width would exceed it, but it needs to be checked against this + code and local_prompt_newlines[]. */ + if (ignoring == 0) + can_add_invis = (physchars == bound); } } - if (rl < _rl_screenwidth) + if (rl <= _rl_screenwidth) invfl = ninvis; *r = '\0'; @@ -2588,7 +2601,8 @@ rl_clear_visible_line (void) for (curr_line = _rl_last_v_pos; curr_line >= 0; curr_line--) { _rl_move_vert (curr_line); - _rl_clear_to_eol (0); + _rl_clear_to_eol (_rl_screenwidth); + _rl_cr (); /* in case we use space_to_eol() */ } return 0; @@ -3372,27 +3386,16 @@ _rl_redisplay_after_sigwinch (void) screen line. */ if (_rl_term_cr) { - _rl_move_vert (_rl_vis_botlin); - - _rl_cr (); - _rl_last_c_pos = 0; - -#if !defined (__MSDOS__) - if (_rl_term_clreol) - tputs (_rl_term_clreol, 1, _rl_output_character_function); - else -#endif - { - space_to_eol (_rl_screenwidth); - _rl_cr (); - } - + rl_clear_visible_line (); if (_rl_last_v_pos > 0) _rl_move_vert (0); } else rl_crlf (); + if (_rl_screenwidth < prompt_visible_length) + _rl_reset_prompt (); /* update local_prompt_newlines array */ + /* Redraw only the last line of a multi-line prompt. */ t = strrchr (rl_display_prompt, '\n'); if (t) diff --git a/doc/readline.3 b/doc/readline.3 index cf59b43..92ee63d 100644 --- a/doc/readline.3 +++ b/doc/readline.3 @@ -6,9 +6,9 @@ .\" Case Western Reserve University .\" chet.ramey@case.edu .\" -.\" Last Change: Wed Jun 16 09:49:37 EDT 2021 +.\" Last Change: Mon Nov 15 17:06:54 EST 2021 .\" -.TH READLINE 3 "2021 June 16" "GNU Readline 8.1" +.TH READLINE 3 "2021 November 15" "GNU Readline 8.1" .\" .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. @@ -359,6 +359,9 @@ If set to \fBOn\fP, when listing completions, readline displays the common prefix of the set of possible completions using a different color. The color definitions are taken from the value of the \fBLS_COLORS\fP environment variable. +If there is a color definition in \fB$LS_COLORS\fP for the custom suffix +"readline-colored-completion-prefix", readline uses this color for +the common prefix instead of its default. .TP .B colored\-stats (Off) If set to \fBOn\fP, readline displays possible completions using different diff --git a/doc/rluser.texi b/doc/rluser.texi index 6990e85..505225b 100644 --- a/doc/rluser.texi +++ b/doc/rluser.texi @@ -445,6 +445,9 @@ If set to @samp{on}, when listing completions, Readline displays the common prefix of the set of possible completions using a different color. The color definitions are taken from the value of the @env{LS_COLORS} environment variable. +If there is a color definition in @env{LS_COLORS} for the custom suffix +@samp{readline-colored-completion-prefix}, Readline uses this color for +the common prefix instead of its default. The default is @samp{off}. @item colored-stats diff --git a/doc/version.texi b/doc/version.texi index d422668..0d5883f 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -4,7 +4,7 @@ Copyright (C) 1988-2021 Free Software Foundation, Inc. @set EDITION 8.1 @set VERSION 8.1 -@set UPDATED 16 June 2021 -@set UPDATED-MONTH June 2021 +@set UPDATED 15 November 2021 +@set UPDATED-MONTH November 2021 -@set LASTCHANGE Wed Jun 16 09:50:11 EDT 2021 +@set LASTCHANGE Mon Nov 15 17:05:28 EST 2021 diff --git a/history.pc.in b/history.pc.in new file mode 100644 index 0000000..8a80775 --- /dev/null +++ b/history.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: History +Description: Gnu History library for managing previously-entered lines +URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html +Version: @LIBVERSION@ +Libs: -L${libdir} -lhistory +Cflags: -I${includedir} diff --git a/isearch.c b/isearch.c index 33f67d3..df23f15 100644 --- a/isearch.c +++ b/isearch.c @@ -273,6 +273,8 @@ _rl_isearch_fini (_rl_search_cxt *cxt) last_isearch_string = cxt->search_string; last_isearch_string_len = cxt->search_string_index; cxt->search_string = 0; + cxt->search_string_size = 0; + cxt->search_string_index = 0; if (cxt->last_found_line < cxt->save_line) rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0); @@ -687,8 +689,9 @@ opcode_dispatch: cxt->search_string_size += pastelen + 2; cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size); } - strcpy (cxt->search_string + cxt->search_string_index, paste); + memcpy (cxt->search_string + cxt->search_string_index, paste, pastelen); cxt->search_string_index += pastelen; + cxt->search_string[cxt->search_string_index] = '\0'; free (paste); break; diff --git a/macro.c b/macro.c index 92cc55c..231a24b 100644 --- a/macro.c +++ b/macro.c @@ -276,6 +276,8 @@ rl_end_kbd_macro (int count, int ignore) } current_macro_index -= rl_key_sequence_length; + if (current_macro_index < 0) + current_macro_index = 0; current_macro[current_macro_index] = '\0'; RL_UNSETSTATE(RL_STATE_MACRODEF); diff --git a/posixdir.h b/posixdir.h index af5be80..b737bd7 100644 --- a/posixdir.h +++ b/posixdir.h @@ -1,6 +1,6 @@ /* posixdir.h -- Posix directory reading includes and defines. */ -/* Copyright (C) 1987,1991,2012 Free Software Foundation, Inc. +/* Copyright (C) 1987,1991,2012,2019,2021 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. diff --git a/posixtime.h b/posixtime.h index 3fbf178..e70ebec 100644 --- a/posixtime.h +++ b/posixtime.h @@ -1,6 +1,6 @@ /* posixtime.h -- wrapper for time.h, sys/times.h mess. */ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999-2021 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. diff --git a/rltty.c b/rltty.c index 4a49200..dd10933 100644 --- a/rltty.c +++ b/rltty.c @@ -694,6 +694,8 @@ rl_deprep_terminal (void) fprintf (rl_outstream, BRACK_PASTE_FINI); if (_rl_eof_found && (RL_ISSTATE (RL_STATE_TIMEOUT) == 0)) fprintf (rl_outstream, "\n"); + else if (_rl_echoing_p == 0) + fprintf (rl_outstream, "\n"); } if (_rl_enable_keypad) diff --git a/support/shobj-conf b/support/shobj-conf index acbb344..cd7634d 100644 --- a/support/shobj-conf +++ b/support/shobj-conf @@ -123,7 +123,7 @@ sunos5*|solaris2*) ;; # All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd. -linux*-*|gnu*-*|k*bsd*-gnu-*|midnightbsd*freebsd*|dragonfly*) +linux*-*|gnu*-*|k*bsd*-gnu-*|midnightbsd*|freebsd*|dragonfly*) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' diff --git a/terminal.c b/terminal.c index 8bdc9a4..5b4ef1b 100644 --- a/terminal.c +++ b/terminal.c @@ -386,8 +386,12 @@ _rl_sigwinch_resize_terminal (void) void rl_resize_terminal (void) { + int width, height; + + width = _rl_screenwidth; + height = _rl_screenheight; _rl_get_screen_size (fileno (rl_instream), 1); - if (_rl_echoing_p) + if (_rl_echoing_p && (width != _rl_screenwidth || height != _rl_screenheight)) { if (CUSTOM_REDISPLAY_FUNC ()) rl_forced_update_display (); @@ -420,7 +424,7 @@ static const struct _tc_string tc_strings[] = { "kH", &_rl_term_kH }, /* home down ?? */ { "kI", &_rl_term_kI }, /* insert */ { "kN", &_rl_term_kN }, /* page down */ - { "kN", &_rl_term_kP }, /* page up */ + { "kP", &_rl_term_kP }, /* page up */ { "kd", &_rl_term_kd }, { "ke", &_rl_term_ke }, /* end keypad mode */ { "kh", &_rl_term_kh }, /* home */ diff --git a/text.c b/text.c index b16bc9b..91c3f33 100644 --- a/text.c +++ b/text.c @@ -96,6 +96,7 @@ rl_insert_text (const char *string) for (i = rl_end; i >= rl_point; i--) rl_line_buffer[i + l] = rl_line_buffer[i]; + strncpy (rl_line_buffer + rl_point, string, l); /* Remember how to undo this if we aren't undoing something. */ @@ -1539,7 +1540,10 @@ rl_transpose_words (int count, int key) { char *word1, *word2; int w1_beg, w1_end, w2_beg, w2_end; - int orig_point = rl_point; + int orig_point, orig_end; + + orig_point = rl_point; + orig_end = rl_end; if (!count) return 0; @@ -1583,6 +1587,7 @@ rl_transpose_words (int count, int key) /* This is exactly correct since the text before this point has not changed in length. */ rl_point = w2_end; + rl_end = orig_end; /* just make sure */ /* I think that does it. */ rl_end_undo_group (); diff --git a/vi_mode.c b/vi_mode.c index c3b555d..3a033ba 100644 --- a/vi_mode.c +++ b/vi_mode.c @@ -1372,8 +1372,15 @@ int rl_vi_delete_to (int count, int key) { int c, r; + _rl_vimotion_cxt *savecxt; - if (_rl_vimvcxt) + savecxt = 0; + if (_rl_vi_redoing) + { + savecxt = _rl_vimvcxt; + _rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key); + } + else if (_rl_vimvcxt) _rl_mvcxt_init (_rl_vimvcxt, VIM_DELETE, key); else _rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key); @@ -1416,7 +1423,7 @@ rl_vi_delete_to (int count, int key) } _rl_mvcxt_dispose (_rl_vimvcxt); - _rl_vimvcxt = 0; + _rl_vimvcxt = savecxt; return r; } @@ -1464,8 +1471,15 @@ int rl_vi_change_to (int count, int key) { int c, r; + _rl_vimotion_cxt *savecxt; - if (_rl_vimvcxt) + savecxt = 0; + if (_rl_vi_redoing) + { + savecxt = _rl_vimvcxt; + _rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key); + } + else if (_rl_vimvcxt) _rl_mvcxt_init (_rl_vimvcxt, VIM_CHANGE, key); else _rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key); @@ -1507,7 +1521,7 @@ rl_vi_change_to (int count, int key) } _rl_mvcxt_dispose (_rl_vimvcxt); - _rl_vimvcxt = 0; + _rl_vimvcxt = savecxt; return r; } @@ -1536,8 +1550,15 @@ int rl_vi_yank_to (int count, int key) { int c, r; + _rl_vimotion_cxt *savecxt; - if (_rl_vimvcxt) + savecxt = 0; + if (_rl_vi_redoing) + { + savecxt = _rl_vimvcxt; + _rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key); + } + else if (_rl_vimvcxt) _rl_mvcxt_init (_rl_vimvcxt, VIM_YANK, key); else _rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key); @@ -1579,7 +1600,7 @@ rl_vi_yank_to (int count, int key) } _rl_mvcxt_dispose (_rl_vimvcxt); - _rl_vimvcxt = 0; + _rl_vimvcxt = savecxt; return r; } diff --git a/xmalloc.h b/xmalloc.h index 3bd7f0f..0fb9df9 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -1,6 +1,6 @@ /* xmalloc.h -- memory allocation that aborts on errors. */ -/* Copyright (C) 1999-2009 Free Software Foundation, Inc. +/* Copyright (C) 1999-2009,2010-2021 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing.