From 4c6956b433064ee67758064d6e80b77fcb37d463 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 12 Jan 2005 04:32:43 +0000 Subject: [PATCH] add minor fixes to make the displaying of invalid multibyte sequences work again git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2249 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/chars.c | 9 ++++----- src/winio.c | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/chars.c b/src/chars.c index 134bad3c..de28d420 100644 --- a/src/chars.c +++ b/src/chars.c @@ -150,7 +150,7 @@ char *control_mbrep(const char *c, char *crep, int *crep_len) if (c_mb_len <= 0) { mbtowc(NULL, NULL, 0); - wc = *c; + wc = (unsigned char)*c; } wcrep = control_wrep(wc); @@ -237,14 +237,13 @@ char *make_mbchar(unsigned int chr, char *chr_mb, int *chr_mb_len) *chr_mb_len = wctomb(chr_mb, chr); if (*chr_mb_len <= 0) { - mbtowc(NULL, NULL, 0); - *chr_mb_len = 1; - chr_mb[0] = (unsigned char)chr; + wctomb(NULL, 0); + *chr_mb_len = 0; } } else { #endif *chr_mb_len = 1; - chr_mb[0] = (unsigned char)chr; + chr_mb[0] = (char)chr; #ifdef NANO_WIDE } #endif diff --git a/src/winio.c b/src/winio.c index 3a99ea7d..328fafc3 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2190,7 +2190,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool char *bad_buf_mb = charalloc(mb_cur_max()); int bad_buf_mb_len; - bad_buf_mb = make_mbchar((unsigned int)*buf_mb, + bad_buf_mb = make_mbchar((unsigned char)*buf_mb, bad_buf_mb, &bad_buf_mb_len); for (i = 0; i < bad_buf_mb_len; i++) -- 2.39.5