mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.1314: :messages behavior depends on 'fileformat' of current buffer
Problem: :messages behavior depends on 'fileformat' of current buffer. Solution: Pass the buffer pointer to where it is used. (Mirko Ceroni, closes #11995)
This commit is contained in:
parent
ce3189d56e
commit
1d87e11a1e
@ -523,19 +523,28 @@ transchar_buf(buf_T *buf, int c)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Like transchar(), but called with a byte instead of a character. Checks
|
* Like transchar(), but called with a byte instead of a character. Checks
|
||||||
* for an illegal UTF-8 byte.
|
* for an illegal UTF-8 byte. Uses 'fileformat' of the current buffer.
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
transchar_byte(int c)
|
transchar_byte(int c)
|
||||||
{
|
{
|
||||||
if (enc_utf8 && c >= 0x80)
|
return transchar_byte_buf(curbuf, c);
|
||||||
{
|
|
||||||
transchar_nonprint(curbuf, transchar_charbuf, c);
|
|
||||||
return transchar_charbuf;
|
|
||||||
}
|
|
||||||
return transchar(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
|
* Convert non-printable character to two or more printable characters in
|
||||||
* "charbuf[]". "charbuf" needs to be able to hold five bytes.
|
* "charbuf[]". "charbuf" needs to be able to hold five bytes.
|
||||||
@ -546,7 +555,7 @@ transchar_nonprint(buf_T *buf, char_u *charbuf, int c)
|
|||||||
{
|
{
|
||||||
if (c == NL)
|
if (c == NL)
|
||||||
c = NUL; // we use newline in place of a NUL
|
c = NUL; // we use newline in place of a NUL
|
||||||
else if (c == CAR && get_fileformat(buf) == EOL_MAC)
|
else if (buf != NULL && c == CAR && get_fileformat(buf) == EOL_MAC)
|
||||||
c = NL; // we use CR in place of NL in this case
|
c = NL; // we use CR in place of NL in this case
|
||||||
|
|
||||||
if (dy_flags & DY_UHEX) // 'display' has "uhex"
|
if (dy_flags & DY_UHEX) // 'display' has "uhex"
|
||||||
|
@ -902,7 +902,7 @@ internal_error_no_abort(char *where)
|
|||||||
void
|
void
|
||||||
emsg_invreg(int name)
|
emsg_invreg(int name)
|
||||||
{
|
{
|
||||||
semsg(_(e_invalid_register_name_str), transchar(name));
|
semsg(_(e_invalid_register_name_str), transchar_buf(NULL, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
@ -1601,7 +1601,7 @@ msg_outtrans_one(char_u *p, int attr)
|
|||||||
msg_outtrans_len_attr(p, l, attr);
|
msg_outtrans_len_attr(p, l, attr);
|
||||||
return p + l;
|
return p + l;
|
||||||
}
|
}
|
||||||
msg_puts_attr((char *)transchar_byte(*p), attr);
|
msg_puts_attr((char *)transchar_byte_buf(NULL, *p), attr);
|
||||||
return p + 1;
|
return p + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1658,7 +1658,7 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
|
|||||||
msg_puts_attr_len((char *)plain_start,
|
msg_puts_attr_len((char *)plain_start,
|
||||||
(int)(str - plain_start), attr);
|
(int)(str - plain_start), attr);
|
||||||
plain_start = str + mb_l;
|
plain_start = str + mb_l;
|
||||||
msg_puts_attr((char *)transchar(c),
|
msg_puts_attr((char *)transchar_buf(NULL, c),
|
||||||
attr == 0 ? HL_ATTR(HLF_8) : attr);
|
attr == 0 ? HL_ATTR(HLF_8) : attr);
|
||||||
retval += char2cells(c);
|
retval += char2cells(c);
|
||||||
}
|
}
|
||||||
@ -1667,7 +1667,7 @@ msg_outtrans_len_attr(char_u *msgstr, int len, int attr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = transchar_byte(*str);
|
s = transchar_byte_buf(NULL, *str);
|
||||||
if (s[1] != NUL)
|
if (s[1] != NUL)
|
||||||
{
|
{
|
||||||
// unprintable char: print the printable chars so far and the
|
// unprintable char: print the printable chars so far and the
|
||||||
@ -1753,7 +1753,7 @@ msg_outtrans_special(
|
|||||||
text = (char *)str2special(&str, from, FALSE);
|
text = (char *)str2special(&str, from, FALSE);
|
||||||
if (text[0] != NUL && text[1] == NUL)
|
if (text[0] != NUL && text[1] == NUL)
|
||||||
// single-byte character or illegal byte
|
// single-byte character or illegal byte
|
||||||
text = (char *)transchar_byte((char_u)text[0]);
|
text = (char *)transchar_byte_buf(NULL, (char_u)text[0]);
|
||||||
len = vim_strsize((char_u *)text);
|
len = vim_strsize((char_u *)text);
|
||||||
if (maxlen > 0 && retval + len >= maxlen)
|
if (maxlen > 0 && retval + len >= maxlen)
|
||||||
break;
|
break;
|
||||||
@ -2021,7 +2021,7 @@ msg_prt_line(char_u *s, int list)
|
|||||||
else if (c != NUL && (n = byte2cells(c)) > 1)
|
else if (c != NUL && (n = byte2cells(c)) > 1)
|
||||||
{
|
{
|
||||||
n_extra = n - 1;
|
n_extra = n - 1;
|
||||||
p_extra = transchar_byte(c);
|
p_extra = transchar_byte_buf(NULL, c);
|
||||||
c_extra = NUL;
|
c_extra = NUL;
|
||||||
c_final = NUL;
|
c_final = NUL;
|
||||||
c = *p_extra++;
|
c = *p_extra++;
|
||||||
|
@ -7,6 +7,7 @@ char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen);
|
|||||||
char_u *transchar(int c);
|
char_u *transchar(int c);
|
||||||
char_u *transchar_buf(buf_T *buf, int c);
|
char_u *transchar_buf(buf_T *buf, int c);
|
||||||
char_u *transchar_byte(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_nonprint(buf_T *buf, char_u *charbuf, int c);
|
||||||
void transchar_hex(char_u *buf, int c);
|
void transchar_hex(char_u *buf, int c);
|
||||||
int byte2cells(int b);
|
int byte2cells(int b);
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1314,
|
||||||
/**/
|
/**/
|
||||||
1313,
|
1313,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user