@@ -499,18 +499,24 @@ str_foldcase(
499499 * Also doesn't work for the first byte of a multi-byte, "c" must be a
500500 * character!
501501 */
502- static char_u transchar_buf [7 ];
502+ static char_u transchar_charbuf [7 ];
503503
504504 char_u *
505505transchar (int c )
506+ {
507+ return transchar_buf (curbuf , c );
508+ }
509+
510+ char_u *
511+ transchar_buf (buf_T * buf , int c )
506512{
507513 int i ;
508514
509515 i = 0 ;
510516 if (IS_SPECIAL (c )) // special key code, display as ~@ char
511517 {
512- transchar_buf [0 ] = '~' ;
513- transchar_buf [1 ] = '@' ;
518+ transchar_charbuf [0 ] = '~' ;
519+ transchar_charbuf [1 ] = '@' ;
514520 i = 2 ;
515521 c = K_SECOND (c );
516522 }
@@ -524,12 +530,12 @@ transchar(int c)
524530 )) || (c < 256 && vim_isprintc_strict (c )))
525531 {
526532 // printable character
527- transchar_buf [i ] = c ;
528- transchar_buf [i + 1 ] = NUL ;
533+ transchar_charbuf [i ] = c ;
534+ transchar_charbuf [i + 1 ] = NUL ;
529535 }
530536 else
531- transchar_nonprint (transchar_buf + i , c );
532- return transchar_buf ;
537+ transchar_nonprint (buf , transchar_charbuf + i , c );
538+ return transchar_charbuf ;
533539}
534540
535541/*
@@ -541,27 +547,27 @@ transchar_byte(int c)
541547{
542548 if (enc_utf8 && c >= 0x80 )
543549 {
544- transchar_nonprint (transchar_buf , c );
545- return transchar_buf ;
550+ transchar_nonprint (curbuf , transchar_charbuf , c );
551+ return transchar_charbuf ;
546552 }
547553 return transchar (c );
548554}
549555
550556/*
551557 * Convert non-printable character to two or more printable characters in
552- * "buf[]". "buf " needs to be able to hold five bytes.
558+ * "buf[]". "charbuf " needs to be able to hold five bytes.
553559 * Does NOT work for multi-byte characters, c must be <= 255.
554560 */
555561 void
556- transchar_nonprint (char_u * buf , int c )
562+ transchar_nonprint (buf_T * buf , char_u * charbuf , int c )
557563{
558564 if (c == NL )
559565 c = NUL ; // we use newline in place of a NUL
560- else if (c == CAR && get_fileformat (curbuf ) == EOL_MAC )
566+ else if (c == CAR && get_fileformat (buf ) == EOL_MAC )
561567 c = NL ; // we use CR in place of NL in this case
562568
563569 if (dy_flags & DY_UHEX ) // 'display' has "uhex"
564- transchar_hex (buf , c );
570+ transchar_hex (charbuf , c );
565571
566572#ifdef EBCDIC
567573 // For EBCDIC only the characters 0-63 and 255 are not printable
@@ -570,35 +576,35 @@ transchar_nonprint(char_u *buf, int c)
570576 else if (c <= 0x7f ) // 0x00 - 0x1f and 0x7f
571577#endif
572578 {
573- buf [0 ] = '^' ;
579+ charbuf [0 ] = '^' ;
574580#ifdef EBCDIC
575581 if (c == DEL )
576- buf [1 ] = '?' ; // DEL displayed as ^?
582+ charbuf [1 ] = '?' ; // DEL displayed as ^?
577583 else
578- buf [1 ] = CtrlChar (c );
584+ charbuf [1 ] = CtrlChar (c );
579585#else
580- buf [1 ] = c ^ 0x40 ; // DEL displayed as ^?
586+ charbuf [1 ] = c ^ 0x40 ; // DEL displayed as ^?
581587#endif
582588
583- buf [2 ] = NUL ;
589+ charbuf [2 ] = NUL ;
584590 }
585591 else if (enc_utf8 && c >= 0x80 )
586592 {
587- transchar_hex (buf , c );
593+ transchar_hex (charbuf , c );
588594 }
589595#ifndef EBCDIC
590596 else if (c >= ' ' + 0x80 && c <= '~' + 0x80 ) // 0xa0 - 0xfe
591597 {
592- buf [0 ] = '|' ;
593- buf [1 ] = c - 0x80 ;
594- buf [2 ] = NUL ;
598+ charbuf [0 ] = '|' ;
599+ charbuf [1 ] = c - 0x80 ;
600+ charbuf [2 ] = NUL ;
595601 }
596602#else
597603 else if (c < 64 )
598604 {
599- buf [0 ] = '~' ;
600- buf [1 ] = MetaChar (c );
601- buf [2 ] = NUL ;
605+ charbuf [0 ] = '~' ;
606+ charbuf [1 ] = MetaChar (c );
607+ charbuf [2 ] = NUL ;
602608 }
603609#endif
604610 else // 0x80 - 0x9f and 0xff
@@ -607,13 +613,13 @@ transchar_nonprint(char_u *buf, int c)
607613 * TODO: EBCDIC I don't know what to do with this chars, so I display
608614 * them as '~?' for now
609615 */
610- buf [0 ] = '~' ;
616+ charbuf [0 ] = '~' ;
611617#ifdef EBCDIC
612- buf [1 ] = '?' ; // 0xff displayed as ~?
618+ charbuf [1 ] = '?' ; // 0xff displayed as ~?
613619#else
614- buf [1 ] = (c - 0x80 ) ^ 0x40 ; // 0xff displayed as ~?
620+ charbuf [1 ] = (c - 0x80 ) ^ 0x40 ; // 0xff displayed as ~?
615621#endif
616- buf [2 ] = NUL ;
622+ charbuf [2 ] = NUL ;
617623 }
618624}
619625
0 commit comments