Patch 9.0.1314
Problem:    :messages behavior depends on 'fileformat' of current buffer.
Solution:   Pass the buffer pointer to where it is used. (Mirko Ceroni,
            closes #11995)
Files:      src/charset.c, src/proto/charset.pro, src/message.c


*** ../vim-9.0.1313/src/charset.c       2023-02-12 18:03:39.158310875 +0000
--- src/charset.c       2023-02-16 15:02:23.305700614 +0000
***************
*** 523,541 ****
  
  /*
   * Like transchar(), but called with a byte instead of a character.  Checks
!  * for an illegal UTF-8 byte.
   */
      char_u *
  transchar_byte(int c)
  {
      if (enc_utf8 && c >= 0x80)
      {
!       transchar_nonprint(curbuf, transchar_charbuf, c);
        return transchar_charbuf;
      }
!     return transchar(c);
  }
- 
  /*
   * Convert non-printable character to two or more printable characters in
   * "charbuf[]".  "charbuf" needs to be able to hold five bytes.
--- 523,550 ----
  
  /*
   * Like transchar(), but called with a byte instead of a character.  Checks
!  * for an illegal UTF-8 byte.  Uses 'fileformat' of the current buffer.
   */
      char_u *
  transchar_byte(int c)
  {
+     return transchar_byte_buf(curbuf, c);
+ }
+ 
+ /*
+  * Like transchar_buf(), but called with a byte instead of a character.  
Checks
+  * for an illegal UTF-8 byte.  Uses 'fileformat' of "buf", unless it is NULL.
+  */
+     char_u *
+ transchar_byte_buf(buf_T *buf, int c)
+ {
      if (enc_utf8 && c >= 0x80)
      {
!       transchar_nonprint(buf, transchar_charbuf, c);
        return transchar_charbuf;
      }
!     return transchar_buf(buf, c);
  }
  /*
   * Convert non-printable character to two or more printable characters in
   * "charbuf[]".  "charbuf" needs to be able to hold five bytes.
***************
*** 546,552 ****
  {
      if (c == NL)
        c = NUL;                // we use newline in place of a NUL
!     else if (c == CAR && get_fileformat(buf) == EOL_MAC)
        c = NL;                 // we use CR in place of  NL in this case
  
      if (dy_flags & DY_UHEX)           // 'display' has "uhex"
--- 555,561 ----
  {
      if (c == NL)
        c = NUL;                // we use newline in place of a NUL
!     else if (buf != NULL && c == CAR && get_fileformat(buf) == EOL_MAC)
        c = NL;                 // we use CR in place of  NL in this case
  
      if (dy_flags & DY_UHEX)           // 'display' has "uhex"
*** ../vim-9.0.1313/src/proto/charset.pro       2022-10-14 20:09:00.895207512 
+0100
--- src/proto/charset.pro       2023-02-16 14:56:30.633974041 +0000
***************
*** 7,12 ****
--- 7,13 ----
  char_u *transchar(int c);
  char_u *transchar_buf(buf_T *buf, int c);
  char_u *transchar_byte(int c);
+ char_u *transchar_byte_buf(buf_T *buf, int c);
  void transchar_nonprint(buf_T *buf, char_u *charbuf, int c);
  void transchar_hex(char_u *buf, int c);
  int byte2cells(int b);
*** ../vim-9.0.1313/src/message.c       2023-02-01 13:11:11.714991151 +0000
--- src/message.c       2023-02-16 14:59:40.525823117 +0000
***************
*** 902,908 ****
      void
  emsg_invreg(int name)
  {
!     semsg(_(e_invalid_register_name_str), transchar(name));
  }
  
  #if defined(FEAT_EVAL) || defined(PROTO)
--- 902,908 ----
      void
  emsg_invreg(int name)
  {
!     semsg(_(e_invalid_register_name_str), transchar_buf(NULL, name));
  }
  
  #if defined(FEAT_EVAL) || defined(PROTO)
***************
*** 1601,1607 ****
        msg_outtrans_len_attr(p, l, attr);
        return p + l;
      }
!     msg_puts_attr((char *)transchar_byte(*p), attr);
      return p + 1;
  }
  
--- 1601,1607 ----
        msg_outtrans_len_attr(p, l, attr);
        return p + l;
      }
!     msg_puts_attr((char *)transchar_byte_buf(NULL, *p), attr);
      return p + 1;
  }
  
***************
*** 1658,1664 ****
                    msg_puts_attr_len((char *)plain_start,
                                               (int)(str - plain_start), attr);
                plain_start = str + mb_l;
!               msg_puts_attr((char *)transchar(c),
                                            attr == 0 ? HL_ATTR(HLF_8) : attr);
                retval += char2cells(c);
            }
--- 1658,1664 ----
                    msg_puts_attr_len((char *)plain_start,
                                               (int)(str - plain_start), attr);
                plain_start = str + mb_l;
!               msg_puts_attr((char *)transchar_buf(NULL, c),
                                            attr == 0 ? HL_ATTR(HLF_8) : attr);
                retval += char2cells(c);
            }
***************
*** 1667,1673 ****
        }
        else
        {
!           s = transchar_byte(*str);
            if (s[1] != NUL)
            {
                // unprintable char: print the printable chars so far and the
--- 1667,1673 ----
        }
        else
        {
!           s = transchar_byte_buf(NULL, *str);
            if (s[1] != NUL)
            {
                // unprintable char: print the printable chars so far and the
***************
*** 1753,1759 ****
            text = (char *)str2special(&str, from, FALSE);
        if (text[0] != NUL && text[1] == NUL)
            // single-byte character or illegal byte
!           text = (char *)transchar_byte((char_u)text[0]);
        len = vim_strsize((char_u *)text);
        if (maxlen > 0 && retval + len >= maxlen)
            break;
--- 1753,1759 ----
            text = (char *)str2special(&str, from, FALSE);
        if (text[0] != NUL && text[1] == NUL)
            // single-byte character or illegal byte
!           text = (char *)transchar_byte_buf(NULL, (char_u)text[0]);
        len = vim_strsize((char_u *)text);
        if (maxlen > 0 && retval + len >= maxlen)
            break;
***************
*** 2021,2027 ****
            else if (c != NUL && (n = byte2cells(c)) > 1)
            {
                n_extra = n - 1;
!               p_extra = transchar_byte(c);
                c_extra = NUL;
                c_final = NUL;
                c = *p_extra++;
--- 2021,2027 ----
            else if (c != NUL && (n = byte2cells(c)) > 1)
            {
                n_extra = n - 1;
!               p_extra = transchar_byte_buf(NULL, c);
                c_extra = NUL;
                c_final = NUL;
                c = *p_extra++;
*** ../vim-9.0.1313/src/version.c       2023-02-15 19:13:39.363474050 +0000
--- src/version.c       2023-02-16 14:58:30.049877966 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1314,
  /**/

-- 
Statistics say that you can have a baby per month on average:
Just get nine women pregnant.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230216150343.E7D491C0E92%40moolenaar.net.

Raspunde prin e-mail lui