1
1

handle wctomb() failures properly in display_stirng_len() and

display_string()


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2207 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2004-12-29 21:32:22 +00:00
родитель 4d97a588e6
Коммит f282428a42

Просмотреть файл

@ -1769,6 +1769,8 @@ size_t display_string_len(const char *buf, size_t start_col, size_t
if (bad_wide_buf_len != -1) if (bad_wide_buf_len != -1)
retval += bad_wide_buf_len; retval += bad_wide_buf_len;
else
retval++;
free(bad_wide_buf); free(bad_wide_buf);
} else { } else {
@ -1809,7 +1811,10 @@ size_t display_string_len(const char *buf, size_t start_col, size_t
free(bad_wide_buf); free(bad_wide_buf);
retval += bad_wide_buf_len; if (bad_wide_buf_len != -1)
retval += bad_wide_buf_len;
else
retval++;
} else } else
#endif #endif
retval += wide_buf_len; retval += wide_buf_len;
@ -1887,10 +1892,15 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
wide_buf = control_rep((unsigned char)wide_buf); wide_buf = control_rep((unsigned char)wide_buf);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) if (!ISSET(NO_UTF8)) {
ctrl_wide_buf_len = wctomb(ctrl_wide_buf, ctrl_wide_buf_len = wctomb(ctrl_wide_buf,
(wchar_t)wide_buf); (wchar_t)wide_buf);
else {
if (ctrl_wide_buf_len == -1) {
ctrl_wide_buf_len = 1;
ctrl_wide_buf[0] = ' ';
}
} else {
#endif #endif
ctrl_wide_buf_len = 1; ctrl_wide_buf_len = 1;
ctrl_wide_buf[0] = (unsigned char)wide_buf; ctrl_wide_buf[0] = (unsigned char)wide_buf;
@ -1961,10 +1971,15 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
wide_buf = control_rep((unsigned char)wide_buf); wide_buf = control_rep((unsigned char)wide_buf);
#ifdef NANO_WIDE #ifdef NANO_WIDE
if (!ISSET(NO_UTF8)) if (!ISSET(NO_UTF8)) {
ctrl_wide_buf_len = wctomb(ctrl_wide_buf, ctrl_wide_buf_len = wctomb(ctrl_wide_buf,
(wchar_t)wide_buf); (wchar_t)wide_buf);
else {
if (ctrl_wide_buf_len == -1) {
ctrl_wide_buf_len = 1;
ctrl_wide_buf[0] = ' ';
}
} else {
#endif #endif
ctrl_wide_buf_len = 1; ctrl_wide_buf_len = 1;
ctrl_wide_buf[0] = (unsigned char)wide_buf; ctrl_wide_buf[0] = (unsigned char)wide_buf;
@ -2003,6 +2018,11 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
bad_wide_buf_len = wctomb(bad_wide_buf, bad_wide_buf_len = wctomb(bad_wide_buf,
(wchar_t)wide_buf); (wchar_t)wide_buf);
if (bad_wide_buf_len == -1) {
bad_wide_buf_len = 1;
bad_wide_buf[0] = ' ';
}
for (i = 0; i < bad_wide_buf_len; i++) for (i = 0; i < bad_wide_buf_len; i++)
converted[index++] = bad_wide_buf[i]; converted[index++] = bad_wide_buf[i];