summaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorcero1988 <mirkoceroni@mirkoceroni.it>2023-02-16 15:03:12 +0000
committerBram Moolenaar <Bram@vim.org>2023-02-16 15:03:12 +0000
commit1d87e11a1ef201b26ed87585fba70182ad0c468a (patch)
tree283b5f6b6856a18af08196375d4613a8303148d8 /src/charset.c
parentce3189d56e867a2ffc077893b62f530d5b09150f (diff)
patch 9.0.1314: :messages behavior depends on 'fileformat' of current bufferv9.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)
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/charset.c b/src/charset.c
index 3ce95c7f41..a8c20f9eb3 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -523,19 +523,28 @@ transchar_buf(buf_T *buf, int c)
/*
* 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 *
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(curbuf, transchar_charbuf, c);
+ transchar_nonprint(buf, transchar_charbuf, c);
return transchar_charbuf;
}
- return transchar(c);
+ 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,7 +555,7 @@ transchar_nonprint(buf_T *buf, char_u *charbuf, int c)
{
if (c == NL)
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
if (dy_flags & DY_UHEX) // 'display' has "uhex"