]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
changes for multibyte characters with intermediate state; small change to readline...
authorChet Ramey <chet.ramey@case.edu>
Wed, 28 Sep 2022 15:00:34 +0000 (11:00 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 28 Sep 2022 15:00:34 +0000 (11:00 -0400)
CWRU/CWRU.chlog
builtins/printf.def
configure
configure.ac
include/shmbutil.h
lib/readline/display.c
lib/sh/mbscasecmp.c
lib/sh/mbscmp.c
mailcheck.c
print_cmd.c
subst.c

index da6d4aa1c36207626e9c7dc7cba546dcb196e3ae..967239559fdbe1c73c6c1448f5a40c08a9294e31 100644 (file)
@@ -3950,3 +3950,43 @@ lib/readline/history.c
                                   9/23
                                   ----
 [bash-5.2 frozen]
+
+                                  9/26
+                                  ----
+[bash-5.2 released]
+
+                                  9/27
+                                  ----
+mailcheck.c
+       - time_to_check_mail: don't bother if we're in the middle of readline
+         completion or command dispatching.
+         From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1019462
+
+lib/readline/display.c
+       - rl_forced_update_display: use memset to clear out visible_line
+         instead of trying to use a loop; line_size is the size.
+         Report from <srobertson@peratonlabs.com>
+
+print_cmd.c
+       - indirection_level_string: use MBRLEN and an initialized mbstate_t
+         object to avoid altering an internal mbstate_t.
+         From Koichi Murase <myoga.murase@gmail.com>
+
+subst.c
+       - string_extract_verbatim: use an explicit mbstate_t object and pass
+         it to MBRLEN and mbrtowc to avoid altering the state that
+         ADVANCE_CHAR is using.
+         From Koichi Murase <myoga.murase@gmail.com>
+       - setifs: use an explicit mbstate_t object and pass it to MBRLEN so
+         to avoid altering an internal mbstate_t.
+         From Koichi Murase <myoga.murase@gmail.com>
+
+builtins/printf.def
+       - asciicode: use an explicit mbstate_t object and pass it to mbrtowc
+         to avoid using an incorrect internal mbstate_t
+         From Koichi Murase <myoga.murase@gmail.com>
+
+lib/sh/{mbscasecmp,mbscmp}.c
+       - mbscasecmp,mbscmp: use different mbstate_t objects for the different
+         strings so they don't affect each others' intermediate mbstate.
+         From Koichi Murase <myoga.murase@gmail.com>
index 84658c3990c822bccb146ecf964af0ddb4398b7d..29a94eaf88d85d754c9a6f0b48bf4c853ce5a997 100644 (file)
@@ -1,7 +1,7 @@
 This file is printf.def, from which is created printf.c.
 It implements the builtin "printf" in Bash.
 
-Copyright (C) 1997-2021 Free Software Foundation, Inc.
+Copyright (C) 1997-2022 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -1343,7 +1343,7 @@ asciicode ()
 #if defined (HANDLE_MULTIBYTE)
   slen = strlen (garglist->word->word+1);
   wc = 0;
-  mblength = mbtowc (&wc, garglist->word->word+1, slen);
+  mblength = mbrtowc (&wc, garglist->word->word+1, slen, &state);
   if (mblength > 0)
     ch = wc;           /* XXX */
   else
index c591dc1a282c0468c3308cdcd3d16627b68c6c82..28e09134992d85d81e603dfecb7a55755096a378 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
 #! /bin/sh
-# From configure.ac for Bash 5.2, version 5.045.
+# From configure.ac for Bash 5.2, version 5.046.
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for bash 5.2-rc4.
+# Generated by GNU Autoconf 2.71 for bash 5.2-maint.
 #
 # Report bugs to <bug-bash@gnu.org>.
 #
@@ -612,8 +612,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='bash'
 PACKAGE_TARNAME='bash'
-PACKAGE_VERSION='5.2-rc4'
-PACKAGE_STRING='bash 5.2-rc4'
+PACKAGE_VERSION='5.2-maint'
+PACKAGE_STRING='bash 5.2-maint'
 PACKAGE_BUGREPORT='bug-bash@gnu.org'
 PACKAGE_URL=''
 
@@ -1467,7 +1467,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 bash 5.2-rc4 to adapt to many kinds of systems.
+\`configure' configures bash 5.2-maint to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1533,7 +1533,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of bash 5.2-rc4:";;
+     short | recursive ) echo "Configuration of bash 5.2-maint:";;
    esac
   cat <<\_ACEOF
 
@@ -1740,7 +1740,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-bash configure 5.2-rc4
+bash configure 5.2-maint
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2397,7 +2397,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by bash $as_me 5.2-rc4, which was
+It was created by bash $as_me 5.2-maint, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -3176,7 +3176,7 @@ ac_config_headers="$ac_config_headers config.h"
 
 
 BASHVERS=5.2
-RELSTATUS=rc4
+RELSTATUS=maint
 
 case "$RELSTATUS" in
 alp*|bet*|dev*|rc*|releng*|maint*)     DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
@@ -22369,7 +22369,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by bash $as_me 5.2-rc4, which was
+This file was extended by bash $as_me 5.2-maint, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -22437,7 +22437,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-bash config.status 5.2-rc4
+bash config.status 5.2-maint
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
index 6335742bac06a8818866f496100c0d0fb58480f9..4a454dea8949b5fb3bd548c9bc7b574c880c1c32 100644 (file)
@@ -21,10 +21,10 @@ 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 5.2, version 5.045])dnl
+AC_REVISION([for Bash 5.2, version 5.046])dnl
 
 define(bashvers, 5.2)
-define(relstatus, rc4)
+define(relstatus, maint)
 
 AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org])
 
index 0f711eab73f28944d92bfe350ddf5c8ab79a1829..24f9c4622f50193b117420fba988e25c04b6139a 100644 (file)
@@ -1,6 +1,6 @@
 /* shmbutil.h -- utility functions for multibyte characters. */
 
-/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2022 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
index c1135ec59294a394e8b852b37c2e4d420a3dca87..df9d74925772f1835783a8a438dce98ffaca9e73 100644 (file)
@@ -684,7 +684,7 @@ init_line_structures (int minsize)
       if (line_size > minsize)
        minsize = line_size;
     }
-   realloc_line (minsize); 
+  realloc_line (minsize); 
 
   if (vis_lbreaks == 0)
     {
@@ -2681,13 +2681,11 @@ int
 rl_forced_update_display (void)
 {
   register char *temp;
+  register int tlen;
 
   if (visible_line)
-    {
-      temp = visible_line;
-      while (*temp)
-       *temp++ = '\0';
-    }
+    memset (visible_line, 0, line_size);
+
   rl_on_new_line ();
   forced_display++;
   (*rl_redisplay_function) ();
index 0ab956055cbae268a03f508d9c1cd82c6b1f2049..bb94f183523734eb53bd77c7d0a85f84c0570a9a 100644 (file)
@@ -1,6 +1,6 @@
 /* mbscasecmp - case-insensitive multibyte string comparison. */
 
-/* Copyright (C) 2009-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2009-2022 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -37,16 +37,15 @@ mbscasecmp (mbs1, mbs2)
 {
   int len1, len2, mb_cur_max;
   wchar_t c1, c2, l1, l2;
+  mbstate_t state1 = { 0 }, state2 = { 0 };
 
   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 = mbrtowc (&c1, mbs1, mb_cur_max, &state1);
+      len2 = mbrtowc (&c2, mbs2, mb_cur_max, &state2);
 
       if (len1 == 0)
        return len2 == 0 ? 0 : -1;
index c7c8443578f1ea28232590460a5ef99e386bd7d6..f475c538e9ee47493cfb060da8e3455bfa6ae161 100644 (file)
@@ -1,6 +1,6 @@
 /* mbscmp - multibyte string comparison. */
 
-/* Copyright (C) 1995-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2022 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -38,16 +38,15 @@ mbscmp (mbs1, mbs2)
 {
   int len1, len2, mb_cur_max;
   wchar_t c1, c2;
+  mbstate_t state1 = { 0 }, state2 = { 0 };
 
   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 = mbrtowc (&c1, mbs1, mb_cur_max, &state1);
+      len2 = mbrtowc (&c2, mbs2, mb_cur_max, &state2);
 
       if (len1 == 0)
        return len2 == 0 ? 0 : -1;
index 4a11143cc83b3d5d7d01623ee12ce5f3cb8268ea..fe335e7b290035d9d1678f795bb96b2021f93aeb 100644 (file)
 #include "mailcheck.h"
 #include <tilde/tilde.h>
 
+#if defined (READLINE)
+# include <readline/readline.h>
+#endif
+
 /* Values for flags word in struct _fileinfo */
 #define MBOX_INITIALIZED       0x01
 
@@ -88,6 +92,11 @@ time_to_check_mail ()
   time_t now;
   intmax_t seconds;
 
+#if defined (READLINE)
+  if (RL_ISSTATE (RL_STATE_COMPLETING|RL_STATE_DISPATCHING))
+    return (0);
+#endif
+
   temp = get_string_value ("MAILCHECK");
 
   /* Negative number, or non-numbers (such as empty string) cause no
index eef9bb6a051798480205770662074cfce789cb71..406417bee207dbdecf3bf21d9402a18a0d422a8f 100644 (file)
@@ -451,6 +451,7 @@ indirection_level_string ()
   char *ps4;
   char ps4_firstc[MB_LEN_MAX+1];
   int ps4_firstc_len, ps4_len, ineed, old;
+  DECLARE_MBSTATE;
 
   ps4 = get_string_value ("PS4");
   if (indirection_string == 0)
@@ -473,7 +474,7 @@ indirection_level_string ()
 
 #if defined (HANDLE_MULTIBYTE)
   ps4_len = strnlen (ps4, MB_CUR_MAX);
-  ps4_firstc_len = MBLEN (ps4, ps4_len);
+  ps4_firstc_len = MBRLEN (ps4, ps4_len, &state);
   if (ps4_firstc_len == 1 || ps4_firstc_len == 0 || ps4_firstc_len < 0)
     {
       ps4_firstc[0] = ps4[0];
diff --git a/subst.c b/subst.c
index d9feabca9ec3bc0c91ea79c70a0608c391e095e8..89e40688f4838ff675011474c4d7ce507a3d8adb 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -1173,6 +1173,7 @@ string_extract_verbatim (string, slen, sindex, charlist, flags)
   register int i;
 #if defined (HANDLE_MULTIBYTE)
   wchar_t *wcharlist;
+  mbstate_t mbstmp;
 #endif
   int c;
   char *temp;
@@ -1226,11 +1227,15 @@ string_extract_verbatim (string, slen, sindex, charlist, flags)
       if (locale_utf8locale && slen > i && UTF8_SINGLEBYTE (string[i]))
        mblength = (string[i] != 0) ? 1 : 0;
       else
-       mblength = MBLEN (string + i, slen - i);
+       {
+         mbstmp = state;
+         mblength = MBRLEN (string + i, slen - i, &mbstmp);
+       }
       if (mblength > 1)
        {
          wchar_t wc;
-         mblength = mbtowc (&wc, string + i, slen - i);
+         mbstmp = state;
+         mblength = mbrtowc (&wc, string + i, slen - i, &mbstmp);
          if (MB_INVALIDCH (mblength))
            {
              if (MEMBER (c, charlist))
@@ -12020,8 +12025,9 @@ setifs (v)
       else
        {
          size_t ifs_len;
+         DECLARE_MBSTATE;
          ifs_len = strnlen (ifs_value, MB_CUR_MAX);
-         ifs_firstc_len = MBLEN (ifs_value, ifs_len);
+         ifs_firstc_len = MBRLEN (ifs_value, ifs_len, &state);
        }
       if (ifs_firstc_len == 1 || ifs_firstc_len == 0 || MB_INVALIDCH (ifs_firstc_len))
        {