=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/line.c,v retrieving revision 1.27 retrieving revision 1.28 diff -c -r1.27 -r1.28 *** src/usr.bin/less/line.c 2019/03/12 11:59:24 1.27 --- src/usr.bin/less/line.c 2019/03/13 11:22:56 1.28 *************** *** 16,21 **** --- 16,22 ---- */ #include + #include #include "charset.h" #include "less.h" *************** *** 774,781 **** static int do_append(LWCHAR ch, char *rep, off_t pos) { int a; - LWCHAR prev_ch; a = AT_NORMAL; --- 775,782 ---- static int do_append(LWCHAR ch, char *rep, off_t pos) { + wchar_t prev_ch; int a; a = AT_NORMAL; *************** *** 813,819 **** */ overstrike = utf_mode ? -1 : 0; /* To be correct, this must be a base character. */ ! prev_ch = get_wchar(linebuf + curr); a = attr[curr]; if (ch == prev_ch) { /* --- 814,823 ---- */ overstrike = utf_mode ? -1 : 0; /* To be correct, this must be a base character. */ ! if (mbtowc(&prev_ch, linebuf + curr, MB_CUR_MAX) == -1) { ! (void)mbtowc(NULL, NULL, MB_CUR_MAX); ! prev_ch = L'\0'; ! } a = attr[curr]; if (ch == prev_ch) { /* *************** *** 835,841 **** } else { a |= AT_BOLD; } ! } else if (ch == '_') { a |= AT_UNDERLINE; ch = prev_ch; rep = linebuf + curr; --- 839,845 ---- } else { a |= AT_BOLD; } ! } else if (ch == '_' && prev_ch != L'\0') { a |= AT_UNDERLINE; ch = prev_ch; rep = linebuf + curr; *************** *** 844,851 **** } /* Else we replace prev_ch, but we keep its attributes. */ } else if (overstrike < 0) { ! if (is_composing_char(ch) || ! is_combining_char(get_wchar(linebuf + curr), ch)) { /* Continuation of the same overstrike. */ if (curr > 0) a = attr[curr - 1] & (AT_UNDERLINE | AT_BOLD); --- 848,854 ---- } /* Else we replace prev_ch, but we keep its attributes. */ } else if (overstrike < 0) { ! if (wcwidth(ch) == 0) { /* Continuation of the same overstrike. */ if (curr > 0) a = attr[curr - 1] & (AT_UNDERLINE | AT_BOLD); *************** *** 868,874 **** return (1); break; } ! } else if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch)) { do_control_char: if (ctldisp == OPT_ON || (ctldisp == OPT_ONPLUS && ch == ESC)) { --- 871,878 ---- return (1); break; } ! } else if ((!utf_mode || is_ascii_char(ch)) && ! !isprint((unsigned char)ch)) { do_control_char: if (ctldisp == OPT_ON || (ctldisp == OPT_ONPLUS && ch == ESC)) { *************** *** 881,887 **** if (store_prchar(ch, pos)) return (1); } ! } else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch)) { char *s; s = prutfchar(ch); --- 885,891 ---- if (store_prchar(ch, pos)) return (1); } ! } else if (utf_mode && ctldisp != OPT_ON && !iswprint(ch)) { char *s; s = prutfchar(ch);