From 603281bd9a333a5e8850ac78f00d2a964c3213de Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Wed, 23 Nov 2011 19:16:49 -0500 Subject: Readline-5.2 import --- CHANGELOG | 40 ++ CHANGES | 74 +++ INSTALL | 2 +- NEWS | 35 +- README | 4 +- aclocal.m4 | 82 ++- bind.c | 94 ++- callback.c | 120 ++-- complete.c | 38 +- config.h.in | 36 +- configure | 600 +++++++++++++++--- configure.in | 7 +- display.c | 210 ++++-- doc/history.dvi | Bin 79896 -> 79844 bytes doc/history.html | 6 +- doc/history.info | 54 +- doc/history.ps | 47 +- doc/history.texi | 4 +- doc/hstech.texi | 2 +- doc/hsuser.texi | 2 +- doc/readline.0 | 21 +- doc/readline.3 | 8 +- doc/readline.dvi | Bin 277700 -> 278256 bytes doc/readline.html | 29 +- doc/readline.info | 182 +++--- doc/readline.ps | 1541 +++++++++++++++++++++++---------------------- doc/readline_3.ps | 397 ++++++------ doc/rlman.texi | 4 +- doc/rltech.texi | 11 +- doc/rluser.texi | 14 +- doc/rluserman.dvi | Bin 92872 -> 93076 bytes doc/rluserman.html | 18 +- doc/rluserman.info | 70 +- doc/rluserman.ps | 1323 +++++++++++++++++++------------------- doc/rluserman.texi | 4 +- doc/version.texi | 12 +- examples/excallback.c | 3 + examples/rlfe/Makefile.in | 2 +- histexpand.c | 12 +- histfile.c | 6 +- history.c | 87 ++- input.c | 27 +- isearch.c | 4 +- kill.c | 1 + macro.c | 2 +- misc.c | 2 + readline.c | 19 + readline.h | 8 +- rlconf.h | 5 +- rlmbutil.h | 13 +- rlprivate.h | 5 + rltty.c | 1 - search.c | 3 +- signals.c | 42 +- support/shlib-install | 3 +- support/shobj-conf | 17 + terminal.c | 55 +- text.c | 30 +- tilde.c | 10 +- undo.c | 74 ++- vi_mode.c | 61 +- 61 files changed, 3323 insertions(+), 2260 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b6499c3..c64d959 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -918,3 +918,43 @@ configure.in - changed release status to `release' [readline-5.1 frozen] + + 12/9 + ---- +[readline-5.1 released] + + 12/14 + ----- +examples/rlfe/Makefile.in + - add @LIBS@ to LIBS assignment to pick up extra libraries from + configure + + 1/3/2006 + -------- +support/shlib-install + - Install shared libraries with execute bit set on Linux + + 6/9 + --- +[readline-5.2-alpha frozen] + + 6/26 + ---- +configure.in + - set CROSS_COMPILE to the empty string by default, so we don't inherit + a random value from the environment + + 7/8 + --- +[readline-5.2-alpha released] + + +[readline-5.2-beta released] + + 9/12 + ---- +config.h.in + - add defines for wcscoll, iswctype, iswupper, iswlower, towupper, + towlower functions + - replace define for wctomb with one for wcrtomb + - add defines for wchar_t, wint_t, wctype_t types diff --git a/CHANGES b/CHANGES index 1ba0c12..87e01e1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,77 @@ +This document details the changes between this version, readline-5.2, +and the previous version, readline-5.1. + +1. Changes to Readline + +a. Fixed a problem that caused segmentation faults when using readline in + callback mode and typing consecutive DEL characters on an empty line. + +b. Fixed several redisplay problems with multibyte characters, all having to + do with the different code paths and variable meanings between single-byte + and multibyte character redisplay. + +c. Fixed a problem with key sequence translation when presented with the + sequence \M-\C-x. + +d. Fixed a problem that prevented the `a' command in vi mode from being + undone and redone properly. + +e. Fixed a problem that prevented empty inserts in vi mode from being undone + properly. + +f. Fixed a problem that caused readline to initialize with an incorrect idea + of whether or not the terminal can autowrap. + +g. Fixed output of key bindings (like bash `bind -p') to honor the setting of + convert-meta and use \e where appropriate. + +h. Changed the default filename completion function to call the filename + dequoting function if the directory completion hook isn't set. This means + that any directory completion hooks need to dequote the directory name, + since application-specific hooks need to know how the word was quoted, + even if no other changes are made. + +i. Fixed a bug with creating the prompt for a non-interactive search string + when there are non-printing characters in the primary prompt. + +j. Fixed a bug that caused prompts with invisible characters to be redrawn + multiple times in a multibyte locale. + +k. Fixed a bug that could cause the key sequence scanning code to return the + wrong function. + +l. Fixed a problem with the callback interface that caused it to fail when + using multi-character keyboard macros. + +m. Fixed a bug that could cause a core dump when an edited history entry was + re-executed under certain conditions. + +n. Fixed a bug that caused readline to reference freed memory when attmpting + to display a portion of the prompt. + +o. Fixed a bug with prompt redisplay in a multi-byte locale to avoid redrawing + the prompt and input line multiple times. + +p. Fixed history expansion to not be confused by here-string redirection. + +q. Readline no longer treats read errors by converting them to newlines, as + it does with EOF. This caused partial lines to be returned from readline(). + +r. Fixed a redisplay bug that occurred in multibyte-capable locales when the + prompt was one character longer than the screen width. + +2. New Features in Readline + +a. Calling applications can now set the keyboard timeout to 0, allowing + poll-like behavior. + +b. The value of SYS_INPUTRC (configurable at compilation time) is now used as + the default last-ditch startup file. + +c. The history file reading functions now allow windows-like \r\n line + terminators. + +------------------------------------------------------------------------------- This document details the changes between this version, readline-5.1, and the previous version, readline-5.0. diff --git a/INSTALL b/INSTALL index 1a73c77..f360b9e 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,7 @@ Basic Installation ================== -These are installation instructions for Readline-5.1. +These are installation instructions for Readline-5.2. The simplest way to compile readline is: diff --git a/NEWS b/NEWS index c5e67dc..96711a0 100644 --- a/NEWS +++ b/NEWS @@ -1,32 +1,13 @@ -This is a terse description of the new features added to readline-5.1 since -the release of readline-5.0. +This is a terse description of the new features added to readline-5.2 since +the release of readline-5.1. 1. New Features in Readline -a. The key sequence sent by the keypad `delete' key is now automatically - bound to delete-char. +a. Calling applications can now set the keyboard timeout to 0, allowing + poll-like behavior. -b. A negative argument to menu-complete now cycles backward through the - completion list. +b. The value of SYS_INPUTRC (configurable at compilation time) is now used as + the default last-ditch startup file. -c. A new bindable readline variable: bind-tty-special-chars. If non-zero, - readline will bind the terminal special characters to their readline - equivalents when it's called (on by default). - -d. New bindable command: vi-rubout. Saves deleted text for possible - reinsertion, as with any vi-mode `text modification' command; `X' is bound - to this in vi command mode. - -e. If the rl_completion_query_items is set to a value < 0, readline never - asks the user whether or not to view the possible completions. - -f. New application-callable auxiliary function, rl_variable_value, returns - a string corresponding to a readline variable's value. - -g. When parsing inputrc files and variable binding commands, the parser - strips trailing whitespace from values assigned to boolean variables - before checking them. - -h. A new external application-controllable variable that allows the LINES - and COLUMNS environment variables to set the window size regardless of - what the kernel returns. +c. The history file reading functions now allow windows-like \r\n line + terminators. diff --git a/README b/README index 8dd09cc..8da9962 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ Introduction ============ -This is the Gnu Readline library, version 5.1. +This is the Gnu Readline library, version 5.2. The Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both @@ -183,4 +183,4 @@ list (mirrored to the Usenet newsgroup gnu.bash.bug) often contains Readline bug reports and fixes. Chet Ramey -chet@po.cwru.edu +chet.ramey@case.edu diff --git a/aclocal.m4 b/aclocal.m4 index 8a70084..eda151c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -933,7 +933,7 @@ AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS) fi ]) -AC_DEFUN(BASH_CHECK_LIB_TERMCAP, +AC_DEFUN([BASH_CHECK_LIB_TERMCAP], [ if test "X$bash_cv_termcap_lib" = "X"; then _bash_needmsg=yes @@ -1540,20 +1540,24 @@ fi AC_DEFUN(BASH_CHECK_DEV_FD, [AC_MSG_CHECKING(whether /dev/fd is available) AC_CACHE_VAL(bash_cv_dev_fd, -[if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then +[bash_cv_dev_fd="" +if test -d /dev/fd && test -r /dev/fd/0 < /dev/null; then # check for systems like FreeBSD 5 that only provide /dev/fd/[012] - exec 3<&0 + exec 3], [ - mbstate_t ps; - mbstate_t *psp; - psp = (mbstate_t *)0; -], bash_cv_have_mbstate_t=yes, bash_cv_have_mbstate_t=no)]) -if test $bash_cv_have_mbstate_t = yes; then +dnl checks for both mbrtowc and mbstate_t +AC_FUNC_MBRTOWC +if test $ac_cv_func_mbrtowc = yes; then AC_DEFINE(HAVE_MBSTATE_T) fi +AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype) + AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset, [AC_TRY_LINK( [#include ], @@ -1700,6 +1705,43 @@ if test $bash_cv_langinfo_codeset = yes; then AC_DEFINE(HAVE_LANGINFO_CODESET) fi +dnl check for wchar_t in +AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t, +[AC_TRY_COMPILE( +[#include +], +[ + wchar_t foo; + foo = 0; +], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)]) +if test $bash_cv_type_wchar_t = yes; then + AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here]) +fi + +dnl check for wctype_t in +AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t, +[AC_TRY_COMPILE( +[#include ], +[ + wctype_t foo; + foo = 0; +], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)]) +if test $bash_cv_type_wctype_t = yes; then + AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here]) +fi + +dnl check for wint_t in +AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t, +[AC_TRY_COMPILE( +[#include ], +[ + wint_t foo; + foo = 0; +], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)]) +if test $bash_cv_type_wint_t = yes; then + AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here]) +fi + ]) dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB @@ -1707,7 +1749,7 @@ dnl require: dnl AC_PROG_CC dnl BASH_CHECK_LIB_TERMCAP -AC_DEFUN(RL_LIB_READLINE_VERSION, +AC_DEFUN([RL_LIB_READLINE_VERSION], [ AC_REQUIRE([BASH_CHECK_LIB_TERMCAP]) diff --git a/bind.c b/bind.c index 7559d32..08c906b 100644 --- a/bind.c +++ b/bind.c @@ -1,6 +1,6 @@ /* bind.c -- key binding and startup file support for the readline library. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2006 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. @@ -370,7 +370,10 @@ rl_generic_bind (type, keyseq, data, map) ic = uc; if (ic < 0 || ic >= KEYMAP_SIZE) - return -1; + { + free (keys); + return -1; + } if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) { @@ -462,12 +465,21 @@ rl_translate_keyseq (seq, array, len) } else if (c == 'M') { - i++; - /* XXX - should obey convert-meta setting? */ + i++; /* seq[i] == '-' */ + /* XXX - obey convert-meta setting */ if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP) array[l++] = ESC; /* ESC is meta-prefix */ + else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-') + { + i += 4; + temp = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i])); + array[l++] = META (temp); + } else { + /* This doesn't yet handle things like \M-\a, which may + or may not have any reasonable meaning. You're + probably better off using straight octal or hex. */ i++; array[l++] = META (seq[i]); } @@ -565,6 +577,11 @@ rl_untranslate_keyseq (seq) kseq[i++] = '-'; c = UNMETA (c); } + else if (c == ESC) + { + kseq[i++] = '\\'; + c = 'e'; + } else if (CTRL_CHAR (c)) { kseq[i++] = '\\'; @@ -613,7 +630,12 @@ _rl_untranslate_macro_value (seq) *r++ = '-'; c = UNMETA (c); } - else if (CTRL_CHAR (c) && c != ESC) + else if (c == ESC) + { + *r++ = '\\'; + c = 'e'; + } + else if (CTRL_CHAR (c)) { *r++ = '\\'; *r++ = 'C'; @@ -672,7 +694,7 @@ rl_function_of_keyseq (keyseq, map, type) { register int i; - if (!map) + if (map == 0) map = _rl_keymap; for (i = 0; keyseq && keyseq[i]; i++) @@ -681,25 +703,27 @@ rl_function_of_keyseq (keyseq, map, type) if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) { - if (map[ESC].type != ISKMAP) + if (map[ESC].type == ISKMAP) + { + map = FUNCTION_TO_KEYMAP (map, ESC); + ic = UNMETA (ic); + } + /* XXX - should we just return NULL here, since this obviously + doesn't match? */ + else { if (type) *type = map[ESC].type; return (map[ESC].function); } - else - { - map = FUNCTION_TO_KEYMAP (map, ESC); - ic = UNMETA (ic); - } } if (map[ic].type == ISKMAP) { /* If this is the last key in the key sequence, return the map. */ - if (!keyseq[i + 1]) + if (keyseq[i + 1] == '\0') { if (type) *type = ISKMAP; @@ -709,7 +733,12 @@ rl_function_of_keyseq (keyseq, map, type) else map = FUNCTION_TO_KEYMAP (map, ic); } - else + /* If we're not at the end of the key sequence, and the current key + is bound to something other than a keymap, then the entire key + sequence is not bound. */ + else if (map[ic].type != ISKMAP && keyseq[i+1]) + return ((rl_command_func_t *)NULL); + else /* map[ic].type != ISKMAP && keyseq[i+1] == 0 */ { if (type) *type = map[ic].type; @@ -791,6 +820,7 @@ rl_re_read_init_file (count, ignore) 1. the filename used for the previous call 2. the value of the shell variable `INPUTRC' 3. ~/.inputrc + 4. /etc/inputrc If the file existed and could be opened and read, 0 is returned, otherwise errno is returned. */ int @@ -799,17 +829,18 @@ rl_read_init_file (filename) { /* Default the filename. */ if (filename == 0) + filename = last_readline_init_file; + if (filename == 0) + filename = sh_get_env_value ("INPUTRC"); + if (filename == 0 || *filename == 0) { - filename = last_readline_init_file; - if (filename == 0) - filename = sh_get_env_value ("INPUTRC"); - if (filename == 0) - filename = DEFAULT_INPUTRC; + filename = DEFAULT_INPUTRC; + /* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */ + if (_rl_read_init_file (filename, 0) == 0) + return 0; + filename = SYS_INPUTRC; } - if (*filename == 0) - filename = DEFAULT_INPUTRC; - #if defined (__MSDOS__) if (_rl_read_init_file (filename, 0) == 0) return 0; @@ -1506,8 +1537,6 @@ rl_variable_value (name) const char *name; { register int i; - int v; - char *ret; /* Check for simple variables first. */ i = find_boolean_var (name); @@ -1948,12 +1977,16 @@ rl_invoking_keyseqs_in_map (function, map) char *keyname = (char *)xmalloc (6 + strlen (seqs[i])); if (key == ESC) -#if 0 - sprintf (keyname, "\\e"); -#else - /* XXX - experimental */ - sprintf (keyname, "\\M-"); -#endif + { + /* If ESC is the meta prefix and we're converting chars + with the eighth bit set to ESC-prefixed sequences, then + we can use \M-. Otherwise we need to use the sequence + for ESC. */ + if (_rl_convert_meta_chars_to_ascii && map[ESC].type == ISKMAP) + sprintf (keyname, "\\M-"); + else + sprintf (keyname, "\\e"); + } else if (CTRL_CHAR (key)) sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key))); else if (key == RUBOUT) @@ -2170,7 +2203,6 @@ _rl_get_string_variable_value (name) { static char numbuf[32]; char *ret; - int n; if (_rl_stricmp (name, "bell-style") == 0) { diff --git a/callback.c b/callback.c index 9120969..ada04d8 100644 --- a/callback.c +++ b/callback.c @@ -43,6 +43,7 @@ #include "rldefs.h" #include "readline.h" #include "rlprivate.h" +#include "xmalloc.h" /* Private data for callback registration functions. See comments in rl_callback_read_char for more details. */ @@ -124,73 +125,73 @@ rl_callback_read_char () return; } - if (RL_ISSTATE (RL_STATE_ISEARCH)) + do { - 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 (); - /* XXX - this should handle _rl_last_command_was_kill better */ - else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) - _rl_internal_char_cleanup (); + 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_MULTIKEY)) - { - eof = _rl_dispatch_callback (_rl_kscxt); /* For now */ - while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED)) - eof = _rl_dispatch_callback (_rl_kscxt); - if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0) + return; + } + else if (RL_ISSTATE (RL_STATE_NSEARCH)) { - _rl_internal_char_cleanup (); - _rl_want_redisplay = 1; + eof = _rl_nsearch_callback (_rl_nscxt); + 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) + 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 (); + /* XXX - this should handle _rl_last_command_was_kill better */ + else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) + _rl_internal_char_cleanup (); + + return; + } + else if (RL_ISSTATE (RL_STATE_MULTIKEY)) { - if (_rl_callback_data) + eof = _rl_dispatch_callback (_rl_kscxt); /* For now */ + while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED)) + eof = _rl_dispatch_callback (_rl_kscxt); + if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0) { - _rl_callback_data_dispose (_rl_callback_data); - _rl_callback_data = 0; + _rl_internal_char_cleanup (); + _rl_want_redisplay = 1; } - _rl_internal_char_cleanup (); } - } - else - eof = readline_internal_char (); + 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) + { + if (_rl_callback_data) + { + _rl_callback_data_dispose (_rl_callback_data); + _rl_callback_data = 0; + } + _rl_internal_char_cleanup (); + } + } + else + eof = readline_internal_char (); - if (rl_done == 0 && _rl_want_redisplay) - { - (*rl_redisplay_function) (); - _rl_want_redisplay = 0; - } + 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 (;;) - { if (rl_done) { line = readline_internal_teardown (eof); @@ -212,11 +213,8 @@ rl_callback_read_char () if (in_handler == 0 && rl_linefunc) _rl_callback_newline (); } - if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT)) - eof = readline_internal_char (); - else - break; } + while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT)); } /* Remove the handler, and make sure the terminal is in its normal state. */ diff --git a/complete.c b/complete.c index d93c15a..73f834a 100644 --- a/complete.c +++ b/complete.c @@ -950,7 +950,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) rl_compentry_func_t *our_func; int found_quote, quote_char; { - char **matches, *temp; + char **matches; rl_completion_found_quote = found_quote; rl_completion_quote_character = quote_char; @@ -969,21 +969,9 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char) } } - /* Beware -- we're stripping the quotes here. Do this only if we know - we are doing filename completion and the application has defined a - filename dequoting function. */ - temp = (char *)NULL; - - if (found_quote && our_func == rl_filename_completion_function && - rl_filename_dequoting_function) - { - /* delete single and double quotes */ - temp = (*rl_filename_dequoting_function) (text, quote_char); - text = temp; /* not freeing text is not a memory leak */ - } + /* XXX -- filename dequoting moved into rl_filename_completion_function */ matches = rl_completion_matches (text, our_func); - FREE (temp); return matches; } @@ -1116,7 +1104,8 @@ compute_lcd_of_matches (match_list, matches, text) #if defined (HANDLE_MULTIBYTE) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - mbstate_t ps_back = ps1; + mbstate_t ps_back; + ps_back = ps1; if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2)) break; else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1) @@ -1974,13 +1963,30 @@ rl_filename_completion_function (text, state) if (rl_directory_rewrite_hook) (*rl_directory_rewrite_hook) (&dirname); + /* The directory completion hook should perform any necessary + dequoting. */ if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&dirname)) { free (users_dirname); users_dirname = savestring (dirname); } - + else if (rl_completion_found_quote && rl_filename_dequoting_function) + { + /* delete single and double quotes */ + temp = (*rl_filename_dequoting_function) (users_dirname, rl_completion_quote_character); + free (users_dirname); + users_dirname = temp; + } directory = opendir (dirname); + + /* Now dequote a non-null filename. */ + if (filename && *filename && rl_completion_found_quote && rl_filename_dequoting_function) + { + /* delete single and double quotes */ + temp = (*rl_filename_dequoting_function) (filename, rl_completion_quote_character); + free (filename); + filename = temp; + } filename_len = strlen (filename); rl_filename_completion_desired = 1; diff --git a/config.h.in b/config.h.in index b4aae98..03178a4 100644 --- a/config.h.in +++ b/config.h.in @@ -41,6 +41,15 @@ /* Define if you have the isascii function. */ #undef HAVE_ISASCII +/* Define if you have the iswctype function. */ +#undef HAVE_ISWCTYPE + +/* Define if you have the iswlower function. */ +#undef HAVE_ISWLOWER + +/* Define if you have the iswupper function. */ +#undef HAVE_ISWUPPER + /* Define if you have the isxdigit function. */ #undef HAVE_ISXDIGIT @@ -88,11 +97,23 @@ /* Define if you have the tcgetattr function. */ #undef HAVE_TCGETATTR +/* Define if you have the towlower function. */ +#undef HAVE_TOWLOWER + +/* Define if you have the towupper function. */ +#undef HAVE_TOWUPPER + /* Define if you have the vsnprintf function. */ #undef HAVE_VSNPRINTF -/* Define if you have the wctomb function. */ -#undef HAVE_WCTOMB +/* Define if you have the wcrtomb function. */ +#undef HAVE_WCRTOMB + +/* Define if you have the wcscoll function. */ +#undef HAVE_WCSCOLL + +/* Define if you have the wctype function. */ +#undef HAVE_WCTYPE /* Define if you have the wcwidth function. */ #undef HAVE_WCWIDTH @@ -174,11 +195,20 @@ /* Define if you have the header file. */ #undef HAVE_WCHAR_H -/* Define if you have the header file. */ +/* Define if you have the header file. */ #undef HAVE_WCTYPE_H #undef HAVE_MBSTATE_T +/* Define if you have wchar_t in . */ +#undef HAVE_WCHAR_T + +/* Define if you have wctype_t in . */ +#undef HAVE_WCTYPE_T + +/* Define if you have wint_t in . */ +#undef HAVE_WINT_T + /* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET diff --git a/configure b/configure index 17a9eeb..5706839 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in for Readline 5.1, version 2.58. +# From configure.in for Readline 5.2, version 2.61. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for readline 5.1-beta1. +# Generated by GNU Autoconf 2.59 for readline 5.2. # # Report bugs to . # @@ -270,8 +270,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='readline' PACKAGE_TARNAME='readline' -PACKAGE_VERSION='5.1-beta1' -PACKAGE_STRING='readline 5.1-beta1' +PACKAGE_VERSION='5.2' +PACKAGE_STRING='readline 5.2' PACKAGE_BUGREPORT='bug-readline@gnu.org' ac_unique_file="readline.h" @@ -781,7 +781,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures readline 5.1-beta1 to adapt to many kinds of systems. +\`configure' configures readline 5.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -842,7 +842,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of readline 5.1-beta1:";; + short | recursive ) echo "Configuration of readline 5.2:";; esac cat <<\_ACEOF @@ -968,7 +968,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -readline configure 5.1-beta1 +readline configure 5.2 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -982,7 +982,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by readline $as_me 5.1-beta1, which was +It was created by readline $as_me 5.2, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1350,7 +1350,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. ac_config_headers="$ac_config_headers config.h" -LIBVERSION=5.1 +LIBVERSION=5.2 # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || @@ -1462,6 +1462,7 @@ fi +CROSS_COMPILE= if test "x$cross_compiling" = "xyes"; then case "${host}" in *-cygwin*) @@ -7403,9 +7404,9 @@ _ACEOF fi -echo "$as_me:$LINENO: checking for mbrtowc" >&5 -echo $ECHO_N "checking for mbrtowc... $ECHO_C" >&6 -if test "${ac_cv_func_mbrtowc+set}" = set; then +echo "$as_me:$LINENO: checking for mbrlen" >&5 +echo $ECHO_N "checking for mbrlen... $ECHO_C" >&6 +if test "${ac_cv_func_mbrlen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7414,12 +7415,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define mbrtowc to an innocuous variant, in case declares mbrtowc. +/* Define mbrlen to an innocuous variant, in case declares mbrlen. For example, HP-UX 11i declares gettimeofday. */ -#define mbrtowc innocuous_mbrtowc +#define mbrlen innocuous_mbrlen /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char mbrtowc (); below. + which can conflict with char mbrlen (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -7429,7 +7430,7 @@ cat >>conftest.$ac_ext <<_ACEOF # include #endif -#undef mbrtowc +#undef mbrlen /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus @@ -7438,14 +7439,14 @@ extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char mbrtowc (); +char mbrlen (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_mbrtowc) || defined (__stub___mbrtowc) +#if defined (__stub_mbrlen) || defined (__stub___mbrlen) choke me #else -char (*f) () = mbrtowc; +char (*f) () = mbrlen; #endif #ifdef __cplusplus } @@ -7454,7 +7455,7 @@ char (*f) () = mbrtowc; int main () { -return f != mbrtowc; +return f != mbrlen; ; return 0; } @@ -7481,28 +7482,29 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_mbrtowc=yes + ac_cv_func_mbrlen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_mbrtowc=no +ac_cv_func_mbrlen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_mbrtowc" >&5 -echo "${ECHO_T}$ac_cv_func_mbrtowc" >&6 -if test $ac_cv_func_mbrtowc = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_mbrlen" >&5 +echo "${ECHO_T}$ac_cv_func_mbrlen" >&6 +if test $ac_cv_func_mbrlen = yes; then cat >>confdefs.h <<\_ACEOF -#define HAVE_MBRTOWC 1 +#define HAVE_MBRLEN 1 _ACEOF fi -echo "$as_me:$LINENO: checking for mbrlen" >&5 -echo $ECHO_N "checking for mbrlen... $ECHO_C" >&6 -if test "${ac_cv_func_mbrlen+set}" = set; then + +echo "$as_me:$LINENO: checking for wcrtomb" >&5 +echo $ECHO_N "checking for wcrtomb... $ECHO_C" >&6 +if test "${ac_cv_func_wcrtomb+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7511,12 +7513,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define mbrlen to an innocuous variant, in case declares mbrlen. +/* Define wcrtomb to an innocuous variant, in case declares wcrtomb. For example, HP-UX 11i declares gettimeofday. */ -#define mbrlen innocuous_mbrlen +#define wcrtomb innocuous_wcrtomb /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char mbrlen (); below. + which can conflict with char wcrtomb (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -7526,7 +7528,7 @@ cat >>conftest.$ac_ext <<_ACEOF # include #endif -#undef mbrlen +#undef wcrtomb /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus @@ -7535,14 +7537,14 @@ extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char mbrlen (); +char wcrtomb (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_mbrlen) || defined (__stub___mbrlen) +#if defined (__stub_wcrtomb) || defined (__stub___wcrtomb) choke me #else -char (*f) () = mbrlen; +char (*f) () = wcrtomb; #endif #ifdef __cplusplus } @@ -7551,7 +7553,7 @@ char (*f) () = mbrlen; int main () { -return f != mbrlen; +return f != wcrtomb; ; return 0; } @@ -7578,28 +7580,125 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_mbrlen=yes + ac_cv_func_wcrtomb=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_mbrlen=no +ac_cv_func_wcrtomb=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_mbrlen" >&5 -echo "${ECHO_T}$ac_cv_func_mbrlen" >&6 -if test $ac_cv_func_mbrlen = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_wcrtomb" >&5 +echo "${ECHO_T}$ac_cv_func_wcrtomb" >&6 +if test $ac_cv_func_wcrtomb = yes; then cat >>confdefs.h <<\_ACEOF -#define HAVE_MBRLEN 1 +#define HAVE_WCRTOMB 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for wcscoll" >&5 +echo $ECHO_N "checking for wcscoll... $ECHO_C" >&6 +if test "${ac_cv_func_wcscoll+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define wcscoll to an innocuous variant, in case declares wcscoll. + For example, HP-UX 11i declares gettimeofday. */ +#define wcscoll innocuous_wcscoll + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char wcscoll (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef wcscoll + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char wcscoll (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_wcscoll) || defined (__stub___wcscoll) +choke me +#else +char (*f) () = wcscoll; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != wcscoll; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_wcscoll=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_wcscoll=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_wcscoll" >&5 +echo "${ECHO_T}$ac_cv_func_wcscoll" >&6 +if test $ac_cv_func_wcscoll = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_WCSCOLL 1 _ACEOF fi -echo "$as_me:$LINENO: checking for wctomb" >&5 -echo $ECHO_N "checking for wctomb... $ECHO_C" >&6 -if test "${ac_cv_func_wctomb+set}" = set; then +echo "$as_me:$LINENO: checking for wcsdup" >&5 +echo $ECHO_N "checking for wcsdup... $ECHO_C" >&6 +if test "${ac_cv_func_wcsdup+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7608,12 +7707,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define wctomb to an innocuous variant, in case declares wctomb. +/* Define wcsdup to an innocuous variant, in case declares wcsdup. For example, HP-UX 11i declares gettimeofday. */ -#define wctomb innocuous_wctomb +#define wcsdup innocuous_wcsdup /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char wctomb (); below. + which can conflict with char wcsdup (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -7623,7 +7722,7 @@ cat >>conftest.$ac_ext <<_ACEOF # include #endif -#undef wctomb +#undef wcsdup /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus @@ -7632,14 +7731,14 @@ extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char wctomb (); +char wcsdup (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_wctomb) || defined (__stub___wctomb) +#if defined (__stub_wcsdup) || defined (__stub___wcsdup) choke me #else -char (*f) () = wctomb; +char (*f) () = wcsdup; #endif #ifdef __cplusplus } @@ -7648,7 +7747,7 @@ char (*f) () = wctomb; int main () { -return f != wctomb; +return f != wcsdup; ; return 0; } @@ -7675,21 +7774,21 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_wctomb=yes + ac_cv_func_wcsdup=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_wctomb=no +ac_cv_func_wcsdup=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_wctomb" >&5 -echo "${ECHO_T}$ac_cv_func_wctomb" >&6 -if test $ac_cv_func_wctomb = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_wcsdup" >&5 +echo "${ECHO_T}$ac_cv_func_wcsdup" >&6 +if test $ac_cv_func_wcsdup = yes; then cat >>confdefs.h <<\_ACEOF -#define HAVE_WCTOMB 1 +#define HAVE_WCSDUP 1 _ACEOF fi @@ -7791,9 +7890,9 @@ _ACEOF fi -echo "$as_me:$LINENO: checking for wcsdup" >&5 -echo $ECHO_N "checking for wcsdup... $ECHO_C" >&6 -if test "${ac_cv_func_wcsdup+set}" = set; then +echo "$as_me:$LINENO: checking for wctype" >&5 +echo $ECHO_N "checking for wctype... $ECHO_C" >&6 +if test "${ac_cv_func_wctype+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7802,12 +7901,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define wcsdup to an innocuous variant, in case declares wcsdup. +/* Define wctype to an innocuous variant, in case declares wctype. For example, HP-UX 11i declares gettimeofday. */ -#define wcsdup innocuous_wcsdup +#define wctype innocuous_wctype /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char wcsdup (); below. + which can conflict with char wctype (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -7817,7 +7916,7 @@ cat >>conftest.$ac_ext <<_ACEOF # include #endif -#undef wcsdup +#undef wctype /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus @@ -7826,14 +7925,14 @@ extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ -char wcsdup (); +char wctype (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_wcsdup) || defined (__stub___wcsdup) +#if defined (__stub_wctype) || defined (__stub___wctype) choke me #else -char (*f) () = wcsdup; +char (*f) () = wctype; #endif #ifdef __cplusplus } @@ -7842,7 +7941,7 @@ char (*f) () = wcsdup; int main () { -return f != wcsdup; +return f != wctype; ; return 0; } @@ -7869,29 +7968,30 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_func_wcsdup=yes + ac_cv_func_wctype=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_func_wcsdup=no +ac_cv_func_wctype=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_func_wcsdup" >&5 -echo "${ECHO_T}$ac_cv_func_wcsdup" >&6 -if test $ac_cv_func_wcsdup = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_wctype" >&5 +echo "${ECHO_T}$ac_cv_func_wctype" >&6 +if test $ac_cv_func_wctype = yes; then cat >>confdefs.h <<\_ACEOF -#define HAVE_WCSDUP 1 +#define HAVE_WCTYPE 1 _ACEOF fi -echo "$as_me:$LINENO: checking for mbstate_t" >&5 -echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6 -if test "${bash_cv_have_mbstate_t+set}" = set; then + + echo "$as_me:$LINENO: checking whether mbrtowc and mbstate_t are properly declared" >&5 +echo $ECHO_N "checking whether mbrtowc and mbstate_t are properly declared... $ECHO_C" >&6 +if test "${ac_cv_func_mbrtowc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -7900,23 +8000,18 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - #include int main () { - - mbstate_t ps; - mbstate_t *psp; - psp = (mbstate_t *)0; - +mbstate_t state; return ! (sizeof state && mbrtowc); ; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 @@ -7930,30 +8025,146 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - bash_cv_have_mbstate_t=yes + ac_cv_func_mbrtowc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -bash_cv_have_mbstate_t=no +ac_cv_func_mbrtowc=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $bash_cv_have_mbstate_t" >&5 -echo "${ECHO_T}$bash_cv_have_mbstate_t" >&6 -if test $bash_cv_have_mbstate_t = yes; then +echo "$as_me:$LINENO: result: $ac_cv_func_mbrtowc" >&5 +echo "${ECHO_T}$ac_cv_func_mbrtowc" >&6 + if test $ac_cv_func_mbrtowc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MBRTOWC 1 +_ACEOF + + fi + +if test $ac_cv_func_mbrtowc = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MBSTATE_T 1 _ACEOF fi + + + + + +for ac_func in iswlower iswupper towlower towupper iswctype +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + echo "$as_me:$LINENO: checking for nl_langinfo and CODESET" >&5 echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6 if test "${bash_cv_langinfo_codeset+set}" = set; then @@ -8015,6 +8226,199 @@ _ACEOF fi +echo "$as_me:$LINENO: checking for wchar_t in wchar.h" >&5 +echo $ECHO_N "checking for wchar_t in wchar.h... $ECHO_C" >&6 +if test "${bash_cv_type_wchar_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ + + wchar_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_type_wchar_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +bash_cv_type_wchar_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $bash_cv_type_wchar_t" >&5 +echo "${ECHO_T}$bash_cv_type_wchar_t" >&6 +if test $bash_cv_type_wchar_t = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WCHAR_T 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for wctype_t in wctype.h" >&5 +echo $ECHO_N "checking for wctype_t in wctype.h... $ECHO_C" >&6 +if test "${bash_cv_type_wctype_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + + wctype_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_type_wctype_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +bash_cv_type_wctype_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $bash_cv_type_wctype_t" >&5 +echo "${ECHO_T}$bash_cv_type_wctype_t" >&6 +if test $bash_cv_type_wctype_t = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WCTYPE_T 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for wint_t in wctype.h" >&5 +echo $ECHO_N "checking for wint_t in wctype.h... $ECHO_C" >&6 +if test "${bash_cv_type_wint_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ + + wint_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + bash_cv_type_wint_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +bash_cv_type_wint_t=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $bash_cv_type_wint_t" >&5 +echo "${ECHO_T}$bash_cv_type_wint_t" >&6 +if test $bash_cv_type_wint_t = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WINT_T 1 +_ACEOF + +fi + case "$host_cpu" in @@ -8479,7 +8883,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by readline $as_me 5.1-beta1, which was +This file was extended by readline $as_me 5.2, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8542,7 +8946,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -readline config.status 5.1-beta1 +readline config.status 5.2 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.in b/configure.in index a786398..868773b 100644 --- a/configure.in +++ b/configure.in @@ -22,9 +22,9 @@ dnl Process this file with autoconf to produce a configure script. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. -AC_REVISION([for Readline 5.1, version 2.59]) +AC_REVISION([for Readline 5.2, version 2.61]) -AC_INIT(readline, 5.1-release, bug-readline@gnu.org) +AC_INIT(readline, 5.2, bug-readline@gnu.org) dnl make sure we are using a recent autoconf version AC_PREREQ(2.50) @@ -34,7 +34,7 @@ AC_CONFIG_AUX_DIR(./support) AC_CONFIG_HEADERS(config.h) dnl update the value of RL_READLINE_VERSION in readline.h when this changes -LIBVERSION=5.1 +LIBVERSION=5.2 AC_CANONICAL_HOST @@ -75,6 +75,7 @@ dnl files as necessary dnl Note that host and target machine are the same, and different than the dnl build machine. +CROSS_COMPILE= if test "x$cross_compiling" = "xyes"; then case "${host}" in *-cygwin*) diff --git a/display.c b/display.c index 0d3ae6e..47ff061 100644 --- a/display.c +++ b/display.c @@ -1,6 +1,6 @@ /* display.c -- readline redisplay facility. */ -/* Copyright (C) 1987-2005 Free Software Foundation, Inc. +/* Copyright (C) 1987-2006 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. @@ -59,10 +59,6 @@ extern char *strchr (), *strrchr (); #endif /* !strchr && !__STDC__ */ -#if defined (HACK_TERMCAP_MOTION) -extern char *_rl_term_forward_char; -#endif - static void update_line PARAMS((char *, char *, int, int, int, int)); static void space_to_eol PARAMS((int)); static void delete_chars PARAMS((int)); @@ -80,9 +76,18 @@ static int *inv_lbreaks, *vis_lbreaks; static int inv_lbsize, vis_lbsize; /* Heuristic used to decide whether it is faster to move from CUR to NEW - by backing up or outputting a carriage return and moving forward. */ + by backing up or outputting a carriage return and moving forward. CUR + and NEW are either both buffer positions or absolute screen positions. */ #define CR_FASTER(new, cur) (((new) + 1) < ((cur) - (new))) +/* _rl_last_c_pos is an absolute cursor position in multibyte locales and a + buffer index in others. This macro is used when deciding whether the + current cursor position is in the middle of a prompt string containing + invisible characters. */ +#define PROMPT_ENDING_INDEX \ + ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) ? prompt_physical_chars : prompt_last_invisible+1) + + /* **************************************************************** */ /* */ /* Display stuff */ @@ -135,6 +140,7 @@ int _rl_last_c_pos = 0; int _rl_last_v_pos = 0; static int cpos_adjusted; +static int cpos_buffer_position; /* Number of lines currently on screen minus 1. */ int _rl_vis_botlin = 0; @@ -162,6 +168,7 @@ static int line_size = 1024; include invisible characters. */ static char *local_prompt, *local_prompt_prefix; +static int local_prompt_len; static int prompt_visible_length, prompt_prefix_length; /* The number of invisible characters in the line currently being @@ -197,6 +204,7 @@ static char *saved_local_prefix; static int saved_last_invisible; static int saved_visible_length; static int saved_prefix_length; +static int saved_local_length; static int saved_invis_chars_first_line; static int saved_physical_chars; @@ -220,7 +228,7 @@ expand_prompt (pmt, lp, lip, niflp, vlp) char *pmt; int *lp, *lip, *niflp, *vlp; { - char *r, *ret, *p; + char *r, *ret, *p, *igstart; int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; /* Short-circuit if we can. */ @@ -244,19 +252,21 @@ expand_prompt (pmt, lp, lip, niflp, vlp) invfl = 0; /* invisible chars in first line of prompt */ invflset = 0; /* we only want to set invfl once */ + igstart = 0; for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++) { /* This code strips the invisible character string markers RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */ - if (*p == RL_PROMPT_START_IGNORE) + if (ignoring == 0 && *p == RL_PROMPT_START_IGNORE) /* XXX - check ignoring? */ { - ignoring++; + ignoring = 1; + igstart = p; continue; } else if (ignoring && *p == RL_PROMPT_END_IGNORE) { ignoring = 0; - if (p[-1] != RL_PROMPT_START_IGNORE) + if (p != (igstart + 1)) last = r - ret - 1; continue; } @@ -356,6 +366,7 @@ rl_expand_prompt (prompt) FREE (local_prompt_prefix); local_prompt = local_prompt_prefix = (char *)0; + local_prompt_len = 0; prompt_last_invisible = prompt_invis_chars_first_line = 0; prompt_visible_length = prompt_physical_chars = 0; @@ -371,6 +382,7 @@ rl_expand_prompt (prompt) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)0; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; return (prompt_visible_length); } else @@ -389,6 +401,7 @@ rl_expand_prompt (prompt) &prompt_invis_chars_first_line, (int *)NULL); *t = c; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; return (prompt_prefix_length); } } @@ -445,7 +458,7 @@ rl_redisplay () { register int in, out, c, linenum, cursor_linenum; register char *line; - int c_pos, inv_botlin, lb_botlin, lb_linenum, o_cpos; + int inv_botlin, lb_botlin, lb_linenum, o_cpos; int newlines, lpos, temp, modmark, n0, num; char *prompt_this_line; #if defined (HANDLE_MULTIBYTE) @@ -469,7 +482,7 @@ rl_redisplay () } /* Draw the line into the buffer. */ - c_pos = -1; + cpos_buffer_position = -1; line = invisible_line; out = inv_botlin = 0; @@ -496,24 +509,23 @@ rl_redisplay () number of non-visible characters in the prompt string. */ if (rl_display_prompt == rl_prompt || local_prompt) { - int local_len = local_prompt ? strlen (local_prompt) : 0; if (local_prompt_prefix && forced_display) _rl_output_some_chars (local_prompt_prefix, strlen (local_prompt_prefix)); - if (local_len > 0) + if (local_prompt_len > 0) { - temp = local_len + out + 2; + temp = local_prompt_len + out + 2; if (temp >= line_size) { line_size = (temp + 1024) - (temp % 1024); visible_line = (char *)xrealloc (visible_line, line_size); line = invisible_line = (char *)xrealloc (invisible_line, line_size); } - strncpy (line + out, local_prompt, local_len); - out += local_len; + strncpy (line + out, local_prompt, local_prompt_len); + out += local_prompt_len; } line[out] = '\0'; - wrap_offset = local_len - prompt_visible_length; + wrap_offset = local_prompt_len - prompt_visible_length; } else { @@ -614,6 +626,7 @@ rl_redisplay () contents of the command line? */ while (lpos >= _rl_screenwidth) { + int z; /* fix from Darin Johnson for prompt string with invisible characters that is longer than the screen width. The prompt_invis_chars_first_line variable could be made into an array @@ -622,37 +635,46 @@ rl_redisplay () prompts that exceed two physical lines? Additional logic fix from Edward Catmur */ #if defined (HANDLE_MULTIBYTE) - n0 = num; - temp = local_prompt ? strlen (local_prompt) : 0; - while (num < temp) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth) + n0 = num; + temp = local_prompt_len; + while (num < temp) { - num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); - break; + z = _rl_col_width (local_prompt, n0, num); + if (z > _rl_screenwidth) + { + num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); + break; + } + else if (z == _rl_screenwidth) + break; + num++; } - num++; + temp = num; } - temp = num + -#else - temp = ((newlines + 1) * _rl_screenwidth) + + else #endif /* !HANDLE_MULTIBYTE */ - ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line - : ((newlines == 1) ? wrap_offset : 0)) - : ((newlines == 0) ? wrap_offset :0)); + temp = ((newlines + 1) * _rl_screenwidth); + + /* Now account for invisible characters in the current line. */ + temp += ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line + : ((newlines == 1) ? wrap_offset : 0)) + : ((newlines == 0) ? wrap_offset :0)); inv_lbreaks[++newlines] = temp; #if defined (HANDLE_MULTIBYTE) - lpos -= _rl_col_width (local_prompt, n0, num); -#else - lpos -= _rl_screenwidth; + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) + lpos -= _rl_col_width (local_prompt, n0, num); + else #endif + lpos -= _rl_screenwidth; } prompt_last_screen_line = newlines; /* Draw the rest of the line (after the prompt) into invisible_line, keeping - track of where the cursor is (c_pos), the number of the line containing + track of where the cursor is (cpos_buffer_position), the number of the line containing the cursor (lb_linenum), the last line number (lb_botlin and inv_botlin). It maintains an array of line breaks for display (inv_lbreaks). This handles expanding tabs for display and displaying meta characters. */ @@ -705,7 +727,7 @@ rl_redisplay () if (in == rl_point) { - c_pos = out; + cpos_buffer_position = out; lb_linenum = newlines; } @@ -799,7 +821,7 @@ rl_redisplay () } if (in == rl_point) { - c_pos = out; + cpos_buffer_position = out; lb_linenum = newlines; } for (i = in; i < in+wc_bytes; i++) @@ -830,9 +852,9 @@ rl_redisplay () } line[out] = '\0'; - if (c_pos < 0) + if (cpos_buffer_position < 0) { - c_pos = out; + cpos_buffer_position = out; lb_linenum = newlines; } @@ -841,7 +863,7 @@ rl_redisplay () inv_lbreaks[newlines+1] = out; cursor_linenum = lb_linenum; - /* C_POS == position in buffer where cursor should be placed. + /* CPOS_BUFFER_POSITION == position in buffer where cursor should be placed. CURSOR_LINENUM == line number where the cursor should be placed. */ /* PWP: now is when things get a bit hairy. The visible and invisible @@ -886,6 +908,8 @@ rl_redisplay () /* For each line in the buffer, do the updating display. */ for (linenum = 0; linenum <= inv_botlin; linenum++) { + /* This can lead us astray if we execute a program that changes + the locale from a non-multibyte to a multibyte one. */ o_cpos = _rl_last_c_pos; cpos_adjusted = 0; update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum, @@ -898,7 +922,11 @@ rl_redisplay () change update_line itself. There is one case in which update_line adjusts _rl_last_c_pos itself (so it can pass _rl_move_cursor_relative accurate values); it communicates - this back by setting cpos_adjusted */ + this back by setting cpos_adjusted. If we assume that + _rl_last_c_pos is correct (an absolute cursor position) each + time update_line is called, then we can assume in our + calculations that o_cpos does not need to be adjusted by + wrap_offset. */ if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && cpos_adjusted == 0 && _rl_last_c_pos != o_cpos && @@ -967,7 +995,11 @@ rl_redisplay () invisible character in the prompt string. */ nleft = prompt_visible_length + wrap_offset; if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 && - _rl_last_c_pos <= prompt_last_invisible && local_prompt) +#if 0 + _rl_last_c_pos <= PROMPT_ENDING_INDEX && local_prompt) +#else + _rl_last_c_pos < PROMPT_ENDING_INDEX && local_prompt) +#endif { #if defined (__MSDOS__) putc ('\r', rl_outstream); @@ -986,8 +1018,8 @@ rl_redisplay () in the buffer? */ pos = inv_lbreaks[cursor_linenum]; /* nleft == number of characters in the line buffer between the - start of the line and the cursor position. */ - nleft = c_pos - pos; + start of the line and the desired cursor position. */ + nleft = cpos_buffer_position - pos; /* NLEFT is now a number of characters in a buffer. When in a multibyte locale, however, _rl_last_c_pos is an absolute cursor @@ -999,6 +1031,7 @@ rl_redisplay () those characters here and call _rl_backspace() directly. */ if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos) { + /* TX == new physical cursor position in multibyte locale. */ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset; else @@ -1032,11 +1065,11 @@ rl_redisplay () will be LMARGIN. */ /* The number of characters that will be displayed before the cursor. */ - ndisp = c_pos - wrap_offset; + ndisp = cpos_buffer_position - wrap_offset; nleft = prompt_visible_length + wrap_offset; /* Where the new cursor position will be on the screen. This can be longer than SCREENWIDTH; if it is, lmargin will be adjusted. */ - phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset); + phys_c_pos = cpos_buffer_position - (last_lmargin ? last_lmargin : wrap_offset); t = _rl_screenwidth / 3; /* If the number of characters had already exceeded the screenwidth, @@ -1047,7 +1080,7 @@ rl_redisplay () two-thirds of the way across the screen. */ if (phys_c_pos > _rl_screenwidth - 2) { - lmargin = c_pos - (2 * t); + lmargin = cpos_buffer_position - (2 * t); if (lmargin < 0) lmargin = 0; /* If the left margin would be in the middle of a prompt with @@ -1061,7 +1094,7 @@ rl_redisplay () { /* If we are moving back towards the beginning of the line and the last margin is no longer correct, compute a new one. */ - lmargin = ((c_pos - 1) / t) * t; /* XXX */ + lmargin = ((cpos_buffer_position - 1) / t) * t; /* XXX */ if (wrap_offset && lmargin > 0 && lmargin < nleft) lmargin = nleft; } @@ -1106,7 +1139,7 @@ rl_redisplay () if (visible_first_line_len > _rl_screenwidth) visible_first_line_len = _rl_screenwidth; - _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]); + _rl_move_cursor_relative (cpos_buffer_position - lmargin, &invisible_line[lmargin]); last_lmargin = lmargin; } } @@ -1164,7 +1197,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) int col_lendiff, col_temp; #if defined (HANDLE_MULTIBYTE) mbstate_t ps_new, ps_old; - int new_offset, old_offset, tmp; + int new_offset, old_offset; #endif /* If we're at the right edge of a terminal that supports xn, we're @@ -1397,11 +1430,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) sequences (like drawing the `unbold' sequence without a corresponding `bold') that manifests itself on certain terminals. */ - lendiff = local_prompt ? strlen (local_prompt) : 0; + lendiff = local_prompt_len; od = ofd - old; /* index of first difference in visible line */ if (current_line == 0 && !_rl_horizontal_scroll_mode && _rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 && - od >= lendiff && _rl_last_c_pos <= prompt_last_invisible) + od >= lendiff && _rl_last_c_pos < PROMPT_ENDING_INDEX) { #if defined (__MSDOS__) putc ('\r', rl_outstream); @@ -1420,7 +1453,19 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) _rl_last_c_pos = lendiff; } + /* When this function returns, _rl_last_c_pos is correct, and an absolute + cursor postion in multibyte mode, but a buffer index when not in a + multibyte locale. */ _rl_move_cursor_relative (od, old); +#if 1 +#if defined (HANDLE_MULTIBYTE) + /* We need to indicate that the cursor position is correct in the presence of + invisible characters in the prompt string. Let's see if setting this when + we make sure we're at the end of the drawn prompt string works. */ + if (current_line == 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_last_c_pos == prompt_physical_chars) + cpos_adjusted = 1; +#endif +#endif /* if (len (new) > len (old)) lendiff == difference in buffer @@ -1648,10 +1693,11 @@ rl_on_new_line_with_prompt () int rl_forced_update_display () { + register char *temp; + if (visible_line) { - register char *temp = visible_line; - + temp = visible_line; while (*temp) *temp++ = '\0'; } @@ -1686,8 +1732,14 @@ _rl_move_cursor_relative (new, data) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { dpos = _rl_col_width (data, 0, new); - if (dpos > woff) - dpos -= woff; + if (dpos > prompt_last_invisible) /* XXX - don't use woff here */ + { + dpos -= woff; + /* Since this will be assigned to _rl_last_c_pos at the end (more + precisely, _rl_last_c_pos == dpos when this function returns), + let the caller know. */ + cpos_adjusted = 1; + } } else #endif @@ -1706,7 +1758,7 @@ _rl_move_cursor_relative (new, data) else #endif i = _rl_last_c_pos - woff; - if (new == 0 || CR_FASTER (new, _rl_last_c_pos) || + if (dpos == 0 || CR_FASTER (dpos, _rl_last_c_pos) || (_rl_term_autowrap && i == _rl_screenwidth)) { #if defined (__MSDOS__) @@ -1728,19 +1780,27 @@ _rl_move_cursor_relative (new, data) sequence telling the terminal to move forward one character. That kind of control is for people who don't know what the data is underneath the cursor. */ -#if defined (HACK_TERMCAP_MOTION) - if (_rl_term_forward_char) - { - for (i = cpos; i < dpos; i++) - tputs (_rl_term_forward_char, 1, _rl_output_character_function); - } - else -#endif /* HACK_TERMCAP_MOTION */ + + /* However, we need a handle on where the current display position is + in the buffer for the immediately preceding comment to be true. + In multibyte locales, we don't currently have that info available. + Without it, we don't know where the data we have to display begins + in the buffer and we have to go back to the beginning of the screen + line. In this case, we can use the terminal sequence to move forward + if it's available. */ if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) { - tputs (_rl_term_cr, 1, _rl_output_character_function); - for (i = 0; i < new; i++) - putc (data[i], rl_outstream); + if (_rl_term_forward_char) + { + for (i = cpos; i < dpos; i++) + tputs (_rl_term_forward_char, 1, _rl_output_character_function); + } + else + { + tputs (_rl_term_cr, 1, _rl_output_character_function); + for (i = 0; i < new; i++) + putc (data[i], rl_outstream); + } } else for (i = cpos; i < new; i++) @@ -1889,6 +1949,7 @@ rl_message (va_alist) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; (*rl_redisplay_function) (); return 0; @@ -1912,6 +1973,7 @@ rl_message (format, arg1, arg2) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; (*rl_redisplay_function) (); return 0; @@ -1948,12 +2010,14 @@ rl_save_prompt () saved_local_prompt = local_prompt; saved_local_prefix = local_prompt_prefix; saved_prefix_length = prompt_prefix_length; + saved_local_length = local_prompt_len; saved_last_invisible = prompt_last_invisible; saved_visible_length = prompt_visible_length; saved_invis_chars_first_line = prompt_invis_chars_first_line; saved_physical_chars = prompt_physical_chars; local_prompt = local_prompt_prefix = (char *)0; + local_prompt_len = 0; prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0; prompt_invis_chars_first_line = prompt_physical_chars = 0; } @@ -1966,6 +2030,7 @@ rl_restore_prompt () local_prompt = saved_local_prompt; local_prompt_prefix = saved_local_prefix; + local_prompt_len = saved_local_length; prompt_prefix_length = saved_prefix_length; prompt_last_invisible = saved_last_invisible; prompt_visible_length = saved_visible_length; @@ -1974,6 +2039,7 @@ rl_restore_prompt () /* can test saved_local_prompt to see if prompt info has been saved. */ saved_local_prompt = saved_local_prefix = (char *)0; + saved_local_length = 0; saved_last_invisible = saved_visible_length = saved_prefix_length = 0; saved_invis_chars_first_line = saved_physical_chars = 0; } @@ -2162,7 +2228,8 @@ _rl_update_final () char *last_line; last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]]; - _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); + cpos_buffer_position = -1; /* don't know where we are in buffer */ + _rl_move_cursor_relative (_rl_screenwidth - 1, last_line); /* XXX */ _rl_clear_to_eol (0); putc (last_line[_rl_screenwidth - 1], rl_outstream); } @@ -2205,6 +2272,7 @@ redraw_prompt (t) &prompt_invis_chars_first_line, &prompt_physical_chars); local_prompt_prefix = (char *)NULL; + local_prompt_len = local_prompt ? strlen (local_prompt) : 0; rl_forced_update_display (); @@ -2307,12 +2375,14 @@ _rl_col_width (str, start, end) int start, end; { wchar_t wc; - mbstate_t ps = {0}; + mbstate_t ps; int tmp, point, width, max; if (end <= start) return 0; + memset (&ps, 0, sizeof (mbstate_t)); + point = 0; max = end; diff --git a/doc/history.dvi b/doc/history.dvi index 6377d9d..19b3e5c 100644 Binary files a/doc/history.dvi and b/doc/history.dvi differ diff --git a/doc/history.html b/doc/history.html index 439426a..015a3e2 100644 --- a/doc/history.html +++ b/doc/history.html @@ -1,6 +1,6 @@ - + + +