diff --git a/src/chars.c b/src/chars.c index 97ed921b1759ac33055549aeeba681d78b26c4e2..9e839036df9641773388c891e6f684541599e2fb 100644 --- a/src/chars.c +++ b/src/chars.c @@ -253,27 +253,20 @@ wchar_t control_wrep(wchar_t wc) } #endif -/* c is a multibyte control character. It displays as ^@, ^?, or ^[ch], - * where ch is (c + 64). We return that single-byte character. */ -char *control_mbrep(const char *c, char *crep, int *crep_len) +/* Return the visible representation of multibyte control character c. */ +char control_mbrep(const char *c) { - assert(c != NULL && crep != NULL && crep_len != NULL); + assert(c != NULL); #ifdef ENABLE_UTF8 if (use_utf8) { if (0 <= c[0] && c[0] <= 127) - *crep = control_rep(c[0]); + return control_rep(c[0]); else - *crep = control_rep(c[1]); - *crep_len = 1; + return control_rep(c[1]); } else #endif - { - *crep_len = 1; - *crep = control_rep(*c); - } - - return crep; + return control_rep(*c); } /* c is a multibyte non-control character. We return that multibyte diff --git a/src/proto.h b/src/proto.h index 9581848b342ce9110d4cd38a0cbd3a5680841dd1..14bb0405c168b2ec2414d38f2b163e20da0a535b 100644 --- a/src/proto.h +++ b/src/proto.h @@ -193,7 +193,7 @@ char control_rep(const signed char c); #ifdef ENABLE_UTF8 wchar_t control_wrep(wchar_t wc); #endif -char *control_mbrep(const char *c, char *crep, int *crep_len); +char control_mbrep(const char *c); char *mbrep(const char *c, char *crep, int *crep_len); int mbwidth(const char *c); int mb_cur_max(void); diff --git a/src/winio.c b/src/winio.c index d74945768c62816fbd11ee7344264748ae8e5acf..df7453c19f3fb8bf8483b06e4291eeb86b3743d5 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1786,18 +1786,8 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool if (is_cntrl_mbchar(buf_mb)) { if (column < start_col) { - char *character = charalloc(mb_cur_max()); - int charlen, i; - - character = control_mbrep(buf_mb, character, &charlen); - - for (i = 0; i < charlen; i++) - converted[index++] = character[i]; - - start_col += mbwidth(character); - - free(character); - + converted[index++] = control_mbrep(buf_mb); + start_col++; start_index += buf_mb_len; } } @@ -1859,22 +1849,11 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool converted[index++] = ' '; start_col++; } - /* If buf contains a control character, interpret it. */ + /* If buf contains a control character, represent it. */ } else if (is_cntrl_mbchar(buf_mb)) { - char *character = charalloc(mb_cur_max()); - int charlen, i; - converted[index++] = '^'; - start_col++; - - character = control_mbrep(buf_mb, character, &charlen); - - for (i = 0; i < charlen; i++) - converted[index++] = character[i]; - - start_col += mbwidth(character); - - free(character); + converted[index++] = control_mbrep(buf_mb); + start_col += 2; /* If buf contains a non-control character, interpret it. If buf * contains an invalid multibyte sequence, display it as such. */ } else {