]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20150521 snapshot
authorChet Ramey <chet.ramey@case.edu>
Fri, 5 Jun 2015 15:49:44 +0000 (11:49 -0400)
committerChet Ramey <chet.ramey@case.edu>
Fri, 5 Jun 2015 15:49:44 +0000 (11:49 -0400)
24 files changed:
CWRU/CWRU.chlog
builtins/fc.def
builtins/shopt.def
configure
configure.ac
flags.c
flags.h
lib/readline/callback.c
lib/readline/display.c
lib/readline/doc/history.3
lib/readline/doc/hstech.texi
lib/readline/doc/version.texi
lib/readline/input.c
lib/readline/rlmbutil.h
lib/readline/rlprivate.h
lib/readline/text.c
lib/sh/casemod.c
lib/sh/mbscasecmp.c
lib/sh/mbscmp.c
lib/sh/shmbchar.c
lib/sh/shquote.c
print_cmd.c
shell.c
subst.c

index 5f52542640361795200f198b04a95a48fecd0a32..9c0547f80209ed7d4efc9bf50420dff2190be2be 100644 (file)
@@ -8558,3 +8558,87 @@ lib/readline/bind.c
        - sv_isrchterm: make sure we check for v[end] == 0 while in the loop
          looking for whitespace.  Bug report and fix from Sergio Durigan
          Junior <sergiodj@sergiodj.net>
+
+lib/sh/shmbchar.c
+       - mbstrlen,mbsmbchar: move calculation of MB_CUR_MAX out of loop;
+         calculate it once at beginning
+
+lib/sh/mbscmp.c
+       - mbscmp: move calculation of MB_CUR_MAX out of loop; calculate it once
+         at beginning
+
+lib/sh/mbscasecmp.c
+       - mbscasecmp: move calculation of MB_CUR_MAX out of loop; calculate it once
+         at beginning
+
+lib/sh/shquote.c
+       - sh_backslash_quote: move calculation of MB_CUR_MAX out of loop;
+         calculate it once at beginning
+
+lib/sh/casemod.c
+       - sh_modcase: move calculation of MB_CUR_MAX out of loop; calculate it once
+         at beginning
+
+subst.c
+       - expand_word_internal: move calculation of MB_CUR_MAX out of loops;
+         calculate it once at beginning of function (XXX should use
+         locale_mb_cur_max)
+
+                                  5/22
+                                  ----
+lib/readline/rlmbutil.h
+       - _rl_wcwidth: new function, short-circuits wcwidth calls for ASCII
+         printable characters, returns 1 for those
+       - WCWIDTH: call _rl_wcwidth instead of wcwidth
+
+lib/readline/display.c
+       - rl_redisplay: move calculation of MB_CUR_MAX out of loop; calculate
+         it once at beginning.  Report and patch from Ole Laursen
+         <ole.laursen@gmail.com>
+
+                                  5/24
+                                  ----
+lib/readline/text.c
+       - rl_insert: change to attempt to batch-insert pending typeahead (not
+         pushed input or input from a macro) that maps to rl_insert.  An
+         attempt to suppress redisplay until readline reads all typeahead --
+         pasted input, for instance.  Inspired by report from Ole Laursen
+         <ole.laursen@gmail.com>.  XXX - need to make this a bindable
+         variable; already controlled by _rl_optimize_typeahead
+
+lib/readline/rlprivate.h
+       - _rl_optimize_typeahead: extern declaration
+
+lib/readline/doc/{hstech.texi,history.3}
+       - next_history: clarify under what circumstances the history offset is
+         incremented; suggestion from Glenn Golden <gdg@zplane.com>
+
+print_cmd.c
+       - print_arith_command: should be compiled in if either DPAREN_ARITHMETIC
+         or ARITH_FOR_COMMAND is defined.  Report from Flavio Medeiros
+         <flaviomotamederios@gmail.com>
+
+flags.c
+       - change_flag: new variable verbose_flag, set when `v' flag modified;
+         sets value of echo_input_at_read correspondingly
+
+flags.h
+       - verbose_flag: new extern declaration
+
+shell.c
+       - long_options: --verbose now sets verbose_flag
+       - main: set echo_input_at_read from verbose_flag after parsing any
+         long options
+
+builtins/fc.def
+       - fc_builtin: don't unwind-protect echo_input_at_read directly; set it
+         to 1 before calling fc_execute_file as before, and reset it to value
+         of global verbose_flag using set_verbose_flag called from an
+         unwind_protect.  Report from isabella parakiss <izaberina@gmail.com>
+
+builtins/shopt.def
+       - shopt_set_debug_mode: new function, called when the extdebug shell
+         option changes.  Right now, it sets function_trace_mode when extdebug
+         is enabled, and turns off when extdebug is disabled.  The documentation
+         has always said that shopt does this.  Report from Peng Yu
+         <pengyu.ut@gmail.com>
index cf6b72c75b10b00215a65395f610353e3c65eac4..9d5b342e7d31576bf2ac5b77d6a4642b8bccb1cc 100644 (file)
@@ -158,6 +158,12 @@ static char *fc_readline __P((FILE *));
 static void fc_addhist __P((char *));
 #endif
 
+static void
+set_verbose_flag ()
+{
+  echo_input_at_read = verbose_flag;
+}
+
 /* String to execute on a file that we want to edit. */
 #define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}"
 #if defined (STRICT_POSIX)
@@ -451,9 +457,9 @@ fc_builtin (list)
   begin_unwind_frame ("fc builtin");
   add_unwind_protect ((Function *)xfree, fn);
   add_unwind_protect (unlink, fn);
-  unwind_protect_int (echo_input_at_read);
+  add_unwind_protect (set_verbose_flag, (char *)NULL);
   echo_input_at_read = 1;
-    
+
   retval = fc_execute_file (fn);
 
   run_unwind_frame ("fc builtin");
index 80e257d1f4a02887ee980fb665a4753fe4e5dd9c..b82db630c01bd3ecd45f2dc4dacbf64010320547 100644 (file)
@@ -131,6 +131,8 @@ static int set_restricted_shell __P((char *, int));
 static int shopt_set_complete_direxpand __P((char *, int));
 #endif
 
+static int shopt_set_debug_mode __P((char *, int));
+
 static int shopt_login_shell;
 static int shopt_compat31;
 static int shopt_compat32;
@@ -170,7 +172,7 @@ static struct {
   { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
   { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
 #if defined (DEBUGGER)
-  { "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
+  { "extdebug", &debugging_mode, shopt_set_debug_mode },
 #endif
 #if defined (EXTENDED_GLOB)
   { "extglob", &extended_glob, (shopt_set_func_t *)NULL },
@@ -516,6 +518,16 @@ set_shellopts_after_change (option_name, mode)
   return (0);
 }
 
+static int
+shopt_set_debug_mode (option_name, mode)
+     char *option_name;
+     int mode;
+{
+#if defined (DEBUGGER)
+  function_trace_mode = debugging_mode;
+#endif
+}
+
 static int
 shopt_enable_hostname_completion (option_name, mode)
      char *option_name;
index f289541b144b83afb71a2d9a862273feae041dd8..6852a12197115539323fd463f232f337a90d9b0b 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac for Bash 4.4, version 4.069.
+# From configure.ac for Bash 4.4, version 4.070.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.69 for bash 4.4-devel.
 #
@@ -16020,7 +16020,7 @@ solaris2*)      LOCAL_CFLAGS=-DSOLARIS ;;
 lynxos*)       LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
 linux*)                LOCAL_LDFLAGS=-rdynamic          # allow dynamic loading
                case "`uname -r`" in
-               2.[456789]*|3*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h
+               2.[456789]*|[34]*)      $as_echo "#define PGRP_PIPE 1" >>confdefs.h
  ;;
                esac ;;
 *qnx6*)                LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
index df86486b5230770c92a67f584a5d31c2cbc34932..80977e0dbb5a226f06b203eb8ef1debf0f9ca17a 100644 (file)
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
 #   You should have received a copy of the GNU General Public License
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-AC_REVISION([for Bash 4.4, version 4.069])dnl
+AC_REVISION([for Bash 4.4, version 4.070])dnl
 
 define(bashvers, 4.4)
 define(relstatus, devel)
@@ -1096,7 +1096,7 @@ solaris2*)        LOCAL_CFLAGS=-DSOLARIS ;;
 lynxos*)       LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
 linux*)                LOCAL_LDFLAGS=-rdynamic          # allow dynamic loading
                case "`uname -r`" in
-               2.[[456789]]*|3*)       AC_DEFINE(PGRP_PIPE) ;;
+               2.[[456789]]*|[[34]]*)  AC_DEFINE(PGRP_PIPE) ;;
                esac ;;
 *qnx6*)                LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
 *qnx*)         LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
diff --git a/flags.c b/flags.c
index 79d8e1bf9757d6e413ad9e6f74b212e0ef960887..5704741c43ce753a021b6279dc60c2e95cc774ef 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -90,6 +90,7 @@ int unbound_vars_is_error = 0;
 
 /* Non-zero means type out input lines after you read them. */
 int echo_input_at_read = 0;
+int verbose_flag = 0;
 
 /* Non-zero means type out the command definition after reading, but
    before executing. */
@@ -197,7 +198,7 @@ const struct flags_alist shell_flags[] = {
 #endif /* RESTRICTED_SHELL */
   { 't', &just_one_command },
   { 'u', &unbound_vars_is_error },
-  { 'v', &echo_input_at_read },
+  { 'v', &verbose_flag },
   { 'x', &echo_command_at_execute },
 
   /* New flags that control non-standard things. */
@@ -297,6 +298,9 @@ change_flag (flag, on_or_off)
       break;
 #endif
 
+    case 'v':
+      echo_input_at_read = verbose_flag;
+      break;
     }
 
   return (old_value);
@@ -354,7 +358,7 @@ reset_shell_flags ()
 {
   mark_modified_vars = exit_immediately_on_error = disallow_filename_globbing = 0;
   place_keywords_in_env = read_but_dont_execute = just_one_command = 0;
-  noclobber = unbound_vars_is_error = echo_input_at_read = 0;
+  noclobber = unbound_vars_is_error = echo_input_at_read = verbose_flag = 0;
   echo_command_at_execute = jobs_m_flag = forced_interactive = 0;
   no_symbolic_links = no_invisible_vars = privileged_mode = pipefail_opt = 0;
 
diff --git a/flags.h b/flags.h
index d31007b4b84d6d72bfea69fc23ee5ea79f464215..d5ed334e14afe8973cac991f75df0c8be6db3433 100644 (file)
--- a/flags.h
+++ b/flags.h
@@ -44,7 +44,7 @@ extern int
   mark_modified_vars, errexit_flag, exit_immediately_on_error,
   disallow_filename_globbing,
   place_keywords_in_env, read_but_dont_execute,
-  just_one_command, unbound_vars_is_error, echo_input_at_read,
+  just_one_command, unbound_vars_is_error, echo_input_at_read, verbose_flag,
   echo_command_at_execute, no_invisible_vars, noclobber,
   hashing_enabled, forced_interactive, privileged_mode, jobs_m_flag,
   asynchronous_notification, interactive_comments, no_symbolic_links,
index 6bb2c3e0dc3182e559215ea303a393627bd5a6cb..b2fe3901eb95b49b704948f9954f7c871d83d92f 100644 (file)
@@ -284,7 +284,8 @@ _rl_callback_data_alloc (count)
   return arg;
 }
 
-void _rl_callback_data_dispose (arg)
+void
+_rl_callback_data_dispose (arg)
      _rl_callback_generic_arg *arg;
 {
   xfree (arg);
index 3c0b7aaee08286880750142cd96bca965f704aef..c6b14fb56051301787044ab4cf51245281285d67 100644 (file)
@@ -586,6 +586,7 @@ rl_redisplay ()
   int wc_width;
   mbstate_t ps;
   int _rl_wrapped_multicolumn = 0;
+  int mb_cur_max = MB_CUR_MAX;
 #endif
 
   if (_rl_echoing_p == 0)
@@ -764,7 +765,7 @@ rl_redisplay ()
          prompts that exceed two physical lines?
          Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
 #if defined (HANDLE_MULTIBYTE)
-      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
+      if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
        {
          n0 = num;
           temp = local_prompt_len;
@@ -802,7 +803,7 @@ rl_redisplay ()
 
       inv_lbreaks[++newlines] = temp;
 #if defined (HANDLE_MULTIBYTE)
-      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
+      if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
        lpos -= _rl_col_width (local_prompt, n0, num, 1);
       else
 #endif
@@ -819,7 +820,7 @@ rl_redisplay ()
   lb_linenum = 0;
 #if defined (HANDLE_MULTIBYTE)
   in = 0;
-  if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+  if (mb_cur_max > 1 && rl_byte_oriented == 0)
     {
       memset (&ps, 0, sizeof (mbstate_t));
       /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
@@ -835,7 +836,7 @@ rl_redisplay ()
       c = (unsigned char)rl_line_buffer[in];
 
 #if defined (HANDLE_MULTIBYTE)
-      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+      if (mb_cur_max > 1 && rl_byte_oriented == 0)
        {
          if (MB_INVALIDCH (wc_bytes))
            {
@@ -944,7 +945,7 @@ rl_redisplay ()
       else
        {
 #if defined (HANDLE_MULTIBYTE)
-         if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+         if (mb_cur_max > 1 && rl_byte_oriented == 0)
            {
              register int i;
 
@@ -980,7 +981,7 @@ rl_redisplay ()
        }
 
 #if defined (HANDLE_MULTIBYTE)
-      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+      if (mb_cur_max > 1 && rl_byte_oriented == 0)
        {
          in += wc_bytes;
          /* XXX - what if wc_bytes ends up <= 0? check for MB_INVALIDCH */
@@ -1028,7 +1029,7 @@ rl_redisplay ()
             not the first.  */
          if (out >= _rl_screenchars)
            {
-             if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+             if (mb_cur_max > 1 && rl_byte_oriented == 0)
                out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);
              else
                out = _rl_screenchars - 1;
@@ -1076,10 +1077,10 @@ rl_redisplay ()
                 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) && OLD_CPOS_IN_PROMPT())
+             if (linenum == 0 && (mb_cur_max > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
                _rl_last_c_pos -= prompt_invis_chars_first_line;        /* XXX - was wrap_offset */
              else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
-                       (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+                       (mb_cur_max > 1 && rl_byte_oriented == 0) &&
                        cpos_adjusted == 0 &&
                        _rl_last_c_pos != o_cpos &&
                        _rl_last_c_pos > (prompt_last_invisible - _rl_screenwidth - prompt_invis_chars_first_line))
@@ -1096,7 +1097,7 @@ rl_redisplay ()
                  (wrap_offset > visible_wrap_offset) &&
                  (_rl_last_c_pos < visible_first_line_len))
                {
-                 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+                 if (mb_cur_max > 1 && rl_byte_oriented == 0)
                    nleft = _rl_screenwidth - _rl_last_c_pos;
                  else
                    nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
@@ -1148,7 +1149,7 @@ rl_redisplay ()
                 the physical cursor position on the screen stays the same,
                 but the buffer position needs to be adjusted to account
                 for invisible characters. */
-             if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
+             if ((mb_cur_max == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
                _rl_last_c_pos += wrap_offset;
            }
 
@@ -1175,7 +1176,7 @@ rl_redisplay ()
                _rl_output_some_chars ("*", 1);
 
              _rl_output_some_chars (local_prompt, nleft);
-             if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+             if (mb_cur_max > 1 && rl_byte_oriented == 0)
                _rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft, 1) - wrap_offset + modmark;
              else
                _rl_last_c_pos = nleft + modmark;
@@ -1199,7 +1200,7 @@ rl_redisplay ()
          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)
+             if (mb_cur_max > 1 && rl_byte_oriented == 0)
                tx = _rl_col_width (&visible_line[pos], 0, nleft, 1) - visible_wrap_offset;
              else
                tx = nleft;
@@ -1214,7 +1215,7 @@ rl_redisplay ()
             _rl_last_c_pos as an absolute cursor position, but moving to a
             point specified by a buffer position (NLEFT) that doesn't take
             invisible characters into account. */
-         if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+         if (mb_cur_max > 1 && rl_byte_oriented == 0)
            _rl_move_cursor_relative (nleft, &invisible_line[pos]);
          else if (nleft != _rl_last_c_pos)
            _rl_move_cursor_relative (nleft, &invisible_line[pos]);
@@ -1295,7 +1296,7 @@ rl_redisplay ()
                       _rl_screenwidth + (lmargin ? 0 : wrap_offset),
                       0);
 
-         if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
+         if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
                displaying_prompt_first_line && OLD_CPOS_IN_PROMPT())
            _rl_last_c_pos -= prompt_invis_chars_first_line;    /* XXX - was wrap_offset */
 
index c905219370cbd41b957215e9768c4bb6665c78ed..7ddc26ae353d33956b936d8f470f39303aff2de6 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Mon Apr  6 14:13:28 EDT 2015
+.\"    Last Change: Sun May 24 18:01:17 EDT 2015
 .\"
-.TH HISTORY 3 "2014 April 6" "GNU History 6.3"
+.TH HISTORY 3 "2015 May 24" "GNU History 6.3"
 .\"
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
@@ -441,16 +441,11 @@ return a pointer to that entry.  If there is no previous entry, return
 a \fBNULL\fP pointer.
 
 .Fn1 "HIST_ENTRY *" next_history "void"
-If the current history offset is not already at the end of the history
-list, move the current history offset forward to the next history entry.
-If the incremented history offset refers to a valid history entry, return
-a pointer to that entry.
-If there is no next entry, as when the history offset before being
-incremented refers to the last valid entry in the history list, return
-a \fBNULL\fP pointer.
-If this function returns \fBNULL\fP, the current history offset when the
-function returns (possibly incremented as described above)
-is at the end of the history list.
+If the current history offset refers to a valid history entry,
+increment the current history offset.
+If the possibly-incremented history offset refers to a valid history
+entry, return a pointer to that entry;
+otherwise, return a \fBNULL\fP pointer.
 
 .SS Searching the History List
 
index ecae312c0ba3b30cb2af33c6c402ee72ec42eb3e..6deaeee265fc2b5734a51fbaee4b1f5e5e022338 100644 (file)
@@ -270,16 +270,11 @@ a @code{NULL} pointer.
 @end deftypefun
 
 @deftypefun {HIST_ENTRY *} next_history (void)
-If the current history offset is not already at the end of the history
-list, move the current history offset forward to the next history entry.
-If the incremented history offset refers to a valid history entry, return
-a pointer to that entry.
-If there is no next entry, as when the history offset before being
-incremented refers to the last valid entry in the history list, return
-a @code{NULL} pointer.
-If this function returns @code{NULL}, the current history offset when the
-function returns (possibly incremented as described above)
-is at the end of the history list.
+If the current history offset refers to a valid history entry,
+increment the current history offset.
+If the possibly-incremented history offset refers to a valid history
+entry, return a pointer to that entry;
+otherwise, return a @code{BNULL} pointer.
 @end deftypefun
 
 @node Searching the History List
index 7f29c68804bb00a276a4a613c809afda10b66e2d..d7a210194d7479e1ed88b0d98b0e927abf9a8e62 100644 (file)
@@ -4,7 +4,7 @@ Copyright (C) 1988-2015 Free Software Foundation, Inc.
 
 @set EDITION 6.4
 @set VERSION 6.4
-@set UPDATED 6 April 2015
-@set UPDATED-MONTH April 2015
+@set UPDATED 24 May 2015
+@set UPDATED-MONTH May 2015
 
-@set LASTCHANGE Mon Apr  6 14:13:14 EDT 2015
+@set LASTCHANGE Sun May 24 18:01:45 EDT 2015
index b2db99cc4a82f7b7b04db772db5811f39c4cf4ae..186443da803edaf44a5624eaf44d1f52793aad7e 100644 (file)
@@ -514,10 +514,6 @@ rl_getc (stream)
       FD_ZERO (&readfds);
       FD_SET (fileno (stream), &readfds);
       result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set);
-#  if 0
-      if (result < 0 && errno == EINTR)
-       goto handle_error;
-#  endif
 #endif
       if (result >= 0)
        result = read (fileno (stream), &c, sizeof (unsigned char));
index 0b0a32b90e2ac8328108fc070f0bd9ee13a45109..f0ecfb44ac3697b0bc39952eb92a31a1158385d4 100644 (file)
@@ -123,13 +123,47 @@ 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)
 
+/* Try and shortcut the printable ascii characters to cut down the number of
+   calls to a libc wcwidth() */
+static inline int
+_rl_wcwidth (wc)
+     wchar_t wc;
+{
+  switch (wc)
+    {
+    case ' ': case '!': case '"': case '#': case '%':
+    case '&': case '\'': case '(': case ')': case '*':
+    case '+': case ',': case '-': case '.': case '/':
+    case '0': case '1': case '2': case '3': case '4':
+    case '5': case '6': case '7': case '8': case '9':
+    case ':': case ';': case '<': case '=': case '>':
+    case '?':
+    case 'A': case 'B': case 'C': case 'D': case 'E':
+    case 'F': case 'G': case 'H': case 'I': case 'J':
+    case 'K': case 'L': case 'M': case 'N': case 'O':
+    case 'P': case 'Q': case 'R': case 'S': case 'T':
+    case 'U': case 'V': case 'W': case 'X': case 'Y':
+    case 'Z':
+    case '[': case '\\': case ']': case '^': case '_':
+    case 'a': case 'b': case 'c': case 'd': case 'e':
+    case 'f': case 'g': case 'h': case 'i': case 'j':
+    case 'k': case 'l': case 'm': case 'n': case 'o':
+    case 'p': case 'q': case 'r': case 's': case 't':
+    case 'u': case 'v': case 'w': case 'x': case 'y':
+    case 'z': case '{': case '|': case '}': case '~':
+      return 1;
+    default:
+      return wcwidth (wc);
+    }
+}
+
 /* 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))
+#  define WCWIDTH(wc)  ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : _rl_wcwidth(wc))
 #else
-#  define WCWIDTH(wc)  wcwidth(wc)
+#  define WCWIDTH(wc)  _rl_wcwidth(wc)
 #endif
 
 #if defined (WCWIDTH_BROKEN)
index d9f726a1321eada1a66f8e9d34c25eee45f074ec..15e2809a34f3a2316bd17a3b58a10dfddaa939e9 100644 (file)
@@ -545,6 +545,9 @@ extern int _rl_screenchars;
 extern int _rl_terminal_can_insert;
 extern int _rl_term_autowrap;
 
+/* text.c */
+extern int _rl_optimize_typeahead;
+
 /* undo.c */
 extern int _rl_doing_an_undo;
 extern int _rl_undo_group_level;
index 7f1f076dfcff4fee93e3465fe87747f518cd0125..f2bb22466c5ae3732f5d8f3e42730afc76216fd1 100644 (file)
@@ -71,6 +71,8 @@ static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *));
    rl_insert_text.  Text blocks larger than this are divided. */
 #define TEXT_COUNT_MAX 1024
 
+int _rl_optimize_typeahead = 1;        /* rl_insert tries to read typeahead */
+
 /* **************************************************************** */
 /*                                                                 */
 /*                     Insert and Delete                           */
@@ -890,8 +892,42 @@ int
 rl_insert (count, c)
      int count, c;
 {
-  return (rl_insert_mode == RL_IM_INSERT ? _rl_insert_char (count, c)
-                                        : _rl_overwrite_char (count, c));
+  int r, n, x;
+
+  r = (rl_insert_mode == RL_IM_INSERT) ? _rl_insert_char (count, c) : _rl_overwrite_char (count, c);
+
+  /* XXX -- attempt to batch-insert pending input that maps to self-insert */
+  x = 0;
+  n = (unsigned short)-2;
+  while (_rl_optimize_typeahead &&
+        (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
+        _rl_pushed_input_available () == 0 &&
+        _rl_input_queued (0) &&
+        (n = rl_read_key ()) > 0 &&
+        _rl_keymap[(unsigned char)n].type == ISFUNC &&
+        _rl_keymap[(unsigned char)n].function == rl_insert)
+    {
+      r = (rl_insert_mode == RL_IM_INSERT) ? _rl_insert_char (1, n) : _rl_overwrite_char (1, n);
+      /* _rl_insert_char keeps its own set of pending characters to compose a
+        complete multibyte character, and only returns 1 if it sees a character
+        that's part of a multibyte character but too short to complete one.  We
+        can try to read another character in the hopes that we will get the
+        next one or just punt.  Right now we try to read another character.
+        We don't want to call rl_insert_next if _rl_insert_char has already
+        stored the character in the pending_bytes array because that will
+        result in doubled input. */
+      n = (unsigned short)-2;
+      x++;             /* count of bytes of typeahead read, currently unused */
+      if (r == 1)      /* read partial multibyte character */
+       continue;
+      if (rl_done || r != 0)
+       break;
+    }
+
+  if (n != (unsigned short)-2)         /* -2 = sentinel value for having inserted N */
+    r = rl_execute_next (n);
+
+  return r;
 }
 
 /* Insert the next typed character verbatim. */
index b1711b8a9db92ce62a21d7e3e279b5f6d32bde8a..c12cbe981ed4a9a524c74ad428523019e6ae2637 100644 (file)
@@ -112,7 +112,7 @@ sh_modcase (string, pat, flags)
 #if defined (HANDLE_MULTIBYTE)
   wchar_t nwc;
   char mb[MB_LEN_MAX+1];
-  int mlen;
+  int mlen, mb_cur_max;
   size_t m;
   mbstate_t state;
 #endif
@@ -130,6 +130,7 @@ sh_modcase (string, pat, flags)
 
   start = 0;
   end = strlen (string);
+  mb_cur_max = MB_CUR_MAX;
 
   ret = (char *)xmalloc (2*end + 1);
   retind = 0;
@@ -209,7 +210,7 @@ sh_modcase (string, pat, flags)
 
       /* Can't short-circuit, some locales have multibyte upper and lower
         case equivalents of single-byte ascii characters (e.g., Turkish) */
-      if (MB_CUR_MAX == 1)
+      if (mb_cur_max == 1)
        {
 singlebyte:
          switch (nop)
index 3828164e48e898eb1b02a73a7e8cce409b540401..ff5b6f24337997b0e28b8fe54645b0ab26676076 100644 (file)
@@ -35,17 +35,18 @@ mbscasecmp (mbs1, mbs2)
     const char *mbs1;
     const char *mbs2;
 {
-  int len1, len2;
+  int len1, len2, mb_cur_max;
   wchar_t c1, c2, l1, l2;
 
   len1 = len2 = 0;
   /* Reset multibyte characters to their initial state.         */
   (void) mblen ((char *) NULL, 0);
 
+  mb_cur_max = MB_CUR_MAX;
   do
     {
-      len1 = mbtowc (&c1, mbs1, MB_CUR_MAX);
-      len2 = mbtowc (&c2, mbs2, MB_CUR_MAX);
+      len1 = mbtowc (&c1, mbs1, mb_cur_max);
+      len2 = mbtowc (&c2, mbs2, mb_cur_max);
 
       if (len1 == 0)
        return len2 == 0 ? 0 : -1;
index e0eae5dcc74ecf14fdaadb1f774b73ad44d389ea..711f768f1072b88d222b6fad7b3987a59101e4e0 100644 (file)
@@ -32,17 +32,18 @@ mbscmp (mbs1, mbs2)
     const char *mbs1;
     const char *mbs2;
 {
-  int len1, len2;
+  int len1, len2, mb_cur_max;
   wchar_t c1, c2;
 
   len1 = len2 = 0;
   /* Reset multibyte characters to their initial state.         */
   (void) mblen ((char *) NULL, 0);
 
+  mb_cur_max = MB_CUR_MAX;
   do
     {
-      len1 = mbtowc (&c1, mbs1, MB_CUR_MAX);
-      len2 = mbtowc (&c2, mbs2, MB_CUR_MAX);
+      len1 = mbtowc (&c1, mbs1, mb_cur_max);
+      len2 = mbtowc (&c2, mbs2, mb_cur_max);
 
       if (len1 == 0)
        return len2 == 0 ? 0 : -1;
index 042c9f14069bc27c2957148d2881e28d51f76cff..1bf68701e43abe5ccd7eaad7ba5b9b158d78f253 100644 (file)
@@ -43,10 +43,11 @@ mbstrlen (s)
 {
   size_t clen, nc;
   mbstate_t mbs = { 0 }, mbsbak = { 0 };
-  int f;
+  int f, mb_cur_max;
 
   nc = 0;
-  while (*s && (clen = (f = is_basic (*s)) ? 1 : mbrlen(s, MB_CUR_MAX, &mbs)) != 0)
+  mb_cur_max = MB_CUR_MAX;
+  while (*s && (clen = (f = is_basic (*s)) ? 1 : mbrlen(s, mb_cur_max, &mbs)) != 0)
     {
       if (MB_INVALIDCH(clen))
        {
@@ -71,13 +72,15 @@ mbsmbchar (s)
   char *t;
   size_t clen;
   mbstate_t mbs = { 0 };
+  int mb_cur_max;
 
+  mb_cur_max = MB_CUR_MAX;
   for (t = (char *)s; *t; t++)
     {
       if (is_basic (*t))
        continue;
 
-      clen = mbrlen (t, MB_CUR_MAX, &mbs);
+      clen = mbrlen (t, mb_cur_max, &mbs);
 
       if (clen == 0)
         return 0;
index 4f13ab399bd7dd59ee1ced3f6f3de3ae9d7dbe02..782a1f56cc75919b80d10ab7c56ad96ddd2183b7 100644 (file)
@@ -233,7 +233,7 @@ sh_backslash_quote (string, table, flags)
      char *table;
      int flags;
 {
-  int c;
+  int c, mb_cur_max;
   size_t slen;
   char *result, *r, *s, *backslash_table, *send;
   DECLARE_MBSTATE;
@@ -243,6 +243,8 @@ sh_backslash_quote (string, table, flags)
   result = (char *)xmalloc (2 * slen + 1);
 
   backslash_table = table ? table : (char *)bstab;
+  mb_cur_max = MB_CUR_MAX;
+
   for (r = result, s = string; s && (c = *s); s++)
     {
 #if defined (HANDLE_MULTIBYTE)
@@ -253,7 +255,7 @@ sh_backslash_quote (string, table, flags)
          *r++ = c;
          continue;
        }
-      if (MB_CUR_MAX > 1 && is_basic (c) == 0)
+      if (mb_cur_max > 1 && is_basic (c) == 0)
        {
          COPY_CHAR_P (r, s, send);
          s--;          /* compensate for auto-increment in loop above */
index 000118ac60322faf4920aa68317b0ea799ba3cd4..b4ddc9539c10709d90ef56e8262cbd63b3ed37b4 100644 (file)
@@ -803,7 +803,7 @@ print_if_command (if_command)
   newline ("fi");
 }
 
-#if defined (DPAREN_ARITHMETIC)
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
 void
 print_arith_command (arith_cmd_list)
      WORD_LIST *arith_cmd_list;
diff --git a/shell.c b/shell.c
index 2b3f0ca4101fdeed28b5a23fba6af28b87d74a47..aab2e21cdb6255108d1c23784cdaee6f93f3290b 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -262,7 +262,7 @@ static const struct {
 #if defined (RESTRICTED_SHELL)
   { "restricted", Int, &restricted, (char **)0x0 },
 #endif
-  { "verbose", Int, &echo_input_at_read, (char **)0x0 },
+  { "verbose", Int, &verbose_flag, (char **)0x0 },
   { "version", Int, &do_version, (char **)0x0 },
 #if defined (WORDEXP_OPTION)
   { "wordexp", Int, &wordexp_only, (char **)0x0 },
@@ -460,7 +460,7 @@ main (argc, argv, env)
 
   /* Find full word arguments first. */
   arg_index = parse_long_options (argv, arg_index, argc);
-
+  
   if (want_initial_help)
     {
       show_shell_usage (stdout, 1);
@@ -473,6 +473,8 @@ main (argc, argv, env)
       exit (EXECUTION_SUCCESS);
     }
 
+  echo_input_at_read = verbose_flag;   /* --verbose given */
+
   /* All done with full word options; do standard shell option parsing.*/
   this_command_name = shell_name;      /* for error reporting */
   arg_index = parse_shell_options (argv, arg_index, argc);
diff --git a/subst.c b/subst.c
index 388e58828013b20ae5263393c2ba4a605c35d7de..62308a578e93ef9991b38b9615720a76863bd794 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -2501,7 +2501,7 @@ list_string (string, separators, quoted)
        extract a word, stopping at a separator
        skip sequences of spc, tab, or nl as long as they are separators
      This obeys the field splitting rules in Posix.2. */
-  slen = (MB_CUR_MAX > 1) ? strlen (string) : 1;
+  slen = (MB_CUR_MAX > 1) ? STRLEN (string) : 1;
   for (result = (WORD_LIST *)NULL, sindex = 0; string[sindex]; )
     {
       /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim
@@ -2632,7 +2632,7 @@ get_word_from_string (stringp, separators, endptr)
   sindex = 0;
   /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim
      unless multibyte chars are possible. */
-  slen = (MB_CUR_MAX > 1) ? strlen (s) : 1;
+  slen = (MB_CUR_MAX > 1) ? STRLEN (s) : 1;
   current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);
 
   /* Set ENDPTR to the first character after the end of the word. */
@@ -8642,6 +8642,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
   int split_on_spaces;
   int tflag;
   int pflags;                  /* flags passed to param_expand */
+  int mb_cur_max;
 
   int assignoff;               /* If assignment, offset of `=' */
 
@@ -8678,9 +8679,11 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
   string = word->word;
   if (string == 0)
     goto finished_with_string;
+  mb_cur_max = MB_CUR_MAX;
+
   /* Don't need the string length for the SADD... and COPY_ macros unless
      multibyte characters are possible. */
-  string_size = (MB_CUR_MAX > 1) ? strlen (string) : 1;
+  string_size = (mb_cur_max > 1) ? strlen (string) : 1;
 
   if (contains_dollar_at)
     *contains_dollar_at = 0;
@@ -8702,7 +8705,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
        case CTLESC:
          sindex++;
 #if HANDLE_MULTIBYTE
-         if (MB_CUR_MAX > 1 && string[sindex])
+         if (mb_cur_max > 1 && string[sindex])
            {
              SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
            }
@@ -9210,10 +9213,10 @@ add_twochars:
              else
                {
 #if HANDLE_MULTIBYTE
-                 if (MB_CUR_MAX > 1)
+                 if (mb_cur_max > 1)
                    sindex--;
 
-                 if (MB_CUR_MAX > 1)
+                 if (mb_cur_max > 1)
                    {
                      SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
                    }