comparison src/charset.c @ 31964:c0a9bc376b54 v9.0.1314

patch 9.0.1314: :messages behavior depends on 'fileformat' of current buffer Commit: https://github.com/vim/vim/commit/1d87e11a1ef201b26ed87585fba70182ad0c468a Author: cero1988 <mirkoceroni@mirkoceroni.it> Date: Thu Feb 16 15:03:12 2023 +0000 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)
author Bram Moolenaar <Bram@vim.org>
date Thu, 16 Feb 2023 16:15:04 +0100
parents 05414bdc5c2c
children 27ab829631df
comparison
equal deleted inserted replaced
31963:da67a47e2c2c 31964:c0a9bc376b54
521 return transchar_charbuf; 521 return transchar_charbuf;
522 } 522 }
523 523
524 /* 524 /*
525 * Like transchar(), but called with a byte instead of a character. Checks 525 * Like transchar(), but called with a byte instead of a character. Checks
526 * for an illegal UTF-8 byte. 526 * for an illegal UTF-8 byte. Uses 'fileformat' of the current buffer.
527 */ 527 */
528 char_u * 528 char_u *
529 transchar_byte(int c) 529 transchar_byte(int c)
530 { 530 {
531 return transchar_byte_buf(curbuf, c);
532 }
533
534 /*
535 * Like transchar_buf(), but called with a byte instead of a character. Checks
536 * for an illegal UTF-8 byte. Uses 'fileformat' of "buf", unless it is NULL.
537 */
538 char_u *
539 transchar_byte_buf(buf_T *buf, int c)
540 {
531 if (enc_utf8 && c >= 0x80) 541 if (enc_utf8 && c >= 0x80)
532 { 542 {
533 transchar_nonprint(curbuf, transchar_charbuf, c); 543 transchar_nonprint(buf, transchar_charbuf, c);
534 return transchar_charbuf; 544 return transchar_charbuf;
535 } 545 }
536 return transchar(c); 546 return transchar_buf(buf, c);
537 } 547 }
538
539 /* 548 /*
540 * Convert non-printable character to two or more printable characters in 549 * Convert non-printable character to two or more printable characters in
541 * "charbuf[]". "charbuf" needs to be able to hold five bytes. 550 * "charbuf[]". "charbuf" needs to be able to hold five bytes.
542 * Does NOT work for multi-byte characters, c must be <= 255. 551 * Does NOT work for multi-byte characters, c must be <= 255.
543 */ 552 */
544 void 553 void
545 transchar_nonprint(buf_T *buf, char_u *charbuf, int c) 554 transchar_nonprint(buf_T *buf, char_u *charbuf, int c)
546 { 555 {
547 if (c == NL) 556 if (c == NL)
548 c = NUL; // we use newline in place of a NUL 557 c = NUL; // we use newline in place of a NUL
549 else if (c == CAR && get_fileformat(buf) == EOL_MAC) 558 else if (buf != NULL && c == CAR && get_fileformat(buf) == EOL_MAC)
550 c = NL; // we use CR in place of NL in this case 559 c = NL; // we use CR in place of NL in this case
551 560
552 if (dy_flags & DY_UHEX) // 'display' has "uhex" 561 if (dy_flags & DY_UHEX) // 'display' has "uhex"
553 transchar_hex(charbuf, c); 562 transchar_hex(charbuf, c);
554 563