=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/line.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -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,7 +32,6 @@ 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; @@ -127,7 +126,6 @@ column = 0; cshift = 0; overstrike = 0; - last_overstrike = AT_NORMAL; mbc_buf_len = 0; is_null_line = 0; pendc = '\0'; @@ -515,10 +513,6 @@ 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. @@ -808,10 +802,12 @@ 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 + 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,10 +821,13 @@ /* 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)) + is_combining_char(get_wchar(linebuf + curr), ch)) { /* Continuation of the same overstrike. */ - a = last_overstrike; - else + if (curr > 0) + a = attr[curr - 1] & (AT_UNDERLINE | AT_BOLD); + else + a = AT_NORMAL; + } else overstrike = 0; } @@ -894,6 +893,8 @@ void pdone(int endline, int forw) { + int i; + (void) pflushmbc(); if (pendc && (pendc != '\r' || !endline)) @@ -903,6 +904,16 @@ * (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.