diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-12-29 13:08:27 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-12-29 13:08:27 -0500 |
commit | 22818c1449823d8de5430f734da38d1eae943417 (patch) | |
tree | fc9740afe696794b9ccf2112294ed7a65771108a | |
parent | f4f5e1c2b8fa4539e367e1f48774183d349184c5 (diff) | |
download | bash-22818c1449823d8de5430f734da38d1eae943417.tar.gz |
commit bash-20110520 snapshot
-rw-r--r-- | CWRU/CWRU.chlog | 73 | ||||
-rw-r--r-- | aclocal.m4 | 28 | ||||
-rw-r--r-- | autom4te.cache/output.0 | 52 | ||||
-rw-r--r-- | autom4te.cache/requests | 36 | ||||
-rw-r--r-- | autom4te.cache/traces.0 | 116 | ||||
-rw-r--r-- | config.h.in | 3 | ||||
-rwxr-xr-x | configure | 52 | ||||
-rw-r--r-- | expr.c | 6 | ||||
-rw-r--r-- | lib/readline/complete.c | 4 | ||||
-rw-r--r-- | lib/readline/display.c | 39 | ||||
-rw-r--r-- | lib/readline/isearch.c | 27 | ||||
-rw-r--r-- | lib/readline/mbutil.c | 6 | ||||
-rw-r--r-- | lib/readline/nls.c | 37 | ||||
-rw-r--r-- | lib/readline/rlmbutil.h | 9 | ||||
-rw-r--r-- | lib/readline/rlprivate.h | 6 | ||||
-rw-r--r-- | locale.c | 24 |
16 files changed, 421 insertions, 97 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index f436c353..209f5522 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -11661,3 +11661,76 @@ lib/readline/display.c for UTF-8 combining characters. Added workaround dependent on MACOSX. Fixes problem pointed out by Thomas De Contes <d.l.tDecontes@free.fr> + + 5/16 + ---- +lib/readline/rlmbutil.h + - WCWIDTH: wrapper for wcwidth that returns 0 for Unicode combining + characters on systems where wcwidth is broken (e.g., Mac OS X). + +lib/readline/{complete,display,mbutil}.c + - use WCWIDTH instead of wcwidth + + 5/17 + ---- +lib/readline/display.c + - update_line: after computing ofd and nfd, see whether the next + character in ofd is a zero-width combining character. If it is, + back ofd and nfd up one, so the base characters no longer compare + as equivalent. Fixes problem reported by Keith Winstein + <keithw@mit.edu> + +lib/readline/nls.c + - _rl_utf8locale: new flag variable, set to non-zero if the current + locale is UTF-8 + - utf8locale(): new function, returns 1 if the passed lspec (or the + current locale) indicates that the locale is UTF-8. Called from + _rl_init_eightbit + +lib/readline/rlprivate.h + - extern declaration for _rl_utf8locale + +locale.c + - locale_utf8locale: new flag variable, set to non-zero if the current + locale is UTF-8 (currently unused) + - locale_isutf8(): new function, returns 1 if the passed lspec (or the + current locale) indicates that the locale is UTF-8. Should be called + whenever the locale or LC_CTYPE value is modified + +aclocal.m4 + - BASH_WCWIDTH_BROKEN: new test for whether or not wcwidth returns + zero-width characters like unicode combining characters as having + display length 1; define WCWIDTH_BROKEN in this case + +config.h.in + - WCWIDTH_BROKEN: new define + +lib/readline/rlmbutil.h + - change WCWIDTH macro to use _rl_utf8locale and the full range of + Unicode combining characters (U+0300-U+036F) + + 5/19 + ---- +lib/readline/rlprivate.h + - _rl_search_context: new member, prevc, will hold character read + prior to lastc + +lib/readline/isearch.c + - _rl_isearch_dispatch: if the character causes us to index into + another keymap, save that character in cxt->prevc + - _rl_isearch_dispatch: if we index into another keymap, but don't + find a function that's special to i-search, and the character that + caused us to index into that keymap would have terminated the + search, push back cxt->prevc and cxt->lastc to make it appear as + if `prevc' terminated the search, and execute lastc as a command. + We have to push prevc back so we index into the same keymap before + we read lastc. Fixes bug report from Davor Cubranic + <cubranic@stat.ubc.ca> + + 5/20 + ---- +expr.c + - expr_bind_variable: pay attention to the return value from + bind_variable and check whether or not we should error out due to + a readonly or noassign variable. Fixes bug reported by Eric + Blake <eblake@redhat.com> @@ -1698,7 +1698,6 @@ AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP)) AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS)) AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS)) - AC_REPLACE_FUNCS(mbschr) AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB)) @@ -1763,6 +1762,33 @@ if test $bash_cv_type_wint_t = yes; then AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here]) fi +dnl check for broken wcwidth +AC_CACHE_CHECK([for wcwidth broken with unicode combining characters], +bash_cv_wcwidth_broken, +[AC_TRY_RUN([ +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> + +#include <locale.h> +#include <wchar.h> + +main(c, v) +int c; +char **v; +{ + int w; + + setlocale(LC_ALL, "en_US.UTF-8"); + w = wcwidth (0x0301); + exit (w == 0); /* exit 0 if wcwidth broken */ +} +], +bash_cv_wcwidth_broken=yes, bash_cv_wcwdith_broken=no)]) +if test $bash_cv_wcwidth_broken = yes; then + AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken]) +fi + if test "$am_cv_func_iconv" = yes; then OLDLIBS="$LIBS" LIBS="$LIBS $LIBICONV" diff --git a/autom4te.cache/output.0 b/autom4te.cache/output.0 index 490eca45..5a283c02 100644 --- a/autom4te.cache/output.0 +++ b/autom4te.cache/output.0 @@ -10787,7 +10787,6 @@ if test "x$ac_cv_func_mbsrtowcs" = xyes; then : fi - ac_fn_c_check_func "$LINENO" "mbschr" "ac_cv_func_mbschr" if test "x$ac_cv_func_mbschr" = xyes; then : $as_echo "@%:@define HAVE_MBSCHR 1" >>confdefs.h @@ -11038,6 +11037,57 @@ $as_echo "@%:@define HAVE_WINT_T 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wcwidth broken with unicode combining characters" >&5 +$as_echo_n "checking for wcwidth broken with unicode combining characters... " >&6; } +if ${bash_cv_wcwidth_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> + +#include <locale.h> +#include <wchar.h> + +main(c, v) +int c; +char **v; +{ + int w; + + setlocale(LC_ALL, "en_US.UTF-8"); + w = wcwidth (0x0301); + exit (w == 0); /* exit 0 if wcwidth broken */ +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_wcwidth_broken=yes +else + bash_cv_wcwdith_broken=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_wcwidth_broken" >&5 +$as_echo "$bash_cv_wcwidth_broken" >&6; } +if test $bash_cv_wcwidth_broken = yes; then + +$as_echo "@%:@define WCWIDTH_BROKEN 1" >>confdefs.h + +fi + if test "$am_cv_func_iconv" = yes; then OLDLIBS="$LIBS" LIBS="$LIBS $LIBICONV" diff --git a/autom4te.cache/requests b/autom4te.cache/requests index 3d36623d..d1d8824d 100644 --- a/autom4te.cache/requests +++ b/autom4te.cache/requests @@ -15,55 +15,55 @@ 'configure.in' ], { - 'AM_PROG_F77_C_O' => 1, '_LT_AC_TAGCONFIG' => 1, - 'm4_pattern_forbid' => 1, + 'AM_PROG_F77_C_O' => 1, 'AC_INIT' => 1, - 'AC_CANONICAL_TARGET' => 1, + 'm4_pattern_forbid' => 1, '_AM_COND_IF' => 1, - 'AC_CONFIG_LIBOBJ_DIR' => 1, + 'AC_CANONICAL_TARGET' => 1, 'AC_SUBST' => 1, - 'AC_CANONICAL_HOST' => 1, + 'AC_CONFIG_LIBOBJ_DIR' => 1, 'AC_FC_SRCEXT' => 1, + 'AC_CANONICAL_HOST' => 1, 'AC_PROG_LIBTOOL' => 1, 'AM_INIT_AUTOMAKE' => 1, - 'AC_CONFIG_SUBDIRS' => 1, 'AM_PATH_GUILE' => 1, + 'AC_CONFIG_SUBDIRS' => 1, 'AM_AUTOMAKE_VERSION' => 1, 'LT_CONFIG_LTDL_DIR' => 1, - 'AC_CONFIG_LINKS' => 1, 'AC_REQUIRE_AUX_FILE' => 1, - 'LT_SUPPORTED_TAG' => 1, + 'AC_CONFIG_LINKS' => 1, 'm4_sinclude' => 1, + 'LT_SUPPORTED_TAG' => 1, 'AM_MAINTAINER_MODE' => 1, 'AM_NLS' => 1, 'AM_GNU_GETTEXT_INTL_SUBDIR' => 1, - '_m4_warn' => 1, 'AM_MAKEFILE_INCLUDE' => 1, + '_m4_warn' => 1, 'AM_PROG_CXX_C_O' => 1, - '_AM_COND_ENDIF' => 1, '_AM_MAKEFILE_INCLUDE' => 1, + '_AM_COND_ENDIF' => 1, 'AM_ENABLE_MULTILIB' => 1, 'AM_SILENT_RULES' => 1, 'AM_PROG_MOC' => 1, 'AC_CONFIG_FILES' => 1, - 'LT_INIT' => 1, 'include' => 1, - 'AM_GNU_GETTEXT' => 1, + 'LT_INIT' => 1, 'AM_PROG_AR' => 1, + 'AM_GNU_GETTEXT' => 1, 'AC_LIBSOURCE' => 1, - 'AC_CANONICAL_BUILD' => 1, 'AM_PROG_FC_C_O' => 1, + 'AC_CANONICAL_BUILD' => 1, 'AC_FC_FREEFORM' => 1, 'AH_OUTPUT' => 1, - 'AC_CONFIG_AUX_DIR' => 1, '_AM_SUBST_NOTMAKE' => 1, - 'AM_PROG_CC_C_O' => 1, - 'm4_pattern_allow' => 1, + 'AC_CONFIG_AUX_DIR' => 1, 'sinclude' => 1, - 'AM_CONDITIONAL' => 1, - 'AC_CANONICAL_SYSTEM' => 1, + 'm4_pattern_allow' => 1, + 'AM_PROG_CC_C_O' => 1, 'AM_XGETTEXT_OPTION' => 1, + 'AC_CANONICAL_SYSTEM' => 1, + 'AM_CONDITIONAL' => 1, 'AC_CONFIG_HEADERS' => 1, 'AC_DEFINE_TRACE_LITERAL' => 1, 'AM_POT_TOOLS' => 1, diff --git a/autom4te.cache/traces.0 b/autom4te.cache/traces.0 index 343ea49d..f5559850 100644 --- a/autom4te.cache/traces.0 +++ b/autom4te.cache/traces.0 @@ -580,7 +580,7 @@ m4trace:configure.in:513: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is ob You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... -aclocal.m4:1780: RL_LIB_READLINE_VERSION is expanded from... +aclocal.m4:1806: RL_LIB_READLINE_VERSION is expanded from... configure.in:513: the top level]) m4trace:configure.in:513: -1- AC_DEFINE_TRACE_LITERAL([RL_READLINE_VERSION]) m4trace:configure.in:513: -1- m4_pattern_allow([^RL_READLINE_VERSION$]) @@ -773,8 +773,8 @@ m4trace:configure.in:659: -1- AC_SUBST_TRACE([MSGMERGE]) m4trace:configure.in:659: -1- m4_pattern_allow([^MSGMERGE$]) m4trace:configure.in:659: -1- _m4_warn([obsolete], [The macro `AC_OUTPUT_COMMANDS' is obsolete. You should run autoupdate.], [../../lib/autoconf/status.m4:1028: AC_OUTPUT_COMMANDS is expanded from... -aclocal.m4:3681: AM_PO_SUBDIRS is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:3707: AM_PO_SUBDIRS is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([off_t]) m4trace:configure.in:659: -1- m4_pattern_allow([^off_t$]) @@ -838,9 +838,9 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2587: gt_INTDIV0 is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2613: gt_INTDIV0 is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([INTDIV0_RAISES_SIGFPE]) m4trace:configure.in:659: -1- m4_pattern_allow([^INTDIV0_RAISES_SIGFPE$]) @@ -851,10 +851,10 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2615: AC_TRY_COMPILE ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2689: jm_AC_HEADER_INTTYPES_H is expanded from... -aclocal.m4:3990: jm_AC_TYPE_UINTMAX_T is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2715: jm_AC_HEADER_INTTYPES_H is expanded from... +aclocal.m4:4016: jm_AC_TYPE_UINTMAX_T is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H_WITH_UINTMAX]) m4trace:configure.in:659: -1- m4_pattern_allow([^HAVE_INTTYPES_H_WITH_UINTMAX$]) @@ -866,10 +866,10 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2615: AC_TRY_COMPILE ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:3960: jm_AC_HEADER_STDINT_H is expanded from... -aclocal.m4:3990: jm_AC_TYPE_UINTMAX_T is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:3986: jm_AC_HEADER_STDINT_H is expanded from... +aclocal.m4:4016: jm_AC_TYPE_UINTMAX_T is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([HAVE_STDINT_H_WITH_UINTMAX]) m4trace:configure.in:659: -1- m4_pattern_allow([^HAVE_STDINT_H_WITH_UINTMAX$]) @@ -881,10 +881,10 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:4017: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from... -aclocal.m4:3990: jm_AC_TYPE_UINTMAX_T is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:4043: jm_AC_TYPE_UNSIGNED_LONG_LONG is expanded from... +aclocal.m4:4016: jm_AC_TYPE_UINTMAX_T is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([HAVE_UNSIGNED_LONG_LONG]) m4trace:configure.in:659: -1- m4_pattern_allow([^HAVE_UNSIGNED_LONG_LONG$]) @@ -904,9 +904,9 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2615: AC_TRY_COMPILE ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2662: gt_HEADER_INTTYPES_H is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2688: gt_HEADER_INTTYPES_H is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTTYPES_H]) m4trace:configure.in:659: -1- m4_pattern_allow([^HAVE_INTTYPES_H$]) @@ -917,9 +917,9 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2615: AC_TRY_COMPILE ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2717: gt_INTTYPES_PRI is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2743: gt_INTTYPES_PRI is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([PRI_MACROS_BROKEN]) m4trace:configure.in:659: -1- m4_pattern_allow([^PRI_MACROS_BROKEN$]) @@ -996,20 +996,20 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2495: AM_ICONV_LINK is expanded from... -aclocal.m4:2550: AM_ICONV is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2521: AM_ICONV_LINK is expanded from... +aclocal.m4:2576: AM_ICONV is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2495: AM_ICONV_LINK is expanded from... -aclocal.m4:2550: AM_ICONV is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2521: AM_ICONV_LINK is expanded from... +aclocal.m4:2576: AM_ICONV is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ICONV]) m4trace:configure.in:659: -1- m4_pattern_allow([^HAVE_ICONV$]) @@ -1025,9 +1025,9 @@ m4trace:configure.in:659: -1- _m4_warn([obsolete], [The macro `AC_TRY_COMPILE' i You should run autoupdate.], [../../lib/autoconf/general.m4:2615: AC_TRY_COMPILE is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... -aclocal.m4:2550: AM_ICONV is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2576: AM_ICONV is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([ICONV_CONST]) m4trace:configure.in:659: -1- m4_pattern_allow([^ICONV_CONST$]) @@ -1038,9 +1038,9 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2014: AM_LANGINFO_CODESET is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2040: AM_LANGINFO_CODESET is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LANGINFO_CODESET]) m4trace:configure.in:659: -1- m4_pattern_allow([^HAVE_LANGINFO_CODESET$]) @@ -1051,9 +1051,9 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2784: AM_LC_MESSAGES is expanded from... -aclocal.m4:2373: AM_INTL_SUBDIR is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2810: AM_LC_MESSAGES is expanded from... +aclocal.m4:2399: AM_INTL_SUBDIR is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LC_MESSAGES]) m4trace:configure.in:659: -1- m4_pattern_allow([^HAVE_LC_MESSAGES$]) @@ -1071,21 +1071,21 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- _m4_warn([obsolete], [The macro `AC_TRY_LINK' is obsolete. You should run autoupdate.], [../../lib/autoconf/general.m4:2688: AC_TRY_LINK is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:2085: AM_GNU_GETTEXT is expanded from... +aclocal.m4:2111: AM_GNU_GETTEXT is expanded from... configure.in:659: the top level]) m4trace:configure.in:659: -1- AC_DEFINE_TRACE_LITERAL([ENABLE_NLS]) m4trace:configure.in:659: -1- m4_pattern_allow([^ENABLE_NLS$]) @@ -1829,6 +1829,24 @@ m4trace:configure.in:811: -1- AC_DEFINE_TRACE_LITERAL([HAVE_WINT_T]) m4trace:configure.in:811: -1- m4_pattern_allow([^HAVE_WINT_T$]) m4trace:configure.in:811: -1- AH_OUTPUT([HAVE_WINT_T], [/* systems should define this type here */ @%:@undef HAVE_WINT_T]) +m4trace:configure.in:811: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is obsolete. +You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is expanded from... +../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... +../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... +../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... +aclocal.m4:1689: BASH_CHECK_MULTIBYTE is expanded from... +configure.in:811: the top level]) +m4trace:configure.in:811: -1- _m4_warn([cross], [AC_RUN_IFELSE called without default to allow cross compiling], [../../lib/autoconf/general.m4:2749: AC_RUN_IFELSE is expanded from... +../../lib/autoconf/general.m4:2765: AC_TRY_RUN is expanded from... +../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... +../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... +../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... +aclocal.m4:1689: BASH_CHECK_MULTIBYTE is expanded from... +configure.in:811: the top level]) +m4trace:configure.in:811: -1- AC_DEFINE_TRACE_LITERAL([WCWIDTH_BROKEN]) +m4trace:configure.in:811: -1- m4_pattern_allow([^WCWIDTH_BROKEN$]) +m4trace:configure.in:811: -1- AH_OUTPUT([WCWIDTH_BROKEN], [/* wcwidth is usually not broken */ +@%:@undef WCWIDTH_BROKEN]) m4trace:configure.in:811: -1- AH_OUTPUT([HAVE_LOCALE_CHARSET], [/* Define to 1 if you have the `locale_charset\' function. */ @%:@undef HAVE_LOCALE_CHARSET]) m4trace:configure.in:811: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LOCALE_CHARSET]) @@ -2100,7 +2118,7 @@ m4trace:configure.in:892: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is ob You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... -aclocal.m4:1894: BASH_FUNC_CTYPE_NONASCII is expanded from... +aclocal.m4:1920: BASH_FUNC_CTYPE_NONASCII is expanded from... configure.in:892: the top level]) m4trace:configure.in:892: -1- AC_DEFINE_TRACE_LITERAL([CTYPE_NON_ASCII]) m4trace:configure.in:892: -1- m4_pattern_allow([^CTYPE_NON_ASCII$]) @@ -2320,7 +2338,7 @@ m4trace:configure.in:929: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is ob You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... -aclocal.m4:4123: BASH_STRUCT_WEXITSTATUS_OFFSET is expanded from... +aclocal.m4:4149: BASH_STRUCT_WEXITSTATUS_OFFSET is expanded from... configure.in:929: the top level]) m4trace:configure.in:929: -1- AC_DEFINE_TRACE_LITERAL([WEXITSTATUS_OFFSET]) m4trace:configure.in:929: -1- m4_pattern_allow([^WEXITSTATUS_OFFSET$]) @@ -2402,7 +2420,7 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:4039: BASH_FUNC_SNPRINTF is expanded from... +aclocal.m4:4065: BASH_FUNC_SNPRINTF is expanded from... configure.in:942: the top level]) m4trace:configure.in:942: -1- AC_DEFINE_TRACE_LITERAL([HAVE_SNPRINTF]) m4trace:configure.in:942: -1- m4_pattern_allow([^HAVE_SNPRINTF$]) @@ -2415,7 +2433,7 @@ You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... -aclocal.m4:4067: BASH_FUNC_VSNPRINTF is expanded from... +aclocal.m4:4093: BASH_FUNC_VSNPRINTF is expanded from... configure.in:943: the top level]) m4trace:configure.in:943: -1- AC_DEFINE_TRACE_LITERAL([HAVE_VSNPRINTF]) m4trace:configure.in:943: -1- m4_pattern_allow([^HAVE_VSNPRINTF$]) @@ -2499,7 +2517,7 @@ m4trace:configure.in:971: -1- _m4_warn([obsolete], [The macro `AC_TRY_RUN' is ob You should run autoupdate.], [../../lib/autoconf/general.m4:2765: AC_TRY_RUN is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... -aclocal.m4:1938: BASH_CHECK_WCONTINUED is expanded from... +aclocal.m4:1964: BASH_CHECK_WCONTINUED is expanded from... configure.in:971: the top level]) m4trace:configure.in:971: -1- AC_DEFINE_TRACE_LITERAL([WCONTINUED_BROKEN]) m4trace:configure.in:971: -1- m4_pattern_allow([^WCONTINUED_BROKEN$]) diff --git a/config.h.in b/config.h.in index 69846a65..e2539e34 100644 --- a/config.h.in +++ b/config.h.in @@ -881,6 +881,9 @@ /* Define if you have the wcwidth function. */ #undef HAVE_WCWIDTH +/* and if it works */ +#undef WCWIDTH_BROKEN + /* Presence of certain system include files. */ /* Define if you have the <arpa/inet.h> header file. */ @@ -10787,7 +10787,6 @@ if test "x$ac_cv_func_mbsrtowcs" = xyes; then : fi - ac_fn_c_check_func "$LINENO" "mbschr" "ac_cv_func_mbschr" if test "x$ac_cv_func_mbschr" = xyes; then : $as_echo "#define HAVE_MBSCHR 1" >>confdefs.h @@ -11038,6 +11037,57 @@ $as_echo "#define HAVE_WINT_T 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wcwidth broken with unicode combining characters" >&5 +$as_echo_n "checking for wcwidth broken with unicode combining characters... " >&6; } +if ${bash_cv_wcwidth_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> + +#include <locale.h> +#include <wchar.h> + +main(c, v) +int c; +char **v; +{ + int w; + + setlocale(LC_ALL, "en_US.UTF-8"); + w = wcwidth (0x0301); + exit (w == 0); /* exit 0 if wcwidth broken */ +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_wcwidth_broken=yes +else + bash_cv_wcwdith_broken=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_wcwidth_broken" >&5 +$as_echo "$bash_cv_wcwidth_broken" >&6; } +if test $bash_cv_wcwidth_broken = yes; then + +$as_echo "#define WCWIDTH_BROKEN 1" >>confdefs.h + +fi + if test "$am_cv_func_iconv" = yes; then OLDLIBS="$LIBS" LIBS="$LIBS $LIBICONV" @@ -309,7 +309,11 @@ static void expr_bind_variable (lhs, rhs) char *lhs, *rhs; { - (void)bind_int_variable (lhs, rhs); + SHELL_VAR *v; + + v = bind_int_variable (lhs, rhs); + if (v && (readonly_p (v) || noassign_p (v))) + longjmp (evalbuf, 1); /* variable assignment error */ stupidly_hack_special_variables (lhs); } diff --git a/lib/readline/complete.c b/lib/readline/complete.c index e67cfeb3..1b593969 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -679,7 +679,7 @@ fnwidth (string) else { pos += clen; - w = wcwidth (wc); + w = WCWIDTH (wc); width += (w >= 0) ? w : 1; } #else @@ -766,7 +766,7 @@ fnprint (to_print, prefix_bytes) break; else { - w = wcwidth (wc); + w = WCWIDTH (wc); width = (w >= 0) ? w : 1; } fwrite (s, 1, tlen, rl_outstream); diff --git a/lib/readline/display.c b/lib/readline/display.c index 7cab8642..655f90c9 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -766,7 +766,7 @@ rl_redisplay () break; /* Found '\0' */ else { - temp = wcwidth (wc); + temp = WCWIDTH (wc); wc_width = (temp >= 0) ? temp : 1; } } @@ -1320,7 +1320,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) else if (MB_NULLWCH (ret)) tempwidth = 0; else - tempwidth = wcwidth (wc); + tempwidth = WCWIDTH (wc); if (tempwidth > 0) { @@ -1377,6 +1377,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) temp = (omax < nmax) ? omax : nmax; if (memcmp (old, new, temp) == 0) /* adding at the end */ { + new_offset = old_offset = temp; ofd = old + temp; nfd = new + temp; } @@ -1387,6 +1388,8 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (omax == nmax && STREQN (new, old, omax)) { + old_offset = omax; + new_offset = nmax; ofd = old + omax; nfd = new + nmax; } @@ -1399,6 +1402,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) { old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY); new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY); + ofd = old + old_offset; nfd = new + new_offset; } @@ -1422,6 +1426,27 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) if (ofd == oe && nfd == ne) return; +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && _rl_utf8locale) + { + wchar_t wc; + mbstate_t ps = { 0 }; + int t; + + /* If the first character in the difference is a zero-width character, + assume it's a combining character and back one up so the two base + characters no longer compare equivalently. */ + t = mbrtowc (&wc, ofd, MB_CUR_MAX, &ps); + if (t > 0 && UNICODE_COMBINING_CHAR (wc) && WCWIDTH (wc) == 0) + { + old_offset = _rl_find_prev_mbchar (old, ofd - old, MB_FIND_ANY); + new_offset = _rl_find_prev_mbchar (new, nfd - new, MB_FIND_ANY); + ofd = old + old_offset; /* equal by definition */ + nfd = new + new_offset; + } + } +#endif + wsatend = 1; /* flag for trailing whitespace */ #if defined (HANDLE_MULTIBYTE) @@ -1429,6 +1454,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin) { ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY); nls = new + _rl_find_prev_mbchar (new, ne - new, MB_FIND_ANY); + while ((ols > ofd) && (nls > nfd)) { memset (&ps_old, 0, sizeof (mbstate_t)); @@ -2721,14 +2747,7 @@ _rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1"); { point += tmp; max -= tmp; -#if defined (MACOSX) - /* Mac OS X has a bug where wcwidth returns 1 for UTF-8 combining - characters */ - if (wc >= 769 && wc <= 833) - tmp = 0; - else -#endif - tmp = wcwidth(wc); + tmp = WCWIDTH(wc); width += (tmp >= 0) ? tmp : 1; } } diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c index 712b9ea8..de29e616 100644 --- a/lib/readline/isearch.c +++ b/lib/readline/isearch.c @@ -6,7 +6,7 @@ /* */ /* **************************************************************** */ -/* Copyright (C) 1987-2009 Free Software Foundation, Inc. +/* Copyright (C) 1987-2011 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -110,7 +110,7 @@ _rl_scxt_alloc (type, flags) cxt->history_pos = 0; cxt->direction = 0; - cxt->lastc = 0; + cxt->prevc = cxt->lastc = 0; cxt->sline = 0; cxt->sline_len = cxt->sline_index = 0; @@ -319,6 +319,9 @@ _rl_search_getchar (cxt) return c; } +#define ENDSRCH_CHAR(c) \ + ((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G'))) + /* 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. */ @@ -347,7 +350,10 @@ _rl_isearch_dispatch (cxt, c) cxt->keymap = FUNCTION_TO_KEYMAP (cxt->keymap, c); cxt->sflags |= SF_CHGKMAP; /* XXX - we should probably save this sequence, so we can do - something useful if this doesn't end up mapping to a command. */ + something useful if this doesn't end up mapping to a command we + interpret here. Right now we just save the most recent character + that caused the index into a new keymap. */ + cxt->prevc = c; return 1; } @@ -376,6 +382,18 @@ _rl_isearch_dispatch (cxt, c) { cxt->keymap = cxt->okeymap; cxt->sflags &= ~SF_CHGKMAP; + /* If we indexed into a new keymap, but didn't map to a command that + affects the search (lastc > 0), and the character that mapped to a + new keymap would have ended the search (ENDSRCH_CHAR(cxt->prevc)), + handle that now as if the previous char would have ended the search + and we would have read the current character. */ + /* XXX - should we check cxt->mb? */ + if (cxt->lastc > 0 && ENDSRCH_CHAR (cxt->prevc)) + { + rl_stuff_char (cxt->lastc); + rl_execute_next (cxt->prevc); + return (0); + } } /* The characters in isearch_terminators (set from the user-settable @@ -398,9 +416,6 @@ _rl_isearch_dispatch (cxt, c) 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) { diff --git a/lib/readline/mbutil.c b/lib/readline/mbutil.c index eeb7e557..8e6be2f1 100644 --- a/lib/readline/mbutil.c +++ b/lib/readline/mbutil.c @@ -119,7 +119,7 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) point += tmp; if (find_non_zero) { - if (wcwidth (wc) == 0) + if (WCWIDTH (wc) == 0) continue; else count--; @@ -132,7 +132,7 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero) if (find_non_zero) { tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); - while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && wcwidth (wc) == 0) + while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && WCWIDTH (wc) == 0) { point += tmp; tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); @@ -184,7 +184,7 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero) { if (find_non_zero) { - if (wcwidth (wc) != 0) + if (WCWIDTH (wc) != 0) prev = point; } else diff --git a/lib/readline/nls.c b/lib/readline/nls.c index e3599eb7..a1f57bcf 100644 --- a/lib/readline/nls.c +++ b/lib/readline/nls.c @@ -43,6 +43,10 @@ # include <locale.h> #endif +#if defined (HAVE_LANGINFO_CODESET) +# include <langinfo.h> +#endif + #include <ctype.h> #include "rldefs.h" @@ -50,6 +54,8 @@ #include "rlshell.h" #include "rlprivate.h" +static int utf8locale PARAMS((char *)); + #if !defined (HAVE_SETLOCALE) /* A list of legal values for the LANG or LC_CTYPE environment variables. If a locale name in this list is the value for the LC_ALL, LC_CTYPE, @@ -72,9 +78,12 @@ static char *legal_lang_values[] = }; static char *normalize_codeset PARAMS((char *)); -static char *find_codeset PARAMS((char *, size_t *)); #endif /* !HAVE_SETLOCALE */ +static char *find_codeset PARAMS((char *, size_t *)); + +int _rl_utf8locale = 0; + static char *_rl_get_locale_var PARAMS((const char *)); static char * @@ -91,7 +100,26 @@ _rl_get_locale_var (v) return lspec; } - + +static int +utf8locale (lspec) + char *lspec; +{ + char *cp; + size_t len; + +#if HAVE_LANGINFO_CODESET + cp = nl_langinfo (CODESET); + return (STREQ (cp, "UTF-8") || STREQ (cp, "utf8")); +#else + cp = find_codeset (lspec, &len); + + if (cp == 0 || len < 4 || len > 5) + return 0; + return ((len == 5) ? strncmp (cp. "UTF-8", len) == 0 : strncmp (cp, "utf8", 4) == 0); +#endif +} + /* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value to decide the defaults for 8-bit character input and output. Returns 1 if we set eight-bit mode. */ @@ -116,6 +144,9 @@ _rl_init_eightbit () lspec = ""; t = setlocale (LC_CTYPE, lspec); + if (t && *t) + _rl_utf8locale = utf8locale (t); + if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0)) { _rl_meta_flag = 1; @@ -197,6 +228,7 @@ normalize_codeset (codeset) return retval; } +#endif /* !HAVE_SETLOCALE */ /* Isolate codeset portion of locale specification. */ static char * @@ -249,4 +281,3 @@ find_codeset (name, lenp) return result; } -#endif /* !HAVE_SETLOCALE */ diff --git a/lib/readline/rlmbutil.h b/lib/readline/rlmbutil.h index 7716a70c..06d85ab3 100644 --- a/lib/readline/rlmbutil.h +++ b/lib/readline/rlmbutil.h @@ -123,6 +123,15 @@ extern int _rl_walphabetic PARAMS((wchar_t)); #define MB_INVALIDCH(x) ((x) == (size_t)-1 || (x) == (size_t)-2) #define MB_NULLWCH(x) ((x) == 0) +/* Unicode combining characters range from U+0300 to U+036F */ +#define UNICODE_COMBINING_CHAR(x) ((x) >= 768 && (x) <= 879) + +#if defined (WCWIDTH_BROKEN) +# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : wcwidth(wc)) +#else +# define WCWIDTH(wc) wcwidth(wc) +#endif + #else /* !HANDLE_MULTIBYTE */ #undef MB_LEN_MAX diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h index 2e31ded0..f39c462a 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-2010 Free Software Foundation, Inc. +/* Copyright (C) 1999-2011 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -86,6 +86,7 @@ typedef struct __rl_search_context int history_pos; int direction; + int prevc; int lastc; #if defined (HANDLE_MULTIBYTE) char mb[MB_LEN_MAX]; @@ -443,6 +444,9 @@ extern int _rl_history_saved_point; extern _rl_arg_cxt _rl_argcxt; +/* nls.c */ +extern int _rl_utf8locale; + /* readline.c */ extern int _rl_echoing_p; extern int _rl_horizontal_scroll_mode; @@ -26,6 +26,10 @@ # include <unistd.h> #endif +#if HAVE_LANGINFO_CODESET +# include <langinfo.h> +#endif + #include "bashintl.h" #include "bashansi.h" #include <stdio.h> @@ -39,6 +43,8 @@ extern int errno; #endif +int locale_utf8locale; /* unused for now */ + extern int dump_translatable_strings, dump_po_strings; /* The current locale when the program begins */ @@ -61,6 +67,7 @@ static char *lang; static int reset_locale_vars __P((void)); static void locale_setblanks __P((void)); +static int locale_isutf8 __P((char *)); /* Set the value of default_locale and make the current locale the system default locale. This should be called very early in main(). */ @@ -267,7 +274,7 @@ set_lang (var, value) lang = (char *)xmalloc (1); lang[0] = '\0'; } - + return ((lc_all == 0 || *lc_all == 0) ? reset_locale_vars () : 0); } @@ -532,3 +539,18 @@ locale_setblanks () sh_syntaxtab[x] &= ~(CSHBRK|CBLANK); } } + +static int +locale_isutf8 (lspec) + char *lspec; +{ + char *cp; + +#if HAVE_LANGINFO_CODESET + cp = nl_langinfo (CODESET); + return (STREQ (cp, "UTF-8") || STREQ (cp, "utf8")); +#else + /* Take a shot */ + return (strstr (lspec, "UTF-8") || strstr (lspec, "utf8")); +#endif +} |