From: Chet Ramey Date: Sat, 3 Dec 2011 18:46:50 +0000 (-0500) Subject: commit bash-20050512 snapshot X-Git-Tag: bash-3.1-alpha~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=798a67db11293f88fb381edfba4bd5b0a41d60fe;p=thirdparty%2Fbash.git commit bash-20050512 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index fa586a630..7444a8670 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -11420,3 +11420,86 @@ lib/tilde/tilde.c Makefile.in,builtins/Makefile.in - @CROSS_COMPILE@ is substituted into CFLAGS_FOR_BUILD (equal to -DCROSS_COMPILING if bash is being cross-compiled) + + 5/9 + --- +aclocal.m4 + - print version as `0.0' in RL_LIB_READLINE_VERSION if the + `rl_gnu_readline_p' variable isn't 1 (accept no imitations) + + 5/11 + ---- +lib/readline/rlprivate.h + - definition of a readline `search context', to be use for incremental + search initially and other types of search later. Original from + Bob Rossi as part of work on incremental searching problems when + using callback interface + +lib/readline/isearch.c + - functions to allocate and free search contexts + - function to take a search context and a character just read and + `dispatch' on it: change search parameters, add to search string, + search further, etc. + - isearch is now completely context-driven: a search context is + allocated and passed to the rest of the functions + + 5/12 + ---- +lib/readline/isearch.c + - an additional `isearch cleanup' function that can be called from + the callback interface functions when the search is to be terminated + - an additional `isearch callback' function that can be called from + rl_callback_read_char when input is available + - short-circuit from rl_search_history after initialization if + the callback interface is being used + +lib/readline/callback.c + - in rl_callback_read_char(), if RL_STATE_ISEARCH is set, call + _rl_isearch_callback to read the character and dispatch on it. + If RL_STATE_ISEARCH is unset when that call returns, and there is + input pending, call rl_callback_read_char() again so we don't + have to wait for new input to pick it up + +support/shobj-conf,configure.in + - add support for dragonfly bsd, the same as freebsd + + 5/13-5/15 + --------- +lib/readline/callback.c + - support for readline functions to `register' a function that will + be called when more input is available, with a generic data + structure to encapsulate the arguments and parameters. Primarily + intended for functions that read a single additional character, + like quoted-insert + - support for callback code reading numeric arguments in a loop, + using readline state and an auxiliary variable + - support for callback code performing non-incremental searches using + the same search context struct as the isearch code + +lib/readline/{callback,display}.c + - if a callback function sets `_rl_redisplay_wanted', the redisplay + function will be called as soon as it returns + +lib/readline/input.c + - changes to _rl_read_mbchar to handle reading the null multibyte + character and translating it into '\0' + +lib/readline/misc.c + - break rl_digit_loop() into component functions that can be called + individually from the callback code more easily + - share some of the functions with rl_digit_loop1() in vi_mode.c + +lib/readline/readline.h + - change the version #defines to reflect readline 5.1 + +lib/readline/search.c + - break code into smaller functions that can be composed to work with + the callback code more easily + +lib/readline/text.c + - in rl_quoted_insert(), don't messa around with the tty signals if + running in `callback mode' + +lib/readline/vi_mode.c + - changed set-mark, goto-mark, change-char, and char-search to work + when called by callback functions diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 56615c335..32e1239f5 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -11418,4 +11418,48 @@ lib/tilde/tilde.c - guard calls to {get,end}pwent with HAVE_GETPWENT Makefile.in,builtins/Makefile.in - - @CROSS_COMPILE@ is substituted into CFLAGS_FOR_BUILD + - @CROSS_COMPILE@ is substituted into CFLAGS_FOR_BUILD (equal to + -DCROSS_COMPILING if bash is being cross-compiled) + + 5/9 + --- +aclocal.m4 + - print version as `0.0' in RL_LIB_READLINE_VERSION if the + `rl_gnu_readline_p' variable isn't 1 (accept no imitations) + + 5/11 + ---- +lib/readline/rlprivate.h + - definition of a readline `search context', to be use for incremental + search initially and other types of search later. Original from + Bob Rossi as part of work on incremental searching problems when + using callback interface + +lib/readline/isearch.c + - functions to allocate and free search contexts + - function to take a search context and a character just read and + `dispatch' on it: change search parameters, add to search string, + search further, etc. + - isearch is now completely context-driven: a search context is + allocated and passed to the rest of the functions + + 5/12 + ---- +lib/readline/isearch.c + - an additional `isearch cleanup' function that can be called from + the callback interface functions when the search is to be terminated + - an additional `isearch callback' function that can be called from + rl_callback_read_char when input is available + - short-circuit from rl_search_history after initialization if + the callback interface is being used + +lib/readline/callback.c + - in rl_callback_read_char(), if RL_STATE_ISEARCH is set, call + _rl_isearch_callback to read the character and dispatch on it. + If RL_STATE_ISEARCH is unset when that call returns, and there is + input pending, call rl_callback_read_char() again so we don't + have to wait for new input to pick it up + +support/shobj-conf,configure.in + - add support for dragonfly bsd, the same as freebsd + diff --git a/aclocal.m4 b/aclocal.m4 index bfcd5970c..8a700845d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1740,12 +1740,18 @@ AC_CACHE_VAL(ac_cv_rl_version, #include #include +extern int rl_gnu_readline_p; + main() { FILE *fp; fp = fopen("conftest.rlv", "w"); - if (fp == 0) exit(1); - fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); + if (fp == 0) + exit(1); + if (rl_gnu_readline_p != 1) + fprintf(fp, "0.0\n"); + else + fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); fclose(fp); exit(0); } diff --git a/autom4te.cache/output.0 b/autom4te.cache/output.0 index 53fbd78d5..2aac5bfed 100644 --- a/autom4te.cache/output.0 +++ b/autom4te.cache/output.0 @@ -4709,12 +4709,18 @@ cat >>conftest.$ac_ext <<_ACEOF #include #include +extern int rl_gnu_readline_p; + main() { FILE *fp; fp = fopen("conftest.rlv", "w"); - if (fp == 0) exit(1); - fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); + if (fp == 0) + exit(1); + if (rl_gnu_readline_p != 1) + fprintf(fp, "0.0\n"); + else + fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); fclose(fp); exit(0); } @@ -26750,6 +26756,7 @@ freebsd[3-9]*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading fi ;; freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading esac case "$host_cpu" in diff --git a/autom4te.cache/requests b/autom4te.cache/requests index e5169e704..812ed7e9e 100644 --- a/autom4te.cache/requests +++ b/autom4te.cache/requests @@ -15,101 +15,101 @@ 'configure.in' ], { - 'AC_FUNC_LSTAT' => 1, - 'AC_FUNC_GETMNTENT' => 1, - 'AC_PROG_CPP' => 1, - 'AC_C_INLINE' => 1, - 'AC_DEFINE_TRACE_LITERAL' => 1, - 'AC_CONFIG_FILES' => 1, - 'AC_FUNC_MBRTOWC' => 1, - 'AC_FUNC_GETGROUPS' => 1, - 'AC_LIBSOURCE' => 1, - 'AC_CHECK_HEADERS' => 1, - 'AM_AUTOMAKE_VERSION' => 1, - 'AC_HEADER_MAJOR' => 1, - 'AH_OUTPUT' => 1, - 'AC_STRUCT_ST_BLOCKS' => 1, - 'AC_DECL_SYS_SIGLIST' => 1, - 'm4_include' => 1, - 'AC_CHECK_FUNCS' => 1, - 'AC_TYPE_PID_T' => 1, - 'AC_FUNC_REALLOC' => 1, + 'AC_HEADER_STDC' => 1, 'AC_FUNC_ERROR_AT_LINE' => 1, - 'AC_PROG_YACC' => 1, - 'AC_FUNC_CHOWN' => 1, - 'AC_CHECK_TYPES' => 1, - 'AC_FUNC_MKTIME' => 1, - 'AC_FUNC_STRFTIME' => 1, - 'AC_FUNC_STRTOD' => 1, + 'sinclude' => 1, + 'AC_FUNC_SETVBUF_REVERSED' => 1, + 'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1, + 'AC_PROG_LN_S' => 1, + 'AC_TYPE_MODE_T' => 1, 'AC_C_VOLATILE' => 1, - 'AC_TYPE_SIGNAL' => 1, - 'AC_FUNC_OBSTACK' => 1, - 'AC_FUNC_UTIME_NULL' => 1, - 'AM_GNU_GETTEXT' => 1, + 'AC_HEADER_MAJOR' => 1, + 'AC_CONFIG_LIBOBJ_DIR' => 1, + 'AC_PROG_LEX' => 1, + 'AC_PATH_X' => 1, + 'AC_LIBSOURCE' => 1, + 'AC_TYPE_UID_T' => 1, + 'AC_HEADER_SYS_WAIT' => 1, 'AC_TYPE_OFF_T' => 1, - 'AC_C_CONST' => 1, - 'AC_FUNC_STRCOLL' => 1, + 'AC_CHECK_FUNCS' => 1, + 'AC_FUNC_SELECT_ARGTYPES' => 1, + 'AC_STRUCT_ST_BLOCKS' => 1, 'AC_REPLACE_FNMATCH' => 1, - 'AC_STRUCT_TIMEZONE' => 1, - 'AM_INIT_AUTOMAKE' => 1, - 'm4_pattern_allow' => 1, - 'AC_TYPE_UID_T' => 1, - 'AM_CONDITIONAL' => 1, - 'AC_CHECK_MEMBERS' => 1, - 'AC_FUNC_WAIT3' => 1, - 'sinclude' => 1, - 'AC_FUNC_MALLOC' => 1, - 'include' => 1, - '_m4_warn' => 1, + 'AC_INIT' => 1, + 'AC_FUNC_STRTOD' => 1, 'm4_pattern_forbid' => 1, - 'AC_CONFIG_SUBDIRS' => 1, - 'AC_CONFIG_LINKS' => 1, - 'm4_sinclude' => 1, - 'AC_CONFIG_HEADERS' => 1, - 'AC_FUNC_SETVBUF_REVERSED' => 1, - 'AC_HEADER_SYS_WAIT' => 1, - 'AC_FUNC_VPRINTF' => 1, - 'AC_FUNC_SETPGRP' => 1, - 'AC_PATH_X' => 1, 'AC_CANONICAL_SYSTEM' => 1, - 'AC_PROG_AWK' => 1, - 'AC_CHECK_LIB' => 1, + 'AC_HEADER_TIME' => 1, 'AC_FUNC_ALLOCA' => 1, - 'AC_INIT' => 1, - 'AC_FUNC_STAT' => 1, + 'AC_FUNC_OBSTACK' => 1, 'AC_CANONICAL_HOST' => 1, - 'AC_FUNC_MMAP' => 1, - 'AM_MAINTAINER_MODE' => 1, - 'AC_STRUCT_TM' => 1, - 'AC_HEADER_STDC' => 1, - 'AC_FUNC_GETLOADAVG' => 1, - 'AC_HEADER_STAT' => 1, - 'AC_CONFIG_LIBOBJ_DIR' => 1, + 'AC_CONFIG_LINKS' => 1, + 'AM_INIT_AUTOMAKE' => 1, 'AC_PROG_LIBTOOL' => 1, - 'AC_PROG_RANLIB' => 1, - 'AC_FUNC_STRNLEN' => 1, - 'AC_TYPE_MODE_T' => 1, - 'AC_PROG_LEX' => 1, - 'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1, - 'AC_HEADER_DIRENT' => 1, + 'AC_C_INLINE' => 1, + 'AM_PROG_CC_C_O' => 1, + 'AC_TYPE_PID_T' => 1, + 'AC_FUNC_STRERROR_R' => 1, 'AC_PROG_GCC_TRADITIONAL' => 1, + 'AC_CHECK_HEADERS' => 1, + 'AC_CHECK_LIB' => 1, + 'AC_PROG_RANLIB' => 1, + 'AC_FUNC_MEMCMP' => 1, 'AC_PROG_INSTALL' => 1, - 'AC_PROG_MAKE_SET' => 1, - 'AC_PROG_LN_S' => 1, - 'AC_PROG_CC' => 1, - 'AC_PROG_CXX' => 1, + 'AC_FUNC_STRFTIME' => 1, + 'AC_PROG_CPP' => 1, + 'm4_pattern_allow' => 1, + 'AC_C_CONST' => 1, + 'AC_CONFIG_AUX_DIR' => 1, + 'AC_DEFINE_TRACE_LITERAL' => 1, + 'AC_DECL_SYS_SIGLIST' => 1, + 'AC_HEADER_STAT' => 1, + 'AC_FUNC_MMAP' => 1, + 'AC_CONFIG_HEADERS' => 1, + 'AC_FUNC_SETPGRP' => 1, + 'AC_FUNC_STRNLEN' => 1, 'AC_SUBST' => 1, - 'AC_FUNC_MEMCMP' => 1, + 'AH_OUTPUT' => 1, + 'AM_CONDITIONAL' => 1, 'AC_FUNC_FSEEKO' => 1, + 'AC_PROG_CC' => 1, + 'AC_FUNC_UTIME_NULL' => 1, + 'AC_FUNC_MALLOC' => 1, + 'AC_FUNC_GETLOADAVG' => 1, + 'AC_STRUCT_TM' => 1, + 'AC_PROG_AWK' => 1, + 'AC_HEADER_DIRENT' => 1, + 'include' => 1, + 'AC_CHECK_TYPES' => 1, + 'AC_FUNC_VPRINTF' => 1, + 'AC_FUNC_CLOSEDIR_VOID' => 1, + 'AC_FUNC_WAIT3' => 1, + 'AM_MAINTAINER_MODE' => 1, 'AC_FUNC_FORK' => 1, - 'AC_FUNC_GETPGRP' => 1, 'AC_TYPE_SIZE_T' => 1, - 'AC_HEADER_TIME' => 1, - 'AC_FUNC_STRERROR_R' => 1, - 'AM_PROG_CC_C_O' => 1, - 'AC_CONFIG_AUX_DIR' => 1, - 'AC_FUNC_CLOSEDIR_VOID' => 1, - 'AC_FUNC_SELECT_ARGTYPES' => 1 + 'AC_FUNC_MKTIME' => 1, + 'AC_FUNC_CHOWN' => 1, + 'AC_STRUCT_TIMEZONE' => 1, + 'AC_FUNC_GETPGRP' => 1, + 'AC_FUNC_REALLOC' => 1, + 'AC_PROG_MAKE_SET' => 1, + 'AC_TYPE_SIGNAL' => 1, + 'AC_FUNC_LSTAT' => 1, + 'AC_CONFIG_SUBDIRS' => 1, + 'AC_FUNC_GETMNTENT' => 1, + 'AC_PROG_CXX' => 1, + 'AC_FUNC_GETGROUPS' => 1, + 'AC_CONFIG_FILES' => 1, + 'AC_PROG_YACC' => 1, + 'AM_GNU_GETTEXT' => 1, + 'AC_FUNC_STRCOLL' => 1, + 'AM_AUTOMAKE_VERSION' => 1, + 'm4_sinclude' => 1, + '_m4_warn' => 1, + 'AC_CHECK_MEMBERS' => 1, + 'AC_FUNC_STAT' => 1, + 'AC_FUNC_MBRTOWC' => 1, + 'm4_include' => 1 } ], 'Autom4te::Request' ) ); diff --git a/autom4te.cache/traces.0 b/autom4te.cache/traces.0 index 4756b7991..e6766ac46 100644 --- a/autom4te.cache/traces.0 +++ b/autom4te.cache/traces.0 @@ -64,7 +64,7 @@ m4trace:configure.in:52: -1- AC_SUBST([host_vendor], [`echo $ac_cv_host | sed 's m4trace:configure.in:52: -1- AC_SUBST([host_os], [`echo $ac_cv_host | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`]) m4trace:configure.in:102: -2- _m4_warn([obsolete], [The macro `AC_HELP_STRING' is obsolete. You should run autoupdate.], [autoconf/general.m4:219: AC_HELP_STRING is expanded from... -aclocal.m4:1923: AM_PATH_LISPDIR is expanded from... +aclocal.m4:1929: AM_PATH_LISPDIR is expanded from... configure.in:102: the top level]) m4trace:configure.in:102: -1- AC_SUBST([EMACS]) m4trace:configure.in:102: -1- AC_SUBST([lispdir]) @@ -327,7 +327,7 @@ m4trace:configure.in:480: -1- AC_CHECK_LIB([ncurses], [tgetent], [bash_cv_termca m4trace:configure.in:480: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete. You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... -aclocal.m4:1816: RL_LIB_READLINE_VERSION is expanded from... +aclocal.m4:1822: RL_LIB_READLINE_VERSION is expanded from... configure.in:480: the top level]) m4trace:configure.in:480: -1- AC_DEFINE_TRACE_LITERAL([RL_READLINE_VERSION]) m4trace:configure.in:480: -1- AH_OUTPUT([RL_READLINE_VERSION], [/* encoded version of the installed readline library */ @@ -408,16 +408,16 @@ m4trace:configure.in:617: -1- AC_SUBST([XGETTEXT]) m4trace:configure.in:617: -1- AC_SUBST([MSGMERGE]) m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_OUTPUT_COMMANDS' is obsolete. You should run autoupdate.], [autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from... -aclocal.m4:3779: AM_PO_SUBDIRS is expanded from... +aclocal.m4:3785: AM_PO_SUBDIRS is expanded from... configure.in:617: AM_PO_SUBDIRS is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -3- _m4_warn([obsolete], [The macro `_AC_OUTPUT_COMMANDS_CNT' is obsolete. You should run autoupdate.], [autoconf/status.m4:321: _AC_OUTPUT_COMMANDS_CNT is expanded from... autoconf/status.m4:318: AC_OUTPUT_COMMANDS is expanded from... -aclocal.m4:3779: AM_PO_SUBDIRS is expanded from... +aclocal.m4:3785: AM_PO_SUBDIRS is expanded from... configure.in:617: AM_PO_SUBDIRS is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_TYPE_OFF_T m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([off_t]) @@ -470,11 +470,11 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is ob You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2572: gt_INTDIV0 is expanded from... +aclocal.m4:2578: gt_INTDIV0 is expanded from... configure.in:617: gt_INTDIV0 is required by... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([INTDIV0_RAISES_SIGFPE]) m4trace:configure.in:617: -1- AH_OUTPUT([INTDIV0_RAISES_SIGFPE], [/* Define if integer division by zero raises signal SIGFPE. */ @@ -483,13 +483,13 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2627: jm_AC_HEADER_INTTYPES_H is expanded from... +aclocal.m4:2633: jm_AC_HEADER_INTTYPES_H is expanded from... configure.in:617: jm_AC_HEADER_INTTYPES_H is required by... -aclocal.m4:3930: jm_AC_TYPE_UINTMAX_T is expanded from... +aclocal.m4:3936: jm_AC_TYPE_UINTMAX_T is expanded from... configure.in:617: jm_AC_TYPE_UINTMAX_T is required by... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H_WITH_UINTMAX]) m4trace:configure.in:617: -1- AH_OUTPUT([HAVE_INTTYPES_H_WITH_UINTMAX], [/* Define if exists, doesn\'t clash with , and @@ -499,13 +499,13 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:3898: jm_AC_HEADER_STDINT_H is expanded from... +aclocal.m4:3904: jm_AC_HEADER_STDINT_H is expanded from... configure.in:617: jm_AC_HEADER_STDINT_H is required by... -aclocal.m4:3930: jm_AC_TYPE_UINTMAX_T is expanded from... +aclocal.m4:3936: jm_AC_TYPE_UINTMAX_T is expanded from... configure.in:617: jm_AC_TYPE_UINTMAX_T is required by... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([HAVE_STDINT_H_WITH_UINTMAX]) m4trace:configure.in:617: -1- AH_OUTPUT([HAVE_STDINT_H_WITH_UINTMAX], [/* Define if exists, doesn\'t clash with , and declares @@ -515,13 +515,13 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:3953: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from... +aclocal.m4:3959: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from... configure.in:617: jm_AC_TYPE_UNSIGNED_LONG_LONG is required by... -aclocal.m4:3930: jm_AC_TYPE_UINTMAX_T is expanded from... +aclocal.m4:3936: jm_AC_TYPE_UINTMAX_T is expanded from... configure.in:617: jm_AC_TYPE_UINTMAX_T is required by... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([HAVE_UNSIGNED_LONG_LONG]) m4trace:configure.in:617: -1- AH_OUTPUT([HAVE_UNSIGNED_LONG_LONG], [/* Define if you have the unsigned long long type. */ @@ -537,11 +537,11 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2599: gt_HEADER_INTTYPES_H is expanded from... +aclocal.m4:2605: gt_HEADER_INTTYPES_H is expanded from... configure.in:617: gt_HEADER_INTTYPES_H is required by... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H]) m4trace:configure.in:617: -1- AH_OUTPUT([HAVE_INTTYPES_H], [/* Define if exists and doesn\'t clash with . */ @@ -550,11 +550,11 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2659: gt_INTTYPES_PRI is expanded from... +aclocal.m4:2665: gt_INTTYPES_PRI is expanded from... configure.in:617: gt_INTTYPES_PRI is required by... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([PRI_MACROS_BROKEN]) m4trace:configure.in:617: -1- AH_OUTPUT([PRI_MACROS_BROKEN], [/* Define if exists and defines unusable PRI* macros. */ @@ -633,21 +633,21 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2472: AM_ICONV_LINK is expanded from... -aclocal.m4:2500: AM_ICONV is expanded from... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2478: AM_ICONV_LINK is expanded from... +aclocal.m4:2506: AM_ICONV is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete. You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2472: AM_ICONV_LINK is expanded from... -aclocal.m4:2500: AM_ICONV is expanded from... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2478: AM_ICONV_LINK is expanded from... +aclocal.m4:2506: AM_ICONV is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ICONV]) m4trace:configure.in:617: -1- AH_OUTPUT([HAVE_ICONV], [/* Define if you have the iconv() function. */ @@ -657,10 +657,10 @@ m4trace:configure.in:617: -1- AC_SUBST([LTLIBICONV]) m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete. You should run autoupdate.], [autoconf/general.m4:2180: AC_TRY_COMPILE is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... -aclocal.m4:2500: AM_ICONV is expanded from... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2506: AM_ICONV is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([ICONV_CONST]) m4trace:configure.in:617: -1- AH_OUTPUT([ICONV_CONST], [/* Define as const if the declaration of iconv() needs const. */ @@ -669,10 +669,10 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:1950: AM_LANGINFO_CODESET is expanded from... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:1956: AM_LANGINFO_CODESET is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LANGINFO_CODESET]) m4trace:configure.in:617: -1- AH_OUTPUT([HAVE_LANGINFO_CODESET], [/* Define if you have and nl_langinfo(CODESET). */ @@ -681,10 +681,10 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2717: AM_LC_MESSAGES is expanded from... -aclocal.m4:2361: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2723: AM_LC_MESSAGES is expanded from... +aclocal.m4:2367: AM_INTL_SUBDIR is expanded from... configure.in:617: AM_INTL_SUBDIR is required by... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LC_MESSAGES]) m4trace:configure.in:617: -1- AH_OUTPUT([HAVE_LC_MESSAGES], [/* Define if your file defines LC_MESSAGES. */ @@ -695,19 +695,19 @@ m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is o You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete. You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete. You should run autoupdate.], [autoconf/general.m4:2223: AC_TRY_LINK is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... autoconf/general.m4:1808: AC_CACHE_CHECK is expanded from... -aclocal.m4:2291: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2297: AM_GNU_GETTEXT is expanded from... configure.in:617: the top level]) m4trace:configure.in:617: -1- AC_DEFINE_TRACE_LITERAL([ENABLE_NLS]) m4trace:configure.in:617: -1- AH_OUTPUT([ENABLE_NLS], [/* Define to 1 if translation of program messages to the user\'s native @@ -1478,7 +1478,7 @@ m4trace:configure.in:841: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LSTAT]) m4trace:configure.in:845: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete. You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... -aclocal.m4:1860: BASH_FUNC_CTYPE_NONASCII is expanded from... +aclocal.m4:1866: BASH_FUNC_CTYPE_NONASCII is expanded from... configure.in:845: the top level]) m4trace:configure.in:845: -1- AC_DEFINE_TRACE_LITERAL([CTYPE_NON_ASCII]) m4trace:configure.in:846: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete. @@ -1732,7 +1732,7 @@ m4trace:configure.in:915: -1- AC_DEFINE_TRACE_LITERAL([FIONREAD_IN_SYS_IOCTL]) m4trace:configure.in:917: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete. You should run autoupdate.], [autoconf/general.m4:2289: AC_TRY_RUN is expanded from... autoconf/general.m4:1799: AC_CACHE_VAL is expanded from... -aclocal.m4:1893: BASH_CHECK_WCONTINUED is expanded from... +aclocal.m4:1899: BASH_CHECK_WCONTINUED is expanded from... configure.in:917: the top level]) m4trace:configure.in:917: -1- AC_DEFINE_TRACE_LITERAL([WCONTINUED_BROKEN]) m4trace:configure.in:920: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' is obsolete. @@ -1787,37 +1787,37 @@ m4trace:configure.in:969: -1- AC_DEFINE_TRACE_LITERAL([SVR4]) m4trace:configure.in:970: -1- AC_DEFINE_TRACE_LITERAL([SVR4]) m4trace:configure.in:971: -1- AC_DEFINE_TRACE_LITERAL([SVR5]) m4trace:configure.in:986: -1- AC_DEFINE_TRACE_LITERAL([PGRP_PIPE]) -m4trace:configure.in:1031: -1- AC_SUBST([SHOBJ_CC]) -m4trace:configure.in:1032: -1- AC_SUBST([SHOBJ_CFLAGS]) -m4trace:configure.in:1033: -1- AC_SUBST([SHOBJ_LD]) -m4trace:configure.in:1034: -1- AC_SUBST([SHOBJ_LDFLAGS]) -m4trace:configure.in:1035: -1- AC_SUBST([SHOBJ_XLDFLAGS]) -m4trace:configure.in:1036: -1- AC_SUBST([SHOBJ_LIBS]) -m4trace:configure.in:1037: -1- AC_SUBST([SHOBJ_STATUS]) -m4trace:configure.in:1062: -1- AC_SUBST([PROFILE_FLAGS]) -m4trace:configure.in:1064: -1- AC_SUBST([incdir]) -m4trace:configure.in:1065: -1- AC_SUBST([BUILD_DIR]) -m4trace:configure.in:1067: -1- AC_SUBST([YACC]) -m4trace:configure.in:1068: -1- AC_SUBST([AR]) -m4trace:configure.in:1069: -1- AC_SUBST([ARFLAGS]) -m4trace:configure.in:1071: -1- AC_SUBST([BASHVERS]) -m4trace:configure.in:1072: -1- AC_SUBST([RELSTATUS]) -m4trace:configure.in:1073: -1- AC_SUBST([DEBUG]) -m4trace:configure.in:1074: -1- AC_SUBST([MALLOC_DEBUG]) -m4trace:configure.in:1076: -1- AC_SUBST([host_cpu]) -m4trace:configure.in:1077: -1- AC_SUBST([host_vendor]) -m4trace:configure.in:1078: -1- AC_SUBST([host_os]) -m4trace:configure.in:1080: -1- AC_SUBST([LOCAL_LIBS]) -m4trace:configure.in:1081: -1- AC_SUBST([LOCAL_CFLAGS]) -m4trace:configure.in:1082: -1- AC_SUBST([LOCAL_LDFLAGS]) -m4trace:configure.in:1083: -1- AC_SUBST([LOCAL_DEFS]) -m4trace:configure.in:1097: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \ +m4trace:configure.in:1032: -1- AC_SUBST([SHOBJ_CC]) +m4trace:configure.in:1033: -1- AC_SUBST([SHOBJ_CFLAGS]) +m4trace:configure.in:1034: -1- AC_SUBST([SHOBJ_LD]) +m4trace:configure.in:1035: -1- AC_SUBST([SHOBJ_LDFLAGS]) +m4trace:configure.in:1036: -1- AC_SUBST([SHOBJ_XLDFLAGS]) +m4trace:configure.in:1037: -1- AC_SUBST([SHOBJ_LIBS]) +m4trace:configure.in:1038: -1- AC_SUBST([SHOBJ_STATUS]) +m4trace:configure.in:1063: -1- AC_SUBST([PROFILE_FLAGS]) +m4trace:configure.in:1065: -1- AC_SUBST([incdir]) +m4trace:configure.in:1066: -1- AC_SUBST([BUILD_DIR]) +m4trace:configure.in:1068: -1- AC_SUBST([YACC]) +m4trace:configure.in:1069: -1- AC_SUBST([AR]) +m4trace:configure.in:1070: -1- AC_SUBST([ARFLAGS]) +m4trace:configure.in:1072: -1- AC_SUBST([BASHVERS]) +m4trace:configure.in:1073: -1- AC_SUBST([RELSTATUS]) +m4trace:configure.in:1074: -1- AC_SUBST([DEBUG]) +m4trace:configure.in:1075: -1- AC_SUBST([MALLOC_DEBUG]) +m4trace:configure.in:1077: -1- AC_SUBST([host_cpu]) +m4trace:configure.in:1078: -1- AC_SUBST([host_vendor]) +m4trace:configure.in:1079: -1- AC_SUBST([host_os]) +m4trace:configure.in:1081: -1- AC_SUBST([LOCAL_LIBS]) +m4trace:configure.in:1082: -1- AC_SUBST([LOCAL_CFLAGS]) +m4trace:configure.in:1083: -1- AC_SUBST([LOCAL_LDFLAGS]) +m4trace:configure.in:1084: -1- AC_SUBST([LOCAL_DEFS]) +m4trace:configure.in:1098: -1- AC_CONFIG_FILES([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \ lib/intl/Makefile \ lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \ lib/tilde/Makefile doc/Makefile support/Makefile po/Makefile.in \ examples/loadables/Makefile examples/loadables/perl/Makefile \ pathnames.h]) -m4trace:configure.in:1097: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments. +m4trace:configure.in:1098: -1- _m4_warn([obsolete], [AC_OUTPUT should be used without arguments. You should run autoupdate.], []) -m4trace:configure.in:1097: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs]) -m4trace:configure.in:1097: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs]) +m4trace:configure.in:1098: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs]) +m4trace:configure.in:1098: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs]) diff --git a/configure b/configure index c1fef0d6b..bff25c2df 100755 --- a/configure +++ b/configure @@ -4709,12 +4709,18 @@ cat >>conftest.$ac_ext <<_ACEOF #include #include +extern int rl_gnu_readline_p; + main() { FILE *fp; fp = fopen("conftest.rlv", "w"); - if (fp == 0) exit(1); - fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); + if (fp == 0) + exit(1); + if (rl_gnu_readline_p != 1) + fprintf(fp, "0.0\n"); + else + fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); fclose(fp); exit(0); } @@ -26750,6 +26756,7 @@ freebsd[3-9]*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading fi ;; freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading esac case "$host_cpu" in diff --git a/configure.in b/configure.in index f7eb83bdd..5c7858d1f 100644 --- a/configure.in +++ b/configure.in @@ -1005,6 +1005,7 @@ freebsd[[3-9]]*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading fi ;; freebsdelf*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading +dragonfly*) LOCAL_LDFLAGS=-rdynamic ;; # allow dynamic loading esac case "$host_cpu" in diff --git a/lib/readline/callback.c b/lib/readline/callback.c index 8725652e6..9469233da 100644 --- a/lib/readline/callback.c +++ b/lib/readline/callback.c @@ -44,6 +44,11 @@ #include "readline.h" #include "rlprivate.h" +/* Private data for callback registration functions. See comments in + rl_callback_read_char for more details. */ +_rl_callback_func_t *_rl_callback_func = 0; +_rl_callback_generic_arg *_rl_callback_data = 0; + /* **************************************************************** */ /* */ /* Callback Readline Functions */ @@ -108,7 +113,51 @@ rl_callback_read_char () abort (); } - eof = readline_internal_char (); + if (RL_ISSTATE (RL_STATE_ISEARCH)) + { + eof = _rl_isearch_callback (_rl_iscxt); + if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING)) + rl_callback_read_char (); + + return; + } + else if (RL_ISSTATE (RL_STATE_NSEARCH)) + { + eof = _rl_nsearch_callback (_rl_nscxt); + return; + } + else if (RL_ISSTATE (RL_STATE_NUMERICARG)) + { + eof = _rl_arg_callback (_rl_argcxt); + if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING)) + rl_callback_read_char (); + + return; + } + else if (_rl_callback_func) + { + /* This allows functions that simply need to read an additional character + (like quoted-insert) to register a function to be called when input is + available. _rl_callback_data is simply a pointer to a struct that has + the argument count originally passed to the registering function and + space for any additional parameters. */ + eof = (*_rl_callback_func) (_rl_callback_data); + /* If the function `deregisters' itself, make sure the data is cleaned + up. */ + if (_rl_callback_func == 0 && _rl_callback_data) + { + _rl_callback_data_dispose (_rl_callback_data); + _rl_callback_data = 0; + } + } + else + eof = readline_internal_char (); + + if (rl_done == 0 && _rl_want_redisplay) + { + (*rl_redisplay_function) (); + _rl_want_redisplay = 0; + } /* We loop in case some function has pushed input back with rl_execute_next. */ for (;;) @@ -158,4 +207,25 @@ rl_callback_handler_remove () } } +_rl_callback_generic_arg * +_rl_callback_data_alloc (count) + int count; +{ + _rl_callback_generic_arg *arg; + + arg = (_rl_callback_generic_arg *)xmalloc (sizeof (_rl_callback_generic_arg)); + arg->count = count; + + arg->i1 = arg->i2 = 0; + + return arg; +} + +void _rl_callback_data_dispose (arg) + _rl_callback_generic_arg *arg; +{ + if (arg) + free (arg); +} + #endif diff --git a/lib/readline/display.c b/lib/readline/display.c index d4e6c88e8..107627a99 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -118,6 +118,7 @@ rl_voidfunc_t *rl_redisplay_function = rl_redisplay; int rl_display_fixed = 0; int _rl_suppress_redisplay = 0; +int _rl_want_redisplay = 0; /* The stuff that gets printed out before the actual text of the line. This is usually pointing to rl_prompt. */ diff --git a/lib/readline/input.c b/lib/readline/input.c index 044338e87..8eb5080bf 100644 --- a/lib/readline/input.c +++ b/lib/readline/input.c @@ -1,6 +1,6 @@ /* input.c -- character input functions for readline. */ -/* Copyright (C) 1994 Free Software Foundation, Inc. +/* Copyright (C) 1994-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -519,6 +519,12 @@ _rl_read_mbchar (mbchar, size) ps = ps_back; continue; } + else if (mbchar_bytes_length == 0) + { + mbchar[0] = '\0'; /* null wide character */ + mb_len = 1; + break; + } else if (mbchar_bytes_length > (size_t)(0)) break; } diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c index c1ea5b308..88b398518 100644 --- a/lib/readline/isearch.c +++ b/lib/readline/isearch.c @@ -4,7 +4,7 @@ /* */ /* **************************************************************** */ -/* Copyright (C) 1987-2002 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005 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 @@ -56,12 +56,17 @@ /* Variables exported to other files in the readline library. */ char *_rl_isearch_terminators = (char *)NULL; +_rl_search_cxt *_rl_iscxt = 0; + /* Variables imported from other files in the readline library. */ extern HIST_ENTRY *_rl_saved_line_for_history; -/* Forward declarations */ static int rl_search_history PARAMS((int, int)); +static _rl_search_cxt *_rl_isearch_init PARAMS((int)); +static void _rl_isearch_fini PARAMS((_rl_search_cxt *)); +static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int)); + /* Last line found by the current incremental search, so we don't `find' identical lines many times in a row. */ static char *prev_line_found; @@ -72,6 +77,55 @@ static int last_isearch_string_len; static char *default_isearch_terminators = "\033\012"; +_rl_search_cxt * +_rl_scxt_alloc (type, flags) + int type, flags; +{ + _rl_search_cxt *cxt; + + cxt = (_rl_search_cxt *)xmalloc (sizeof (_rl_search_cxt)); + + cxt->type = type; + cxt->sflags = flags; + + cxt->search_string = 0; + cxt->search_string_size = cxt->search_string_index = 0; + + cxt->lines = 0; + cxt->allocated_line = 0; + cxt->hlen = cxt->hindex = 0; + + cxt->save_point = rl_point; + cxt->save_mark = rl_mark; + cxt->save_line = where_history (); + cxt->last_found_line = cxt->save_line; + cxt->prev_line_found = 0; + + cxt->history_pos = 0; + cxt->direction = 0; + + cxt->lastc = 0; + + cxt->sline = 0; + cxt->sline_len = cxt->sline_index = 0; + + cxt->search_terminators = 0; + + return cxt; +} + +void +_rl_scxt_dispose (cxt, flags) + _rl_search_cxt *cxt; + int flags; +{ + FREE (cxt->search_string); + FREE (cxt->allocated_line); + FREE (cxt->lines); + + free (cxt); +} + /* Search backwards through the history looking for a string which is typed interactively. Start with the current line. */ int @@ -140,66 +194,23 @@ rl_display_search (search_string, reverse_p, where) (*rl_redisplay_function) (); } -/* Search through the history looking for an interactively typed string. - This is analogous to i-search. We start the search in the current line. - DIRECTION is which direction to search; >= 0 means forward, < 0 means - backwards. */ -static int -rl_search_history (direction, invoking_key) - int direction, invoking_key; +static _rl_search_cxt * +_rl_isearch_init (direction) + int direction; { - /* The string that the user types in to search for. */ - char *search_string; - - /* The current length of SEARCH_STRING. */ - int search_string_index; - - /* The amount of space that SEARCH_STRING has allocated to it. */ - int search_string_size; - - /* The list of lines to search through. */ - char **lines, *allocated_line; - - /* The length of LINES. */ - int hlen; - - /* Where we get LINES from. */ - HIST_ENTRY **hlist; - + _rl_search_cxt *cxt; register int i; - int orig_point, orig_mark, orig_line, last_found_line; - int c, found, failed, sline_len; - int n, wstart, wlen; -#if defined (HANDLE_MULTIBYTE) - char mb[MB_LEN_MAX]; -#endif - - /* The line currently being searched. */ - char *sline; - - /* Offset in that line. */ - int line_index; - - /* Non-zero if we are doing a reverse search. */ - int reverse; - - /* The list of characters which terminate the search, but are not - subsequently executed. If the variable isearch-terminators has - been set, we use that value, otherwise we use ESC and C-J. */ - char *isearch_terminators; + HIST_ENTRY **hlist; - RL_SETSTATE(RL_STATE_ISEARCH); - orig_point = rl_point; - orig_mark = rl_mark; - last_found_line = orig_line = where_history (); - reverse = direction < 0; - hlist = history_list (); - allocated_line = (char *)NULL; + cxt = _rl_scxt_alloc (RL_SEARCH_ISEARCH, 0); + if (direction < 0) + cxt->sflags |= SF_REVERSE; - isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators + cxt->search_terminators = _rl_isearch_terminators ? _rl_isearch_terminators : default_isearch_terminators; /* Create an arrary of pointers to the lines that we want to search. */ + hlist = history_list (); rl_maybe_replace_line (); i = 0; if (hlist) @@ -207,354 +218,439 @@ rl_search_history (direction, invoking_key) /* Allocate space for this many lines, +1 for the current input line, and remember those lines. */ - lines = (char **)xmalloc ((1 + (hlen = i)) * sizeof (char *)); - for (i = 0; i < hlen; i++) - lines[i] = hlist[i]->line; + cxt->lines = (char **)xmalloc ((1 + (cxt->hlen = i)) * sizeof (char *)); + for (i = 0; i < cxt->hlen; i++) + cxt->lines[i] = hlist[i]->line; if (_rl_saved_line_for_history) - lines[i] = _rl_saved_line_for_history->line; + cxt->lines[i] = _rl_saved_line_for_history->line; else { /* Keep track of this so we can free it. */ - allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer)); - strcpy (allocated_line, &rl_line_buffer[0]); - lines[i] = allocated_line; + cxt->allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer)); + strcpy (cxt->allocated_line, &rl_line_buffer[0]); + cxt->lines[i] = cxt->allocated_line; } - hlen++; + cxt->hlen++; /* The line where we start the search. */ - i = orig_line; + cxt->history_pos = cxt->save_line; rl_save_prompt (); /* Initialize search parameters. */ - search_string = (char *)xmalloc (search_string_size = 128); - *search_string = '\0'; - search_string_index = 0; - prev_line_found = (char *)0; /* XXX */ + cxt->search_string = (char *)xmalloc (cxt->search_string_size = 128); + cxt->search_string[cxt->search_string_index = 0] = '\0'; /* Normalize DIRECTION into 1 or -1. */ - direction = (direction >= 0) ? 1 : -1; + cxt->direction = (direction >= 0) ? 1 : -1; - rl_display_search (search_string, reverse, -1); + cxt->sline = rl_line_buffer; + cxt->sline_len = strlen (cxt->sline); + cxt->sline_index = rl_point; - sline = rl_line_buffer; - sline_len = strlen (sline); - line_index = rl_point; + _rl_iscxt = cxt; /* save globally */ - found = failed = 0; - for (;;) + return cxt; +} + +static void +_rl_isearch_fini (cxt) + _rl_search_cxt *cxt; +{ + /* First put back the original state. */ + strcpy (rl_line_buffer, cxt->lines[cxt->save_line]); + + rl_restore_prompt (); + + /* Save the search string for possible later use. */ + FREE (last_isearch_string); + last_isearch_string = cxt->search_string; + last_isearch_string_len = cxt->search_string_index; + cxt->search_string = 0; + + if (cxt->last_found_line < cxt->save_line) + rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0); + else + rl_get_next_history (cxt->last_found_line - cxt->save_line, 0); + + /* If the string was not found, put point at the end of the last matching + line. If last_found_line == orig_line, we didn't find any matching + history lines at all, so put point back in its original position. */ + if (cxt->sline_index < 0) { - rl_command_func_t *f = (rl_command_func_t *)NULL; + if (cxt->last_found_line == cxt->save_line) + cxt->sline_index = cxt->save_point; + else + cxt->sline_index = strlen (rl_line_buffer); + rl_mark = cxt->save_mark; + } + + rl_point = cxt->sline_index; + /* Don't worry about where to put the mark here; rl_get_previous_history + and rl_get_next_history take care of it. */ - /* Read a key and decide how to proceed. */ - RL_SETSTATE(RL_STATE_MOREINPUT); - c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); + rl_clear_message (); +} + +int +_rl_search_getchar (cxt) + _rl_search_cxt *cxt; +{ + int c; + + /* Read a key and decide how to proceed. */ + RL_SETSTATE(RL_STATE_MOREINPUT); + c = cxt->lastc = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); #if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - c = _rl_read_mbstring (c, mb, MB_LEN_MAX); + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, MB_LEN_MAX); #endif - /* Translate the keys we do something with to opcodes. */ - if (c >= 0 && _rl_keymap[c].type == ISFUNC) - { - f = _rl_keymap[c].function; - - if (f == rl_reverse_search_history) - c = reverse ? -1 : -2; - else if (f == rl_forward_search_history) - c = !reverse ? -1 : -2; - else if (f == rl_rubout) - c = -3; - else if (c == CTRL ('G')) - c = -4; - else if (c == CTRL ('W')) /* XXX */ - c = -5; - else if (c == CTRL ('Y')) /* XXX */ - c = -6; - } + return c; +} - /* The characters in isearch_terminators (set from the user-settable - variable isearch-terminators) are used to terminate the search but - not subsequently execute the character as a command. The default - value is "\033\012" (ESC and C-J). */ - if (strchr (isearch_terminators, c)) - { - /* ESC still terminates the search, but if there is pending - input or if input arrives within 0.1 seconds (on systems - with select(2)) it is used as a prefix character - with rl_execute_next. WATCH OUT FOR THIS! This is intended - to allow the arrow keys to be used like ^F and ^B are used - to terminate the search and execute the movement command. - XXX - since _rl_input_available depends on the application- - settable keyboard timeout value, this could alternatively - use _rl_input_queued(100000) */ - if (c == ESC && _rl_input_available ()) - rl_execute_next (ESC); - break; - } +/* Process just-read character C according to isearch context CXT. Return + -1 if the caller should just free the context and return, 0 if we should + break out of the loop, and 1 if we should continue to read characters. */ +int +_rl_isearch_dispatch (cxt, c) + _rl_search_cxt *cxt; + int c; +{ + int n, wstart, wlen, limit; + rl_command_func_t *f; + + f = (rl_command_func_t *)NULL; + + /* Translate the keys we do something with to opcodes. */ + if (c >= 0 && _rl_keymap[c].type == ISFUNC) + { + f = _rl_keymap[c].function; + + if (f == rl_reverse_search_history) + cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2; + else if (f == rl_forward_search_history) + cxt->lastc = (cxt->sflags & SF_REVERSE) ? -2 : -1; + else if (f == rl_rubout) + cxt->lastc = -3; + else if (c == CTRL ('G')) + cxt->lastc = -4; + else if (c == CTRL ('W')) /* XXX */ + cxt->lastc = -5; + else if (c == CTRL ('Y')) /* XXX */ + cxt->lastc = -6; + } + + /* The characters in isearch_terminators (set from the user-settable + variable isearch-terminators) are used to terminate the search but + not subsequently execute the character as a command. The default + value is "\033\012" (ESC and C-J). */ + if (strchr (cxt->search_terminators, cxt->lastc)) + { + /* ESC still terminates the search, but if there is pending + input or if input arrives within 0.1 seconds (on systems + with select(2)) it is used as a prefix character + with rl_execute_next. WATCH OUT FOR THIS! This is intended + to allow the arrow keys to be used like ^F and ^B are used + to terminate the search and execute the movement command. + XXX - since _rl_input_available depends on the application- + settable keyboard timeout value, this could alternatively + use _rl_input_queued(100000) */ + if (cxt->lastc == ESC && _rl_input_available ()) + rl_execute_next (ESC); + return (0); + } #define ENDSRCH_CHAR(c) \ ((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G'))) #if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc)) { - if (c >= 0 && strlen (mb) == 1 && ENDSRCH_CHAR (c)) + /* This sets rl_pending_input to c; it will be picked up the next + time rl_read_key is called. */ + rl_execute_next (cxt->lastc); + return (0); + } + } + else +#endif + if (cxt->lastc >= 0 && ENDSRCH_CHAR (cxt->lastc)) + { + /* This sets rl_pending_input to LASTC; it will be picked up the next + time rl_read_key is called. */ + rl_execute_next (cxt->lastc); + return (0); + } + + /* Now dispatch on the character. `Opcodes' affect the search string or + state. Other characters are added to the string. */ + switch (cxt->lastc) + { + /* search again */ + case -1: + if (cxt->search_string_index == 0) + { + if (last_isearch_string) { - /* This sets rl_pending_input to c; it will be picked up the next - time rl_read_key is called. */ - rl_execute_next (c); + cxt->search_string_size = 64 + last_isearch_string_len; + cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size); + strcpy (cxt->search_string, last_isearch_string); + cxt->search_string_index = last_isearch_string_len; + rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1); break; } + return (1); } + else if (cxt->sflags & SF_REVERSE) + cxt->sline_index--; + else if (cxt->sline_index != cxt->sline_len) + cxt->sline_index++; else -#endif - if (c >= 0 && ENDSRCH_CHAR (c)) + rl_ding (); + break; + + /* switch directions */ + case -2: + cxt->direction = -cxt->direction; + if (cxt->direction < 0) + cxt->sflags |= SF_REVERSE; + break; + + /* delete character from search string. */ + case -3: /* C-H, DEL */ + /* 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. But this will + do until we have a real isearch-undo. */ + if (cxt->search_string_index == 0) + rl_ding (); + else + cxt->search_string[--cxt->search_string_index] = '\0'; + break; + + case -4: /* C-G, abort */ + rl_replace_line (cxt->lines[cxt->save_line], 0); + rl_point = cxt->save_point; + rl_mark = cxt->save_mark; + rl_restore_prompt(); + rl_clear_message (); + + return -1; + + case -5: /* C-W */ + /* skip over portion of line we already matched and yank word */ + wstart = rl_point + cxt->search_string_index; + if (wstart >= rl_end) { - /* This sets rl_pending_input to c; it will be picked up the next - time rl_read_key is called. */ - rl_execute_next (c); + rl_ding (); break; } - switch (c) + /* if not in a word, move to one. */ + if (rl_alphabetic(rl_line_buffer[wstart]) == 0) { - case -1: - if (search_string_index == 0) - { - if (last_isearch_string) - { - search_string_size = 64 + last_isearch_string_len; - search_string = (char *)xrealloc (search_string, search_string_size); - strcpy (search_string, last_isearch_string); - search_string_index = last_isearch_string_len; - rl_display_search (search_string, reverse, -1); - break; - } - continue; - } - else if (reverse) - --line_index; - else if (line_index != sline_len) - ++line_index; - else - rl_ding (); + rl_ding (); break; - - /* switch directions */ - case -2: - direction = -direction; - reverse = direction < 0; + } + n = wstart; + while (n < rl_end && rl_alphabetic(rl_line_buffer[n])) + n++; + wlen = n - wstart + 1; + if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size) + { + cxt->search_string_size += wlen + 1; + cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size); + } + for (; wstart < n; wstart++) + cxt->search_string[cxt->search_string_index++] = rl_line_buffer[wstart]; + cxt->search_string[cxt->search_string_index] = '\0'; + break; + + case -6: /* C-Y */ + /* skip over portion of line we already matched and yank rest */ + wstart = rl_point + cxt->search_string_index; + if (wstart >= rl_end) + { + rl_ding (); break; + } + n = rl_end - wstart + 1; + if (cxt->search_string_index + n + 1 >= cxt->search_string_size) + { + cxt->search_string_size += n + 1; + cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size); + } + for (n = wstart; n < rl_end; n++) + cxt->search_string[cxt->search_string_index++] = rl_line_buffer[n]; + cxt->search_string[cxt->search_string_index] = '\0'; + break; + + /* Add character to search string and continue search. */ + default: + if (cxt->search_string_index + 2 >= cxt->search_string_size) + { + cxt->search_string_size += 128; + cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size); + } +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int j, l; + for (j = 0, l = strlen (cxt->mb); j < l; ) + cxt->search_string[cxt->search_string_index++] = cxt->mb[j++]; + } + else +#endif + cxt->search_string[cxt->search_string_index++] = c; + cxt->search_string[cxt->search_string_index] = '\0'; + break; + } - /* delete character from search string. */ - case -3: /* C-H, DEL */ - /* 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. But this will - do until we have a real isearch-undo. */ - if (search_string_index == 0) - rl_ding (); - else - search_string[--search_string_index] = '\0'; - - break; + for (cxt->sflags &= ~(SF_FOUND|SF_FAILED);; ) + { + limit = cxt->sline_len - cxt->search_string_index + 1; - case -4: /* C-G */ - rl_replace_line (lines[orig_line], 0); - rl_point = orig_point; - rl_mark = orig_mark; - rl_restore_prompt(); - rl_clear_message (); - if (allocated_line) - free (allocated_line); - free (lines); - RL_UNSETSTATE(RL_STATE_ISEARCH); - return 0; - - case -5: /* C-W */ - /* skip over portion of line we already matched */ - wstart = rl_point + search_string_index; - if (wstart >= rl_end) + /* Search the current line. */ + while ((cxt->sflags & SF_REVERSE) ? (cxt->sline_index >= 0) : (cxt->sline_index < limit)) + { + if (STREQN (cxt->search_string, cxt->sline + cxt->sline_index, cxt->search_string_index)) { - rl_ding (); + cxt->sflags |= SF_FOUND; break; } + else + cxt->sline_index += cxt->direction; + } + if (cxt->sflags & SF_FOUND) + break; - /* if not in a word, move to one. */ - if (rl_alphabetic(rl_line_buffer[wstart]) == 0) - { - rl_ding (); - break; - } - n = wstart; - while (n < rl_end && rl_alphabetic(rl_line_buffer[n])) - n++; - wlen = n - wstart + 1; - if (search_string_index + wlen + 1 >= search_string_size) - { - search_string_size += wlen + 1; - search_string = (char *)xrealloc (search_string, search_string_size); - } - for (; wstart < n; wstart++) - search_string[search_string_index++] = rl_line_buffer[wstart]; - search_string[search_string_index] = '\0'; - break; + /* Move to the next line, but skip new copies of the line + we just found and lines shorter than the string we're + searching for. */ + do + { + /* Move to the next line. */ + cxt->history_pos += cxt->direction; - case -6: /* C-Y */ - /* skip over portion of line we already matched */ - wstart = rl_point + search_string_index; - if (wstart >= rl_end) + /* At limit for direction? */ + if ((cxt->sflags & SF_REVERSE) ? (cxt->history_pos < 0) : (cxt->history_pos == cxt->hlen)) { - rl_ding (); + cxt->sflags |= SF_FAILED; break; } - n = rl_end - wstart + 1; - if (search_string_index + n + 1 >= search_string_size) - { - search_string_size += n + 1; - search_string = (char *)xrealloc (search_string, search_string_size); - } - for (n = wstart; n < rl_end; n++) - search_string[search_string_index++] = rl_line_buffer[n]; - search_string[search_string_index] = '\0'; - break; - default: - /* Add character to search string and continue search. */ - if (search_string_index + 2 >= search_string_size) - { - search_string_size += 128; - search_string = (char *)xrealloc (search_string, search_string_size); - } -#if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - { - int j, l; - for (j = 0, l = strlen (mb); j < l; ) - search_string[search_string_index++] = mb[j++]; - } - else -#endif - search_string[search_string_index++] = c; - search_string[search_string_index] = '\0'; - break; + /* We will need these later. */ + cxt->sline = cxt->lines[cxt->history_pos]; + cxt->sline_len = strlen (cxt->sline); } + while ((cxt->prev_line_found && STREQ (cxt->prev_line_found, cxt->lines[cxt->history_pos])) || + (cxt->search_string_index > cxt->sline_len)); - for (found = failed = 0;;) - { - int limit = sline_len - search_string_index + 1; + if (cxt->sflags & SF_FAILED) + break; - /* Search the current line. */ - while (reverse ? (line_index >= 0) : (line_index < limit)) - { - if (STREQN (search_string, sline + line_index, search_string_index)) - { - found++; - break; - } - else - line_index += direction; - } - if (found) - break; + /* Now set up the line for searching... */ + cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0; + } - /* Move to the next line, but skip new copies of the line - we just found and lines shorter than the string we're - searching for. */ - do - { - /* Move to the next line. */ - i += direction; - - /* At limit for direction? */ - if (reverse ? (i < 0) : (i == hlen)) - { - failed++; - break; - } - - /* We will need these later. */ - sline = lines[i]; - sline_len = strlen (sline); - } - while ((prev_line_found && STREQ (prev_line_found, lines[i])) || - (search_string_index > sline_len)); + if (cxt->sflags & SF_FAILED) + { + /* We cannot find the search string. Ding the bell. */ + rl_ding (); + cxt->history_pos = cxt->last_found_line; + return 1; + } - if (failed) - break; + /* We have found the search string. Just display it. But don't + actually move there in the history list until the user accepts + the location. */ + if (cxt->sflags & SF_FOUND) + { + cxt->prev_line_found = cxt->lines[cxt->history_pos]; + rl_replace_line (cxt->lines[cxt->history_pos], 0); + rl_point = cxt->sline_index; + cxt->last_found_line = cxt->history_pos; + rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos); + } - /* Now set up the line for searching... */ - line_index = reverse ? sline_len - search_string_index : 0; - } + return 1; +} - if (failed) - { - /* We cannot find the search string. Ding the bell. */ - rl_ding (); - i = last_found_line; - continue; /* XXX - was break */ - } +static int +_rl_isearch_cleanup (cxt, r) + _rl_search_cxt *cxt; + int r; +{ + if (r >= 0) + _rl_isearch_fini (cxt); + _rl_scxt_dispose (cxt, 0); + _rl_iscxt = 0; - /* We have found the search string. Just display it. But don't - actually move there in the history list until the user accepts - the location. */ - if (found) - { - prev_line_found = lines[i]; - rl_replace_line (lines[i], 0); - rl_point = line_index; - last_found_line = i; - rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i); - } - } + RL_UNSETSTATE(RL_STATE_ISEARCH); - /* The searching is over. The user may have found the string that she - was looking for, or else she may have exited a failing search. If - LINE_INDEX is -1, then that shows that the string searched for was - not found. We use this to determine where to place rl_point. */ + return (r != 0); +} - /* First put back the original state. */ - strcpy (rl_line_buffer, lines[orig_line]); +/* Search through the history looking for an interactively typed string. + This is analogous to i-search. We start the search in the current line. + DIRECTION is which direction to search; >= 0 means forward, < 0 means + backwards. */ +static int +rl_search_history (direction, invoking_key) + int direction, invoking_key; +{ + _rl_search_cxt *cxt; /* local for now, but saved globally */ + int c, r; - rl_restore_prompt (); + RL_SETSTATE(RL_STATE_ISEARCH); + cxt = _rl_isearch_init (direction); - /* Save the search string for possible later use. */ - FREE (last_isearch_string); - last_isearch_string = search_string; - last_isearch_string_len = search_string_index; + rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1); - if (last_found_line < orig_line) - rl_get_previous_history (orig_line - last_found_line, 0); - else - rl_get_next_history (last_found_line - orig_line, 0); + /* If we are using the callback interface, all we do is set up here and + return. The key is that we leave RL_STATE_ISEARCH set. */ + if (RL_ISSTATE (RL_STATE_CALLBACK)) + return (0); - /* If the string was not found, put point at the end of the last matching - line. If last_found_line == orig_line, we didn't find any matching - history lines at all, so put point back in its original position. */ - if (line_index < 0) + r = -1; + for (;;) { - if (last_found_line == orig_line) - line_index = orig_point; - else - line_index = strlen (rl_line_buffer); - rl_mark = orig_mark; + c = _rl_search_getchar (cxt); + /* We might want to handle EOF here (c == 0) */ + r = _rl_isearch_dispatch (cxt, cxt->lastc); + if (r <= 0) + break; } - rl_point = line_index; - /* Don't worry about where to put the mark here; rl_get_previous_history - and rl_get_next_history take care of it. */ - - rl_clear_message (); + /* The searching is over. The user may have found the string that she + was looking for, or else she may have exited a failing search. If + LINE_INDEX is -1, then that shows that the string searched for was + not found. We use this to determine where to place rl_point. */ + return (_rl_isearch_cleanup (cxt, r)); +} - FREE (allocated_line); - free (lines); +#if defined (READLINE_CALLBACKS) +/* Called from the callback functions when we are ready to read a key. The + callback functions know to call this because RL_ISSTATE(RL_STATE_ISEARCH). + If _rl_isearch_dispatch finishes searching, this function is responsible + for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */ +int +_rl_isearch_callback (cxt) + _rl_search_cxt *cxt; +{ + int c, r; - RL_UNSETSTATE(RL_STATE_ISEARCH); + c = _rl_search_getchar (cxt); + /* We might want to handle EOF here */ + r = _rl_isearch_dispatch (cxt, cxt->lastc); - return 0; + return (r <= 0) ? _rl_isearch_cleanup (cxt, r) : 0; } +#endif diff --git a/lib/readline/isearch.c.orig b/lib/readline/isearch.c.orig new file mode 100644 index 000000000..c1ea5b308 --- /dev/null +++ b/lib/readline/isearch.c.orig @@ -0,0 +1,560 @@ +/* **************************************************************** */ +/* */ +/* I-Search and Searching */ +/* */ +/* **************************************************************** */ + +/* Copyright (C) 1987-2002 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 2, 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, + 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ +#define READLINE_LIBRARY + +#if defined (HAVE_CONFIG_H) +# include +#endif + +#include + +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#if defined (HAVE_STDLIB_H) +# include +#else +# include "ansi_stdlib.h" +#endif + +#include "rldefs.h" +#include "rlmbutil.h" + +#include "readline.h" +#include "history.h" + +#include "rlprivate.h" +#include "xmalloc.h" + +/* Variables exported to other files in the readline library. */ +char *_rl_isearch_terminators = (char *)NULL; + +/* Variables imported from other files in the readline library. */ +extern HIST_ENTRY *_rl_saved_line_for_history; + +/* Forward declarations */ +static int rl_search_history PARAMS((int, int)); + +/* Last line found by the current incremental search, so we don't `find' + identical lines many times in a row. */ +static char *prev_line_found; + +/* Last search string and its length. */ +static char *last_isearch_string; +static int last_isearch_string_len; + +static char *default_isearch_terminators = "\033\012"; + +/* Search backwards through the history looking for a string which is typed + interactively. Start with the current line. */ +int +rl_reverse_search_history (sign, key) + int sign, key; +{ + return (rl_search_history (-sign, key)); +} + +/* Search forwards through the history looking for a string which is typed + interactively. Start with the current line. */ +int +rl_forward_search_history (sign, key) + int sign, key; +{ + return (rl_search_history (sign, key)); +} + +/* Display the current state of the search in the echo-area. + SEARCH_STRING contains the string that is being searched for, + DIRECTION is zero for forward, or 1 for reverse, + WHERE is the history list number of the current line. If it is + -1, then this line is the starting one. */ +static void +rl_display_search (search_string, reverse_p, where) + char *search_string; + int reverse_p, where; +{ + char *message; + int msglen, searchlen; + + searchlen = (search_string && *search_string) ? strlen (search_string) : 0; + + message = (char *)xmalloc (searchlen + 33); + msglen = 0; + +#if defined (NOTDEF) + if (where != -1) + { + sprintf (message, "[%d]", where + history_base); + msglen = strlen (message); + } +#endif /* NOTDEF */ + + message[msglen++] = '('; + + if (reverse_p) + { + strcpy (message + msglen, "reverse-"); + msglen += 8; + } + + strcpy (message + msglen, "i-search)`"); + msglen += 10; + + if (search_string) + { + strcpy (message + msglen, search_string); + msglen += searchlen; + } + + strcpy (message + msglen, "': "); + + rl_message ("%s", message); + free (message); + (*rl_redisplay_function) (); +} + +/* Search through the history looking for an interactively typed string. + This is analogous to i-search. We start the search in the current line. + DIRECTION is which direction to search; >= 0 means forward, < 0 means + backwards. */ +static int +rl_search_history (direction, invoking_key) + int direction, invoking_key; +{ + /* The string that the user types in to search for. */ + char *search_string; + + /* The current length of SEARCH_STRING. */ + int search_string_index; + + /* The amount of space that SEARCH_STRING has allocated to it. */ + int search_string_size; + + /* The list of lines to search through. */ + char **lines, *allocated_line; + + /* The length of LINES. */ + int hlen; + + /* Where we get LINES from. */ + HIST_ENTRY **hlist; + + register int i; + int orig_point, orig_mark, orig_line, last_found_line; + int c, found, failed, sline_len; + int n, wstart, wlen; +#if defined (HANDLE_MULTIBYTE) + char mb[MB_LEN_MAX]; +#endif + + /* The line currently being searched. */ + char *sline; + + /* Offset in that line. */ + int line_index; + + /* Non-zero if we are doing a reverse search. */ + int reverse; + + /* The list of characters which terminate the search, but are not + subsequently executed. If the variable isearch-terminators has + been set, we use that value, otherwise we use ESC and C-J. */ + char *isearch_terminators; + + RL_SETSTATE(RL_STATE_ISEARCH); + orig_point = rl_point; + orig_mark = rl_mark; + last_found_line = orig_line = where_history (); + reverse = direction < 0; + hlist = history_list (); + allocated_line = (char *)NULL; + + isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators + : default_isearch_terminators; + + /* Create an arrary of pointers to the lines that we want to search. */ + rl_maybe_replace_line (); + i = 0; + if (hlist) + for (i = 0; hlist[i]; i++); + + /* Allocate space for this many lines, +1 for the current input line, + and remember those lines. */ + lines = (char **)xmalloc ((1 + (hlen = i)) * sizeof (char *)); + for (i = 0; i < hlen; i++) + lines[i] = hlist[i]->line; + + if (_rl_saved_line_for_history) + lines[i] = _rl_saved_line_for_history->line; + else + { + /* Keep track of this so we can free it. */ + allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer)); + strcpy (allocated_line, &rl_line_buffer[0]); + lines[i] = allocated_line; + } + + hlen++; + + /* The line where we start the search. */ + i = orig_line; + + rl_save_prompt (); + + /* Initialize search parameters. */ + search_string = (char *)xmalloc (search_string_size = 128); + *search_string = '\0'; + search_string_index = 0; + prev_line_found = (char *)0; /* XXX */ + + /* Normalize DIRECTION into 1 or -1. */ + direction = (direction >= 0) ? 1 : -1; + + rl_display_search (search_string, reverse, -1); + + sline = rl_line_buffer; + sline_len = strlen (sline); + line_index = rl_point; + + found = failed = 0; + for (;;) + { + rl_command_func_t *f = (rl_command_func_t *)NULL; + + /* Read a key and decide how to proceed. */ + RL_SETSTATE(RL_STATE_MOREINPUT); + c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + c = _rl_read_mbstring (c, mb, MB_LEN_MAX); +#endif + + /* Translate the keys we do something with to opcodes. */ + if (c >= 0 && _rl_keymap[c].type == ISFUNC) + { + f = _rl_keymap[c].function; + + if (f == rl_reverse_search_history) + c = reverse ? -1 : -2; + else if (f == rl_forward_search_history) + c = !reverse ? -1 : -2; + else if (f == rl_rubout) + c = -3; + else if (c == CTRL ('G')) + c = -4; + else if (c == CTRL ('W')) /* XXX */ + c = -5; + else if (c == CTRL ('Y')) /* XXX */ + c = -6; + } + + /* The characters in isearch_terminators (set from the user-settable + variable isearch-terminators) are used to terminate the search but + not subsequently execute the character as a command. The default + value is "\033\012" (ESC and C-J). */ + if (strchr (isearch_terminators, c)) + { + /* ESC still terminates the search, but if there is pending + input or if input arrives within 0.1 seconds (on systems + with select(2)) it is used as a prefix character + with rl_execute_next. WATCH OUT FOR THIS! This is intended + to allow the arrow keys to be used like ^F and ^B are used + to terminate the search and execute the movement command. + XXX - since _rl_input_available depends on the application- + settable keyboard timeout value, this could alternatively + use _rl_input_queued(100000) */ + if (c == ESC && _rl_input_available ()) + rl_execute_next (ESC); + break; + } + +#define ENDSRCH_CHAR(c) \ + ((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G'))) + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + if (c >= 0 && strlen (mb) == 1 && ENDSRCH_CHAR (c)) + { + /* This sets rl_pending_input to c; it will be picked up the next + time rl_read_key is called. */ + rl_execute_next (c); + break; + } + } + else +#endif + if (c >= 0 && ENDSRCH_CHAR (c)) + { + /* This sets rl_pending_input to c; it will be picked up the next + time rl_read_key is called. */ + rl_execute_next (c); + break; + } + + switch (c) + { + case -1: + if (search_string_index == 0) + { + if (last_isearch_string) + { + search_string_size = 64 + last_isearch_string_len; + search_string = (char *)xrealloc (search_string, search_string_size); + strcpy (search_string, last_isearch_string); + search_string_index = last_isearch_string_len; + rl_display_search (search_string, reverse, -1); + break; + } + continue; + } + else if (reverse) + --line_index; + else if (line_index != sline_len) + ++line_index; + else + rl_ding (); + break; + + /* switch directions */ + case -2: + direction = -direction; + reverse = direction < 0; + break; + + /* delete character from search string. */ + case -3: /* C-H, DEL */ + /* 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. But this will + do until we have a real isearch-undo. */ + if (search_string_index == 0) + rl_ding (); + else + search_string[--search_string_index] = '\0'; + + break; + + case -4: /* C-G */ + rl_replace_line (lines[orig_line], 0); + rl_point = orig_point; + rl_mark = orig_mark; + rl_restore_prompt(); + rl_clear_message (); + if (allocated_line) + free (allocated_line); + free (lines); + RL_UNSETSTATE(RL_STATE_ISEARCH); + return 0; + + case -5: /* C-W */ + /* skip over portion of line we already matched */ + wstart = rl_point + search_string_index; + if (wstart >= rl_end) + { + rl_ding (); + break; + } + + /* if not in a word, move to one. */ + if (rl_alphabetic(rl_line_buffer[wstart]) == 0) + { + rl_ding (); + break; + } + n = wstart; + while (n < rl_end && rl_alphabetic(rl_line_buffer[n])) + n++; + wlen = n - wstart + 1; + if (search_string_index + wlen + 1 >= search_string_size) + { + search_string_size += wlen + 1; + search_string = (char *)xrealloc (search_string, search_string_size); + } + for (; wstart < n; wstart++) + search_string[search_string_index++] = rl_line_buffer[wstart]; + search_string[search_string_index] = '\0'; + break; + + case -6: /* C-Y */ + /* skip over portion of line we already matched */ + wstart = rl_point + search_string_index; + if (wstart >= rl_end) + { + rl_ding (); + break; + } + n = rl_end - wstart + 1; + if (search_string_index + n + 1 >= search_string_size) + { + search_string_size += n + 1; + search_string = (char *)xrealloc (search_string, search_string_size); + } + for (n = wstart; n < rl_end; n++) + search_string[search_string_index++] = rl_line_buffer[n]; + search_string[search_string_index] = '\0'; + break; + + default: + /* Add character to search string and continue search. */ + if (search_string_index + 2 >= search_string_size) + { + search_string_size += 128; + search_string = (char *)xrealloc (search_string, search_string_size); + } +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + { + int j, l; + for (j = 0, l = strlen (mb); j < l; ) + search_string[search_string_index++] = mb[j++]; + } + else +#endif + search_string[search_string_index++] = c; + search_string[search_string_index] = '\0'; + break; + } + + for (found = failed = 0;;) + { + int limit = sline_len - search_string_index + 1; + + /* Search the current line. */ + while (reverse ? (line_index >= 0) : (line_index < limit)) + { + if (STREQN (search_string, sline + line_index, search_string_index)) + { + found++; + break; + } + else + line_index += direction; + } + if (found) + break; + + /* Move to the next line, but skip new copies of the line + we just found and lines shorter than the string we're + searching for. */ + do + { + /* Move to the next line. */ + i += direction; + + /* At limit for direction? */ + if (reverse ? (i < 0) : (i == hlen)) + { + failed++; + break; + } + + /* We will need these later. */ + sline = lines[i]; + sline_len = strlen (sline); + } + while ((prev_line_found && STREQ (prev_line_found, lines[i])) || + (search_string_index > sline_len)); + + if (failed) + break; + + /* Now set up the line for searching... */ + line_index = reverse ? sline_len - search_string_index : 0; + } + + if (failed) + { + /* We cannot find the search string. Ding the bell. */ + rl_ding (); + i = last_found_line; + continue; /* XXX - was break */ + } + + /* We have found the search string. Just display it. But don't + actually move there in the history list until the user accepts + the location. */ + if (found) + { + prev_line_found = lines[i]; + rl_replace_line (lines[i], 0); + rl_point = line_index; + last_found_line = i; + rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i); + } + } + + /* The searching is over. The user may have found the string that she + was looking for, or else she may have exited a failing search. If + LINE_INDEX is -1, then that shows that the string searched for was + not found. We use this to determine where to place rl_point. */ + + /* First put back the original state. */ + strcpy (rl_line_buffer, lines[orig_line]); + + rl_restore_prompt (); + + /* Save the search string for possible later use. */ + FREE (last_isearch_string); + last_isearch_string = search_string; + last_isearch_string_len = search_string_index; + + if (last_found_line < orig_line) + rl_get_previous_history (orig_line - last_found_line, 0); + else + rl_get_next_history (last_found_line - orig_line, 0); + + /* If the string was not found, put point at the end of the last matching + line. If last_found_line == orig_line, we didn't find any matching + history lines at all, so put point back in its original position. */ + if (line_index < 0) + { + if (last_found_line == orig_line) + line_index = orig_point; + else + line_index = strlen (rl_line_buffer); + rl_mark = orig_mark; + } + + rl_point = line_index; + /* Don't worry about where to put the mark here; rl_get_previous_history + and rl_get_next_history take care of it. */ + + rl_clear_message (); + + FREE (allocated_line); + free (lines); + + RL_UNSETSTATE(RL_STATE_ISEARCH); + + return 0; +} diff --git a/lib/readline/misc.c b/lib/readline/misc.c index 5054358d1..d4558321d 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -1,6 +1,6 @@ /* misc.c -- miscellaneous bindable readline functions. */ -/* Copyright (C) 1987-2004 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -63,6 +63,8 @@ void _rl_free_history_entry PARAMS((HIST_ENTRY *)); to preserve the value of rl_point from line to line. */ int _rl_history_preserve_point = 0; +_rl_arg_cxt _rl_argcxt; + /* Saved target point for when _rl_history_preserve_point is set. Special value of -1 means that point is at the end of the line. */ int _rl_history_saved_point = -1; @@ -73,77 +75,74 @@ int _rl_history_saved_point = -1; /* */ /* **************************************************************** */ -/* Handle C-u style numeric args, as well as M--, and M-digits. */ -static int -rl_digit_loop () +int +_rl_arg_overflow () { - int key, c, sawminus, sawdigits; + if (rl_numeric_arg > 1000000) + { + _rl_argcxt = 0; + rl_explicit_arg = rl_numeric_arg = 0; + rl_ding (); + rl_restore_prompt (); + rl_clear_message (); + RL_UNSETSTATE(RL_STATE_NUMERICARG); + return 1; + } + return 0; +} +void +_rl_arg_init () +{ rl_save_prompt (); - + _rl_argcxt = 0; RL_SETSTATE(RL_STATE_NUMERICARG); - sawminus = sawdigits = 0; - while (1) - { - if (rl_numeric_arg > 1000000) - { - sawdigits = rl_explicit_arg = rl_numeric_arg = 0; - rl_ding (); - rl_restore_prompt (); - rl_clear_message (); - RL_UNSETSTATE(RL_STATE_NUMERICARG); - return 1; - } - rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg); - RL_SETSTATE(RL_STATE_MOREINPUT); - key = c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); +} - if (c < 0) - { - _rl_abort_internal (); - return -1; - } +int +_rl_arg_getchar () +{ + int c; - /* If we see a key bound to `universal-argument' after seeing digits, - it ends the argument but is otherwise ignored. */ - if (_rl_keymap[c].type == ISFUNC && - _rl_keymap[c].function == rl_universal_argument) - { - if (sawdigits == 0) - { - rl_numeric_arg *= 4; - continue; - } - else - { - RL_SETSTATE(RL_STATE_MOREINPUT); - key = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); - rl_restore_prompt (); - rl_clear_message (); - RL_UNSETSTATE(RL_STATE_NUMERICARG); - return (_rl_dispatch (key, _rl_keymap)); - } - } + rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg); + RL_SETSTATE(RL_STATE_MOREINPUT); + c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); - c = UNMETA (c); + return c; +} - if (_rl_digit_p (c)) - { - rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0'; - sawdigits = rl_explicit_arg = 1; - } - else if (c == '-' && rl_explicit_arg == 0) +/* Process C as part of the current numeric argument. Return -1 if the + argument should be aborted, 0 if we should not read any more chars, and + 1 if we should continue to read chars. */ +int +_rl_arg_dispatch (cxt, c) + _rl_arg_cxt cxt; + int c; +{ + int key, r; + + key = c; + + /* If we see a key bound to `universal-argument' after seeing digits, + it ends the argument but is otherwise ignored. */ + if (_rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument) + { + if ((cxt & NUM_SAWDIGITS) == 0) { - rl_numeric_arg = sawminus = 1; - rl_arg_sign = -1; + rl_numeric_arg *= 4; + return 1; } + else if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_argcxt |= NUM_READONE; + return 0; /* XXX */ + } else { - /* Make M-- command equivalent to M--1 command. */ - if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0) - rl_explicit_arg = 1; + RL_SETSTATE(RL_STATE_MOREINPUT); + key = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); rl_restore_prompt (); rl_clear_message (); RL_UNSETSTATE(RL_STATE_NUMERICARG); @@ -151,35 +150,96 @@ rl_digit_loop () } } - /*NOTREACHED*/ -} + c = UNMETA (c); -/* Add the current digit to the argument in progress. */ -int -rl_digit_argument (ignore, key) - int ignore, key; -{ - rl_execute_next (key); - return (rl_digit_loop ()); + if (_rl_digit_p (c)) + { + r = _rl_digit_value (c); + rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + r : r; + rl_explicit_arg = 1; + _rl_argcxt |= NUM_SAWDIGITS; + } + else if (c == '-' && rl_explicit_arg == 0) + { + rl_numeric_arg = 1; + _rl_argcxt |= NUM_SAWMINUS; + rl_arg_sign = -1; + } + else + { + /* Make M-- command equivalent to M--1 command. */ + if ((_rl_argcxt & NUM_SAWMINUS) && rl_numeric_arg == 1 && rl_explicit_arg == 0) + rl_explicit_arg = 1; + rl_restore_prompt (); + rl_clear_message (); + RL_UNSETSTATE(RL_STATE_NUMERICARG); + + r = _rl_dispatch (key, _rl_keymap); + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + /* At worst, this will cause an extra redisplay. Otherwise, + we have to wait until the next character comes in. */ + if (rl_done == 0) + (*rl_redisplay_function) (); + r = 0; + } + return r; + } + + return 1; } -/* What to do when you abort reading an argument. */ -int -rl_discard_argument () +/* Handle C-u style numeric args, as well as M--, and M-digits. */ +static int +rl_digit_loop () { - rl_ding (); - rl_clear_message (); - _rl_init_argument (); - return 0; + int c, r; + + while (1) + { + if (_rl_arg_overflow ()) + return 1; + + c = _rl_arg_getchar (); + + if (c < 0) + { + _rl_abort_internal (); + return -1; + } + + r = _rl_arg_dispatch (_rl_argcxt, c); + if (r <= 0 || (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)) + break; + } } /* Create a default argument. */ -int -_rl_init_argument () +void +_rl_reset_argument () { rl_numeric_arg = rl_arg_sign = 1; rl_explicit_arg = 0; - return 0; + _rl_argcxt = 0; +} + +/* Start a numeric argument with initial value KEY */ +int +rl_digit_argument (ignore, key) + int ignore, key; +{ + _rl_arg_init (); + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_arg_dispatch (_rl_argcxt, key); + rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg); + return 0; + } + else + { + rl_execute_next (key); + return (rl_digit_loop ()); + } } /* C-u, universal argument. Multiply the current argument by 4. @@ -189,8 +249,43 @@ int rl_universal_argument (count, key) int count, key; { + _rl_arg_init (); rl_numeric_arg *= 4; - return (rl_digit_loop ()); + + return (RL_ISSTATE (RL_STATE_CALLBACK) ? 0 : rl_digit_loop ()); +} + +int +_rl_arg_callback (cxt) + _rl_arg_cxt cxt; +{ + int c, r; + + c = _rl_arg_getchar (); + + if (_rl_argcxt & NUM_READONE) + { + _rl_argcxt &= ~NUM_READONE; + rl_restore_prompt (); + rl_clear_message (); + RL_UNSETSTATE(RL_STATE_NUMERICARG); + rl_execute_next (c); + return 0; + } + + r = _rl_arg_dispatch (cxt, c); + return (r != 1); +} + +/* What to do when you abort reading an argument. */ +int +rl_discard_argument () +{ + rl_ding (); + rl_clear_message (); + _rl_reset_argument (); + + return 0; } /* **************************************************************** */ diff --git a/lib/readline/readline.c b/lib/readline/readline.c index 74fa5eb69..2ac774523 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -421,7 +421,7 @@ readline_internal_charloop () if (rl_pending_input == 0) { /* Then initialize the argument and number of keys read. */ - _rl_init_argument (); + _rl_reset_argument (); rl_key_sequence_length = 0; } diff --git a/lib/readline/readline.h b/lib/readline/readline.h index 3d5a62707..95bcc4cf2 100644 --- a/lib/readline/readline.h +++ b/lib/readline/readline.h @@ -1,6 +1,6 @@ /* Readline.h -- the names of functions callable from within readline. */ -/* Copyright (C) 1987-2004 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -40,9 +40,9 @@ extern "C" { #endif /* Hex-encoded Readline version number. */ -#define RL_READLINE_VERSION 0x0500 /* Readline 5.0 */ +#define RL_READLINE_VERSION 0x0501 /* Readline 5.1 */ #define RL_VERSION_MAJOR 5 -#define RL_VERSION_MINOR 0 +#define RL_VERSION_MINOR 1 /* Readline data structures. */ @@ -760,30 +760,32 @@ extern int rl_inhibit_completion; #define MULT_MATCH 2 /* Possible state values for rl_readline_state */ -#define RL_STATE_NONE 0x00000 /* no state; before first call */ - -#define RL_STATE_INITIALIZING 0x00001 /* initializing */ -#define RL_STATE_INITIALIZED 0x00002 /* initialization done */ -#define RL_STATE_TERMPREPPED 0x00004 /* terminal is prepped */ -#define RL_STATE_READCMD 0x00008 /* reading a command key */ -#define RL_STATE_METANEXT 0x00010 /* reading input after ESC */ -#define RL_STATE_DISPATCHING 0x00020 /* dispatching to a command */ -#define RL_STATE_MOREINPUT 0x00040 /* reading more input in a command function */ -#define RL_STATE_ISEARCH 0x00080 /* doing incremental search */ -#define RL_STATE_NSEARCH 0x00100 /* doing non-inc search */ -#define RL_STATE_SEARCH 0x00200 /* doing a history search */ -#define RL_STATE_NUMERICARG 0x00400 /* reading numeric argument */ -#define RL_STATE_MACROINPUT 0x00800 /* getting input from a macro */ -#define RL_STATE_MACRODEF 0x01000 /* defining keyboard macro */ -#define RL_STATE_OVERWRITE 0x02000 /* overwrite mode */ -#define RL_STATE_COMPLETING 0x04000 /* doing completion */ -#define RL_STATE_SIGHANDLER 0x08000 /* in readline sighandler */ -#define RL_STATE_UNDOING 0x10000 /* doing an undo */ -#define RL_STATE_INPUTPENDING 0x20000 /* rl_execute_next called */ -#define RL_STATE_TTYCSAVED 0x40000 /* tty special chars saved */ -#define RL_STATE_CALLBACK 0x80000 /* using the callback interface */ - -#define RL_STATE_DONE 0x80000 /* done; accepted line */ +#define RL_STATE_NONE 0x000000 /* no state; before first call */ + +#define RL_STATE_INITIALIZING 0x000001 /* initializing */ +#define RL_STATE_INITIALIZED 0x000002 /* initialization done */ +#define RL_STATE_TERMPREPPED 0x000004 /* terminal is prepped */ +#define RL_STATE_READCMD 0x000008 /* reading a command key */ +#define RL_STATE_METANEXT 0x000010 /* reading input after ESC */ +#define RL_STATE_DISPATCHING 0x000020 /* dispatching to a command */ +#define RL_STATE_MOREINPUT 0x000040 /* reading more input in a command function */ +#define RL_STATE_ISEARCH 0x000080 /* doing incremental search */ +#define RL_STATE_NSEARCH 0x000100 /* doing non-inc search */ +#define RL_STATE_SEARCH 0x000200 /* doing a history search */ +#define RL_STATE_NUMERICARG 0x000400 /* reading numeric argument */ +#define RL_STATE_MACROINPUT 0x000800 /* getting input from a macro */ +#define RL_STATE_MACRODEF 0x001000 /* defining keyboard macro */ +#define RL_STATE_OVERWRITE 0x002000 /* overwrite mode */ +#define RL_STATE_COMPLETING 0x004000 /* doing completion */ +#define RL_STATE_SIGHANDLER 0x008000 /* in readline sighandler */ +#define RL_STATE_UNDOING 0x010000 /* doing an undo */ +#define RL_STATE_INPUTPENDING 0x020000 /* rl_execute_next called */ +#define RL_STATE_TTYCSAVED 0x040000 /* tty special chars saved */ +#define RL_STATE_CALLBACK 0x080000 /* using the callback interface */ +#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */ +#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */ + +#define RL_STATE_DONE 0x800000 /* done; accepted line */ #define RL_SETSTATE(x) (rl_readline_state |= (x)) #define RL_UNSETSTATE(x) (rl_readline_state &= ~(x)) diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h index 66837d1c4..4eafa7d64 100644 --- a/lib/readline/rlprivate.h +++ b/lib/readline/rlprivate.h @@ -1,7 +1,7 @@ /* rlprivate.h -- functions and variables global to the readline library, but not intended for use by applications. */ -/* Copyright (C) 1999-2004 Free Software Foundation, Inc. +/* Copyright (C) 1999-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -28,6 +28,73 @@ #include "rlstdc.h" #include "posixjmp.h" /* defines procenv_t */ +/************************************************************************* + * * + * Global structs undocumented in texinfo manual and not in readline.h * + * * + *************************************************************************/ +/* search types */ +#define RL_SEARCH_ISEARCH 0x01 /* incremental search */ +#define RL_SEARCH_NSEARCH 0x02 /* non-incremental search */ +#define RL_SEARCH_CSEARCH 0x04 /* intra-line char search */ + +/* search flags */ +#define SF_REVERSE 0x01 +#define SF_FOUND 0x02 +#define SF_FAILED 0x04 + +typedef struct __rl_search_context +{ + int type; + int sflags; + + char *search_string; + int search_string_index; + int search_string_size; + + char **lines; + char *allocated_line; + int hlen; + int hindex; + + int save_point; + int save_mark; + int save_line; + int last_found_line; + char *prev_line_found; + + int history_pos; + int direction; + + int lastc; +#if defined (HANDLE_MULTIBYTE) + char mb[MB_LEN_MAX]; +#endif + + char *sline; + int sline_len; + int sline_index; + + char *search_terminators; +} _rl_search_cxt; + +/* Callback data for reading numeric arguments */ +#define NUM_SAWMINUS 0x01 +#define NUM_SAWDIGITS 0x02 +#define NUM_READONE 0x04 + +typedef int _rl_arg_cxt; + +/* `Generic' callback data and functions */ +typedef struct __rl_callback_generic_arg +{ + int count; + int i1, i2; + /* add here as needed */ +} _rl_callback_generic_arg; + +typedef int _rl_callback_func_t PARAMS((_rl_callback_generic_arg *)); + /************************************************************************* * * * Global functions undocumented in texinfo manual and not in readline.h * @@ -100,6 +167,10 @@ extern void readline_internal_setup PARAMS((void)); extern char *readline_internal_teardown PARAMS((int)); extern int readline_internal_char PARAMS((void)); +/* callback.c */ +extern _rl_callback_generic_arg *_rl_callback_data_alloc PARAMS((int)); +extern void _rl_callback_data_dispose PARAMS((_rl_callback_generic_arg *)); + #endif /* READLINE_CALLBACKS */ /* bind.c */ @@ -132,6 +203,15 @@ extern void _rl_insert_typein PARAMS((int)); extern int _rl_unget_char PARAMS((int)); extern int _rl_pushed_input_available PARAMS((void)); +/* isearch.c */ +extern _rl_search_cxt *_rl_scxt_alloc PARAMS((int, int)); +extern void _rl_scxt_dispose PARAMS((_rl_search_cxt *, int)); + +extern int _rl_isearch_dispatch PARAMS((_rl_search_cxt *, int)); +extern int _rl_isearch_callback PARAMS((_rl_search_cxt *)); + +extern int _rl_search_getchar PARAMS((_rl_search_cxt *)); + /* macro.c */ extern void _rl_with_macro_input PARAMS((char *)); extern int _rl_next_macro_key PARAMS((void)); @@ -141,7 +221,12 @@ extern void _rl_add_macro_char PARAMS((int)); extern void _rl_kill_kbd_macro PARAMS((void)); /* misc.c */ -extern int _rl_init_argument PARAMS((void)); +extern int _rl_arg_overflow PARAMS((void)); +extern void _rl_arg_init PARAMS((void)); +extern int _rl_arg_getchar PARAMS((void)); +extern int _rl_arg_callback PARAMS((_rl_arg_cxt)); +extern void _rl_reset_argument PARAMS((void)); + extern void _rl_start_using_history PARAMS((void)); extern int _rl_free_saved_history_line PARAMS((void)); extern void _rl_set_insert_mode PARAMS((int, int)); @@ -162,6 +247,9 @@ extern int _rl_dispatch_subseq PARAMS((int, Keymap, int)); extern int _rl_disable_tty_signals PARAMS((void)); extern int _rl_restore_tty_signals PARAMS((void)); +/* search.c */ +extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *)); + /* terminal.c */ extern void _rl_get_screen_size PARAMS((int, int)); extern int _rl_init_terminal_io PARAMS((const char *)); @@ -217,6 +305,10 @@ extern void _rl_vi_done_inserting PARAMS((void)); extern const char *_rl_possible_control_prefixes[]; extern const char *_rl_possible_meta_prefixes[]; +/* callback.c */ +extern _rl_callback_func_t *_rl_callback_func; +extern _rl_callback_generic_arg *_rl_callback_data; + /* complete.c */ extern int _rl_complete_show_all; extern int _rl_complete_show_unmodified; @@ -231,11 +323,14 @@ extern int _rl_page_completions; extern int _rl_vis_botlin; extern int _rl_last_c_pos; extern int _rl_suppress_redisplay; +extern int _rl_want_redisplay; extern char *rl_display_prompt; /* isearch.c */ extern char *_rl_isearch_terminators; +extern _rl_search_cxt *_rl_iscxt; + /* macro.c */ extern char *_rl_executing_macro; @@ -243,6 +338,8 @@ extern char *_rl_executing_macro; extern int _rl_history_preserve_point; extern int _rl_history_saved_point; +extern _rl_arg_cxt _rl_argcxt; + /* readline.c */ extern int _rl_horizontal_scroll_mode; extern int _rl_mark_modified_lines; @@ -260,6 +357,9 @@ extern int _rl_last_command_was_kill; extern int _rl_eof_char; extern procenv_t readline_top_level; +/* search.c */ +extern _rl_search_cxt *_rl_nscxt; + /* terminal.c */ extern int _rl_enable_keypad; extern int _rl_enable_meta; diff --git a/lib/readline/search.c b/lib/readline/search.c index ce7d54eb7..103efd1ab 100644 --- a/lib/readline/search.c +++ b/lib/readline/search.c @@ -1,6 +1,6 @@ /* search.c - code for non-incremental searching in emacs and vi modes. */ -/* Copyright (C) 1992 Free Software Foundation, Inc. +/* Copyright (C) 1992-2005 Free Software Foundation, Inc. This file is part of the Readline Library (the Library), a set of routines for providing Emacs style line input to programs that ask @@ -53,6 +53,8 @@ #endif #define abs(x) (((x) >= 0) ? (x) : -(x)) +_rl_search_cxt *_rl_nscxt = 0; + extern HIST_ENTRY *_rl_saved_line_for_history; /* Functions imported from the rest of the library. */ @@ -70,11 +72,16 @@ static int history_string_size; static void make_history_line_current PARAMS((HIST_ENTRY *)); static int noninc_search_from_pos PARAMS((char *, int, int)); -static void noninc_dosearch PARAMS((char *, int)); -static void noninc_search PARAMS((int, int)); +static int noninc_dosearch PARAMS((char *, int)); +static int noninc_search PARAMS((int, int)); static int rl_history_search_internal PARAMS((int, int)); static void rl_history_search_reinit PARAMS((void)); +static _rl_search_cxt *_rl_nsearch_init PARAMS((int, int)); +static int _rl_nsearch_cleanup PARAMS((_rl_search_cxt *, int)); +static void _rl_nsearch_abort PARAMS((_rl_search_cxt *)); +static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int)); + /* Make the data from the history entry ENTRY be the contents of the current line. This doesn't do anything with rl_point; the caller must set it. */ @@ -130,8 +137,8 @@ noninc_search_from_pos (string, pos, dir) /* Search for a line in the history containing STRING. If DIR is < 0, the search is backwards through previous entries, else through subsequent - entries. */ -static void + entries. Returns 1 if the search was successful, 0 otherwise. */ +static int noninc_dosearch (string, dir) char *string; int dir; @@ -142,7 +149,7 @@ noninc_dosearch (string, dir) if (string == 0 || *string == '\0' || noninc_history_pos < 0) { rl_ding (); - return; + return 0; } pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir); @@ -153,7 +160,7 @@ noninc_dosearch (string, dir) rl_clear_message (); rl_point = 0; rl_ding (); - return; + return 0; } noninc_history_pos = pos; @@ -164,7 +171,7 @@ noninc_dosearch (string, dir) #if defined (VI_MODE) if (rl_editing_mode != vi_mode) #endif - history_set_pos (oldpos); + history_set_pos (oldpos); make_history_line_current (entry); @@ -172,27 +179,24 @@ noninc_dosearch (string, dir) rl_mark = rl_end; rl_clear_message (); + return 1; } -/* Search non-interactively through the history list. DIR < 0 means to - search backwards through the history of previous commands; otherwise - the search is for commands subsequent to the current position in the - history list. PCHAR is the character to use for prompting when reading - the search string; if not specified (0), it defaults to `:'. */ -static void -noninc_search (dir, pchar) - int dir; - int pchar; +static _rl_search_cxt * +_rl_nsearch_init (dir, pchar) + int dir, pchar; { - int saved_point, saved_mark, c; + _rl_search_cxt *cxt; char *p; -#if defined (HANDLE_MULTIBYTE) - char mb[MB_LEN_MAX]; -#endif + + cxt = _rl_scxt_alloc (RL_SEARCH_NSEARCH, 0); + if (dir < 0) + cxt->sflags |= SF_REVERSE; /* not strictly needed */ + + cxt->direction = dir; + cxt->history_pos = cxt->save_line; rl_maybe_save_line (); - saved_point = rl_point; - saved_mark = rl_mark; /* Clear the undo list, since reading the search string should create its own undo list, and the whole list will end up being freed when we @@ -207,99 +211,162 @@ noninc_search (dir, pchar) rl_message (p, 0, 0); free (p); -#define SEARCH_RETURN rl_restore_prompt (); RL_UNSETSTATE(RL_STATE_NSEARCH); return - RL_SETSTATE(RL_STATE_NSEARCH); - /* Read the search string. */ - while (1) + + _rl_nscxt = cxt; + + return cxt; +} + +static int +_rl_nsearch_cleanup (cxt, r) + _rl_search_cxt *cxt; + int r; +{ + _rl_scxt_dispose (cxt, 0); + _rl_nscxt = 0; + + RL_UNSETSTATE(RL_STATE_NSEARCH); + + return (r != 1); +} + +static void +_rl_nsearch_abort (cxt) + _rl_search_cxt *cxt; +{ + rl_maybe_unsave_line (); + rl_clear_message (); + rl_point = cxt->save_point; + rl_mark = cxt->save_mark; + rl_restore_prompt (); + + RL_UNSETSTATE (RL_STATE_NSEARCH); +} + +/* Process just-read character C according to search context CXT. Return -1 + if the caller should abort the search, 0 if we should break out of the + loop, and 1 if we should continue to read characters. */ +static int +_rl_nsearch_dispatch (cxt, c) + _rl_search_cxt *cxt; + int c; +{ + switch (c) { - RL_SETSTATE(RL_STATE_MOREINPUT); - c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); + case CTRL('W'): + rl_unix_word_rubout (1, c); + break; -#if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - c = _rl_read_mbstring (c, mb, MB_LEN_MAX); -#endif + case CTRL('U'): + rl_unix_line_discard (1, c); + break; - if (c == 0) - break; + case RETURN: + case NEWLINE: + return 0; - switch (c) + case CTRL('H'): + case RUBOUT: + if (rl_point == 0) { - case CTRL('H'): - case RUBOUT: - if (rl_point == 0) - { - rl_maybe_unsave_line (); - rl_clear_message (); - rl_point = saved_point; - rl_mark = saved_mark; - SEARCH_RETURN; - } - _rl_rubout_char (1, c); - break; - - case CTRL('W'): - rl_unix_word_rubout (1, c); - break; - - case CTRL('U'): - rl_unix_line_discard (1, c); - break; - - case RETURN: - case NEWLINE: - goto dosearch; - /* NOTREACHED */ - break; - - case CTRL('C'): - case CTRL('G'): - rl_maybe_unsave_line (); - rl_clear_message (); - rl_point = saved_point; - rl_mark = saved_mark; - rl_ding (); - SEARCH_RETURN; + _rl_nsearch_abort (cxt); + return -1; + } + _rl_rubout_char (1, c); + break; + + case CTRL('C'): + case CTRL('G'): + rl_ding (); + _rl_nsearch_abort (cxt); + return -1; - default: + default: #if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - rl_insert_text (mb); - else + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + rl_insert_text (cxt->mb); + else #endif - _rl_insert_char (1, c); - break; - } - (*rl_redisplay_function) (); + _rl_insert_char (1, c); + break; } - dosearch: - rl_mark = saved_mark; + (*rl_redisplay_function) (); + return 1; +} + +/* Perform one search according to CXT, using NONINC_SEARCH_STRING. Return + -1 if the search should be aborted, any other value means to clean up + using _rl_nsearch_cleanup (). Returns 1 if the search was successful, + 0 otherwise. */ +static int +_rl_nsearch_dosearch (cxt) + _rl_search_cxt *cxt; +{ + rl_mark = cxt->save_mark; /* If rl_point == 0, we want to re-use the previous search string and start from the saved history position. If there's no previous search string, punt. */ if (rl_point == 0) { - if (!noninc_search_string) + if (noninc_search_string == 0) { rl_ding (); - SEARCH_RETURN; + rl_restore_prompt (); + RL_UNSETSTATE (RL_STATE_NSEARCH); + return -1; } } else { /* We want to start the search from the current history position. */ - noninc_history_pos = where_history (); + noninc_history_pos = cxt->save_line; FREE (noninc_search_string); noninc_search_string = savestring (rl_line_buffer); } rl_restore_prompt (); - noninc_dosearch (noninc_search_string, dir); - RL_UNSETSTATE(RL_STATE_NSEARCH); + return (noninc_dosearch (noninc_search_string, cxt->direction)); +} + +/* Search non-interactively through the history list. DIR < 0 means to + search backwards through the history of previous commands; otherwise + the search is for commands subsequent to the current position in the + history list. PCHAR is the character to use for prompting when reading + the search string; if not specified (0), it defaults to `:'. */ +static int +noninc_search (dir, pchar) + int dir; + int pchar; +{ + _rl_search_cxt *cxt; + int c, r; + + cxt = _rl_nsearch_init (dir, pchar); + + if (RL_ISSTATE (RL_STATE_CALLBACK)) + return (0); + + /* Read the search string. */ + r = 0; + while (1) + { + c = _rl_search_getchar (cxt); + + if (c == 0) + break; + + r = _rl_nsearch_dispatch (cxt, c); + if (r < 0) + return 1; + else if (r == 0) + break; + } + + r = _rl_nsearch_dosearch (cxt); + return ((r >= 0) ? _rl_nsearch_cleanup (cxt, r) : (r != 1)); } /* Search forward through the history list for a string. If the vi-mode @@ -308,8 +375,7 @@ int rl_noninc_forward_search (count, key) int count, key; { - noninc_search (1, (key == '?') ? '?' : 0); - return 0; + return noninc_search (1, (key == '?') ? '?' : 0); } /* Reverse search the history list for a string. If the vi-mode code @@ -318,8 +384,7 @@ int rl_noninc_reverse_search (count, key) int count, key; { - noninc_search (-1, (key == '/') ? '/' : 0); - return 0; + return noninc_search (-1, (key == '/') ? '/' : 0); } /* Search forward through the history list for the last string searched @@ -328,13 +393,15 @@ int rl_noninc_forward_search_again (count, key) int count, key; { + int r; + if (!noninc_search_string) { rl_ding (); return (-1); } - noninc_dosearch (noninc_search_string, 1); - return 0; + r = noninc_dosearch (noninc_search_string, 1); + return (r != 1); } /* Reverse search in the history list for the last string searched @@ -343,15 +410,32 @@ int rl_noninc_reverse_search_again (count, key) int count, key; { + int r; + if (!noninc_search_string) { rl_ding (); return (-1); } - noninc_dosearch (noninc_search_string, -1); - return 0; + r = noninc_dosearch (noninc_search_string, -1); + return (r != 1); } +int +_rl_nsearch_callback (cxt) + _rl_search_cxt *cxt; +{ + int c, r; + + c = _rl_search_getchar (cxt); + r = _rl_nsearch_dispatch (cxt, c); + if (r != 0) + return 1; + + r = _rl_nsearch_dosearch (cxt); + return ((r >= 0) ? _rl_nsearch_cleanup (cxt, r) : (r != 1)); +} + static int rl_history_search_internal (count, dir) int count, dir; diff --git a/lib/readline/signals.c b/lib/readline/signals.c index 281488f85..f344ed834 100644 --- a/lib/readline/signals.c +++ b/lib/readline/signals.c @@ -420,7 +420,7 @@ rl_free_line_state () _rl_kill_kbd_macro (); rl_clear_message (); - _rl_init_argument (); + _rl_reset_argument (); } #endif /* HANDLE_SIGNALS */ diff --git a/lib/readline/text.c b/lib/readline/text.c index 59f55b9e8..766aa81bc 100644 --- a/lib/readline/text.c +++ b/lib/readline/text.c @@ -1,6 +1,6 @@ /* text.c -- text handling commands for readline. */ -/* Copyright (C) 1987-2004 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -62,6 +62,11 @@ static int rl_change_case PARAMS((int, int)); static int _rl_char_search PARAMS((int, int, int)); +#if defined (READLINE_CALLBACKS) +static int _rl_insert_next_callback PARAMS((_rl_callback_generic_arg *)); +static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *)); +#endif + /* **************************************************************** */ /* */ /* Insert and Delete */ @@ -842,27 +847,63 @@ rl_insert (count, c) } /* Insert the next typed character verbatim. */ -int -rl_quoted_insert (count, key) - int count, key; +static int +_rl_insert_next (count) + int count; { int c; -#if defined (HANDLE_SIGNALS) - _rl_disable_tty_signals (); -#endif - RL_SETSTATE(RL_STATE_MOREINPUT); c = rl_read_key (); RL_UNSETSTATE(RL_STATE_MOREINPUT); #if defined (HANDLE_SIGNALS) - _rl_restore_tty_signals (); + if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) + _rl_restore_tty_signals (); #endif return (_rl_insert_char (count, c)); } +#if defined (READLINE_CALLBACKS) +static int +_rl_insert_next_callback (data) + _rl_callback_generic_arg *data; +{ + int count; + + count = data->count; + + /* Deregister function, let rl_callback_read_char deallocate data */ + _rl_callback_func = 0; + _rl_want_redisplay = 1; + + return _rl_insert_next (count); +} +#endif + +int +rl_quoted_insert (count, key) + int count, key; +{ + /* Let's see...should the callback interface futz with signal handling? */ +#if defined (HANDLE_SIGNALS) + if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) + _rl_disable_tty_signals (); +#endif + +#if defined (READLINE_CALLBACKS) + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_callback_data = _rl_callback_data_alloc (count); + _rl_callback_func = _rl_insert_next_callback; + return (0); + } +#endif + + return _rl_insert_next (count); +} + /* Insert a tab character. */ int rl_tab_insert (count, key) @@ -1466,10 +1507,33 @@ _rl_char_search (count, fdir, bdir) } #endif /* !HANDLE_MULTIBYTE */ +#if defined (READLINE_CALLBACKS) +static int +_rl_char_search_callback (data) + _rl_callback_generic_arg *data; +{ + _rl_callback_func = 0; + _rl_want_redisplay = 1; + + return (_rl_char_search (data->count, data->i1, data->i2)); +} +#endif + int rl_char_search (count, key) int count, key; { +#if defined (READLINE_CALLBACKS) + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_callback_data = _rl_callback_data_alloc (count); + _rl_callback_data->i1 = FFIND; + _rl_callback_data->i2 = BFIND; + _rl_callback_func = _rl_char_search_callback; + return (0); + } +#endif + return (_rl_char_search (count, FFIND, BFIND)); } @@ -1477,6 +1541,17 @@ int rl_backward_char_search (count, key) int count, key; { +#if defined (READLINE_CALLBACKS) + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_callback_data = _rl_callback_data_alloc (count); + _rl_callback_data->i1 = BFIND; + _rl_callback_data->i2 = FFIND; + _rl_callback_func = _rl_char_search_callback; + return (0); + } +#endif + return (_rl_char_search (count, BFIND, FFIND)); } diff --git a/lib/readline/util.c b/lib/readline/util.c index d4b532f51..e44ef6434 100644 --- a/lib/readline/util.c +++ b/lib/readline/util.c @@ -1,6 +1,6 @@ /* util.c -- readline utility functions */ -/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -101,7 +101,7 @@ _rl_abort_internal () { rl_ding (); rl_clear_message (); - _rl_init_argument (); + _rl_reset_argument (); rl_clear_pending_input (); RL_UNSETSTATE (RL_STATE_MACRODEF); diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c index 5989658d2..06ec4427a 100644 --- a/lib/readline/vi_mode.c +++ b/lib/readline/vi_mode.c @@ -1,7 +1,7 @@ /* vi_mode.c -- A vi emulation mode for Bash. Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */ -/* Copyright (C) 1987-2004 Free Software Foundation, Inc. +/* Copyright (C) 1987-2005 Free Software Foundation, Inc. This file is part of the GNU Readline Library, a library for reading lines of text with interactive input and history editing. @@ -90,6 +90,7 @@ static int _rl_vi_last_arg_sign = 1; static int _rl_vi_last_motion; #if defined (HANDLE_MULTIBYTE) static char _rl_vi_last_search_mbchar[MB_LEN_MAX]; +static int _rl_vi_last_search_mblen; #else static int _rl_vi_last_search_char; #endif @@ -107,8 +108,22 @@ static int vi_mark_chars['z' - 'a' + 1]; static void _rl_vi_stuff_insert PARAMS((int)); static void _rl_vi_save_insert PARAMS((UNDO_LIST *)); + +static int _rl_vi_arg_dispatch PARAMS((int)); static int rl_digit_loop1 PARAMS((void)); +static int _rl_vi_set_mark PARAMS((void)); +static int _rl_vi_goto_mark PARAMS((void)); + +static int _rl_vi_callback_getchar PARAMS((char *, int)); + +#if defined (READLINE_CALLBACKS) +static int _rl_vi_callback_set_mark PARAMS((_rl_callback_generic_arg *)); +static int _rl_vi_callback_goto_mark PARAMS((_rl_callback_generic_arg *)); +static int _rl_vi_callback_change_char PARAMS((_rl_callback_generic_arg *)); +static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *)); +#endif + void _rl_vi_initialize_line () { @@ -840,7 +855,9 @@ rl_vi_domove (key, nextkey) save = rl_numeric_arg; rl_numeric_arg = _rl_digit_value (c); rl_explicit_arg = 1; + RL_SETSTATE (RL_STATE_NUMERICARG|RL_STATE_VIMOTION); rl_digit_loop1 (); + RL_UNSETSTATE (RL_STATE_VIMOTION); rl_numeric_arg *= save; RL_SETSTATE(RL_STATE_MOREINPUT); c = rl_read_key (); /* real command */ @@ -913,52 +930,59 @@ rl_vi_domove (key, nextkey) return (0); } +/* Process C as part of the current numeric argument. Return -1 if the + argument should be aborted, 0 if we should not read any more chars, and + 1 if we should continue to read chars. */ +static int +_rl_vi_arg_dispatch (c) + int c; +{ + int key; + + key = c; + if (c >= 0 && _rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument) + { + rl_numeric_arg *= 4; + return 1; + } + + c = UNMETA (c); + + if (_rl_digit_p (c)) + { + if (rl_explicit_arg) + rl_numeric_arg = (rl_numeric_arg * 10) + _rl_digit_value (c); + else + rl_numeric_arg = _rl_digit_value (c); + rl_explicit_arg = 1; + return 1; + } + else + { + rl_clear_message (); + rl_stuff_char (key); + return 0; + } +} + /* A simplified loop for vi. Don't dispatch key at end. Don't recognize minus sign? Should this do rl_save_prompt/rl_restore_prompt? */ static int rl_digit_loop1 () { - int key, c; + int c, r; - RL_SETSTATE(RL_STATE_NUMERICARG); while (1) { - if (rl_numeric_arg > 1000000) - { - rl_explicit_arg = rl_numeric_arg = 0; - rl_ding (); - rl_clear_message (); - RL_UNSETSTATE(RL_STATE_NUMERICARG); - return 1; - } - rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg); - RL_SETSTATE(RL_STATE_MOREINPUT); - key = c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); + if (_rl_arg_overflow ()) + return 1; - if (c >= 0 && _rl_keymap[c].type == ISFUNC && - _rl_keymap[c].function == rl_universal_argument) - { - rl_numeric_arg *= 4; - continue; - } + c = _rl_arg_getchar (); - c = UNMETA (c); - if (_rl_digit_p (c)) - { - if (rl_explicit_arg) - rl_numeric_arg = (rl_numeric_arg * 10) + _rl_digit_value (c); - else - rl_numeric_arg = _rl_digit_value (c); - rl_explicit_arg = 1; - } - else - { - rl_clear_message (); - rl_stuff_char (key); - break; - } + r = _rl_vi_arg_dispatch (c); + if (r <= 0) + break; } RL_UNSETSTATE(RL_STATE_NUMERICARG); @@ -1153,64 +1177,102 @@ rl_vi_first_print (count, key) return (rl_vi_back_to_indent (1, key)); } +static int _rl_cs_dir, _rl_cs_orig_dir; + +#if defined (READLINE_CALLBACKS) +static int +_rl_vi_callback_char_search (data) + _rl_callback_generic_arg *data; +{ +#if defined (HANDLE_MULTIBYTE) + _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX); +#else + RL_SETSTATE(RL_STATE_MOREINPUT); + _rl_vi_last_search_char = target = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); +#endif + + _rl_callback_func = 0; + _rl_want_redisplay = 1; + +#if defined (HANDLE_MULTIBYTE) + return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_mbchar, _rl_vi_last_search_mblen)); +#else + return (_rl_char_search_internal (data->count, _rl_cs_dir, _rl_vi_last_search_char)); +#endif +} +#endif + int rl_vi_char_search (count, key) int count, key; { #if defined (HANDLE_MULTIBYTE) static char *target; - static int mb_len; + static int tlen; #else static char target; #endif - static int orig_dir, dir; if (key == ';' || key == ',') - dir = key == ';' ? orig_dir : -orig_dir; + _rl_cs_dir = (key == ';') ? _rl_cs_orig_dir : -_rl_cs_orig_dir; else { - if (vi_redoing) -#if defined (HANDLE_MULTIBYTE) - target = _rl_vi_last_search_mbchar; -#else - target = _rl_vi_last_search_char; -#endif - else - { -#if defined (HANDLE_MULTIBYTE) - mb_len = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX); - target = _rl_vi_last_search_mbchar; -#else - RL_SETSTATE(RL_STATE_MOREINPUT); - _rl_vi_last_search_char = target = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); -#endif - } - switch (key) { case 't': - orig_dir = dir = FTO; + _rl_cs_orig_dir = _rl_cs_dir = FTO; break; case 'T': - orig_dir = dir = BTO; + _rl_cs_orig_dir = _rl_cs_dir = BTO; break; case 'f': - orig_dir = dir = FFIND; + _rl_cs_orig_dir = _rl_cs_dir = FFIND; break; case 'F': - orig_dir = dir = BFIND; + _rl_cs_orig_dir = _rl_cs_dir = BFIND; break; } + + if (vi_redoing) + { + /* set target and tlen below */ + } +#if defined (READLINE_CALLBACKS) + else if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_callback_data = _rl_callback_data_alloc (count); + _rl_callback_data->i1 = _rl_cs_dir; + _rl_callback_func = _rl_vi_callback_char_search; + return (0); + } +#endif + else + { +#if defined (HANDLE_MULTIBYTE) + _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX); +#else + RL_SETSTATE(RL_STATE_MOREINPUT); + _rl_vi_last_search_char = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); +#endif + } } #if defined (HANDLE_MULTIBYTE) - return (_rl_char_search_internal (count, dir, target, mb_len)); + target = _rl_vi_last_search_mbchar; + tlen = _rl_vi_last_search_mblen; #else - return (_rl_char_search_internal (count, dir, target)); + target = _rl_vi_last_search_char; +#endif + +#if defined (HANDLE_MULTIBYTE) + return (_rl_char_search_internal (count, _rl_cs_dir, target, tlen)); +#else + return (_rl_char_search_internal (count, _rl_cs_dir, target)); #endif } @@ -1321,25 +1383,12 @@ rl_vi_bracktype (c) } } -/* XXX - think about reading an entire mbchar with _rl_read_mbchar and - inserting it in one bunch instead of the loop below (like in - rl_vi_char_search or _rl_vi_change_mbchar_case). Set c to mbchar[0] - for test against 033 or ^C. Make sure that _rl_read_mbchar does - this right. */ -int -rl_vi_change_char (count, key) - int count, key; +static int +_rl_vi_change_char (count, c, mb) + int count, c; + char *mb; { - int c, p; - - if (vi_redoing) - c = _rl_vi_last_replacement; - else - { - RL_SETSTATE(RL_STATE_MOREINPUT); - _rl_vi_last_replacement = c = rl_read_key (); - RL_UNSETSTATE(RL_STATE_MOREINPUT); - } + int p; if (c == '\033' || c == CTRL ('C')) return -1; @@ -1349,31 +1398,85 @@ rl_vi_change_char (count, key) { p = rl_point; rl_vi_delete (1, c); + if (rl_point < p) /* Did we retreat at EOL? */ + rl_point++; #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) - { - if (rl_point < p) /* Did we retreat at EOL? */ - rl_point++; - while (_rl_insert_char (1, c)) - { - RL_SETSTATE (RL_STATE_MOREINPUT); - c = rl_read_key (); - RL_UNSETSTATE (RL_STATE_MOREINPUT); - } - } + rl_insert_text (mb); else #endif - { - if (rl_point < p) /* Did we retreat at EOL? */ - rl_point++; - _rl_insert_char (1, c); - } + _rl_insert_char (1, c); } rl_end_undo_group (); return (0); } +static int +_rl_vi_callback_getchar (mb, mblen) + char *mb; + int mblen; +{ + int c; + + RL_SETSTATE(RL_STATE_MOREINPUT); + c = rl_read_key (); + RL_UNSETSTATE(RL_STATE_MOREINPUT); + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + c = _rl_read_mbstring (c, mb, mblen); +#endif + + return c; +} + +#if defined (READLINE_CALLBACKS) +static int +_rl_vi_callback_change_char (data) + _rl_callback_generic_arg *data; +{ + int c; +#if defined (HANDLE_MULTIBYTE) + char mb[MB_LEN_MAX]; +#endif + + _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX); + + _rl_callback_func = 0; + _rl_want_redisplay = 1; + + return (_rl_vi_change_char (data->count, c, mb)); +} +#endif + +int +rl_vi_change_char (count, key) + int count, key; +{ + int c; + char mb[MB_LEN_MAX]; + + if (vi_redoing) + { + c = _rl_vi_last_replacement; + mb[0] = c; + mb[1] = '\0'; + } +#if defined (READLINE_CALLBACKS) + else if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_callback_data = _rl_callback_data_alloc (count); + _rl_callback_func = _rl_vi_callback_change_char; + return (0); + } +#endif + else + _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX); + + return (_rl_vi_change_char (count, c, mb)); +} + int rl_vi_subst (count, key) int count, key; @@ -1496,9 +1599,8 @@ rl_vi_possible_completions() #endif /* Functions to save and restore marks. */ -int -rl_vi_set_mark (count, key) - int count, key; +static int +_rl_vi_set_mark () { int ch; @@ -1516,9 +1618,36 @@ rl_vi_set_mark (count, key) return 0; } +#if defined (READLINE_CALLBACKS) +static int +_rl_vi_callback_set_mark (data) + _rl_callback_generic_arg *data; +{ + _rl_callback_func = 0; + _rl_want_redisplay = 1; + + return (_rl_vi_set_mark ()); +} +#endif + int -rl_vi_goto_mark (count, key) +rl_vi_set_mark (count, key) int count, key; +{ +#if defined (READLINE_CALLBACKS) + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_callback_data = 0; + _rl_callback_func = _rl_vi_callback_set_mark; + return (0); + } +#endif + + return (_rl_vi_set_mark ()); +} + +static int +_rl_vi_goto_mark () { int ch; @@ -1547,4 +1676,31 @@ rl_vi_goto_mark (count, key) return 0; } +#if defined (READLINE_CALLBACKS) +static int +_rl_vi_callback_goto_mark (data) + _rl_callback_generic_arg *data; +{ + _rl_callback_func = 0; + _rl_want_redisplay = 1; + + return (_rl_vi_goto_mark ()); +} +#endif + +int +rl_vi_goto_mark (count, key) + int count, key; +{ +#if defined (READLINE_CALLBACKS) + if (RL_ISSTATE (RL_STATE_CALLBACK)) + { + _rl_callback_data = 0; + _rl_callback_func = _rl_vi_callback_goto_mark; + return (0); + } +#endif + + return (_rl_vi_goto_mark ()); +} #endif /* VI_MODE */ diff --git a/support/shobj-conf b/support/shobj-conf index c2a4afdc3..5dda3532d 100755 --- a/support/shobj-conf +++ b/support/shobj-conf @@ -120,7 +120,7 @@ freebsd2* | netbsd*) ;; # FreeBSD-3.x ELF -freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*) +freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*|dragonfly*) SHOBJ_CFLAGS=-fpic SHOBJ_LD='${CC}'