=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/line.c,v retrieving revision 1.19 retrieving revision 1.20 diff -c -r1.19 -r1.20 *** src/usr.bin/less/line.c 2016/03/16 15:36:26 1.19 --- src/usr.bin/less/line.c 2016/03/26 08:59:29 1.20 *************** *** 32,38 **** static int curr; /* Index into linebuf */ static int column; /* Printable length, accounting for backspaces, etc. */ static int overstrike; /* Next char should overstrike previous char */ - static int last_overstrike = AT_NORMAL; static int is_null_line; /* There is no current line */ static int lmargin; /* Left margin */ static char pendc; --- 32,37 ---- *************** *** 127,133 **** column = 0; cshift = 0; overstrike = 0; - last_overstrike = AT_NORMAL; mbc_buf_len = 0; is_null_line = 0; pendc = '\0'; --- 126,131 ---- *************** *** 515,524 **** char cs; int matches; - w = (a & (AT_UNDERLINE|AT_BOLD)); /* Pre-use w. */ - if (w != AT_NORMAL) - last_overstrike = w; - if (is_hilited(pos, pos+1, 0, &matches)) { /* * This character should be highlighted. --- 513,518 ---- *************** *** 808,817 **** if (ch == '_') { if ((a & (AT_BOLD|AT_UNDERLINE)) != AT_NORMAL) a |= (AT_BOLD|AT_UNDERLINE); ! else if (last_overstrike != AT_NORMAL) ! a |= last_overstrike; ! else a |= AT_BOLD; } else { a |= AT_BOLD; } --- 802,813 ---- if (ch == '_') { if ((a & (AT_BOLD|AT_UNDERLINE)) != AT_NORMAL) a |= (AT_BOLD|AT_UNDERLINE); ! else if (curr > 0 && attr[curr - 1] & AT_UNDERLINE) ! a |= AT_UNDERLINE; ! else if (curr > 0 && attr[curr - 1] & AT_BOLD) a |= AT_BOLD; + else + a |= AT_INDET; } else { a |= AT_BOLD; } *************** *** 825,834 **** /* 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. */ ! a = last_overstrike; ! else overstrike = 0; } --- 821,833 ---- /* 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); ! else ! a = AT_NORMAL; ! } else overstrike = 0; } *************** *** 894,899 **** --- 893,900 ---- void pdone(int endline, int forw) { + int i; + (void) pflushmbc(); if (pendc && (pendc != '\r' || !endline)) *************** *** 903,908 **** --- 904,919 ---- * (that is, discard the CR in a CR/LF sequence). */ (void) do_append(pendc, NULL, pendpos); + + for (i = curr - 1; i >= 0; i--) { + if (attr[i] & AT_INDET) { + attr[i] &= ~AT_INDET; + if (i < curr - 1 && attr[i + 1] & AT_BOLD) + attr[i] |= AT_BOLD; + else + attr[i] |= AT_UNDERLINE; + } + } /* * Make sure we've shifted the line, if we need to.