[BACK]Return to line.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / less

Diff for /src/usr.bin/less/line.c between version 1.27 and 1.28

version 1.27, 2019/03/12 11:59:24 version 1.28, 2019/03/13 11:22:56
Line 16 
Line 16 
  */   */
   
 #include <wchar.h>  #include <wchar.h>
   #include <wctype.h>
   
 #include "charset.h"  #include "charset.h"
 #include "less.h"  #include "less.h"
Line 774 
Line 775 
 static int  static int
 do_append(LWCHAR ch, char *rep, off_t pos)  do_append(LWCHAR ch, char *rep, off_t pos)
 {  {
           wchar_t prev_ch;
         int a;          int a;
         LWCHAR prev_ch;  
   
         a = AT_NORMAL;          a = AT_NORMAL;
   
Line 813 
Line 814 
                  */                   */
                 overstrike = utf_mode ? -1 : 0;                  overstrike = utf_mode ? -1 : 0;
                 /* To be correct, this must be a base character.  */                  /* To be correct, this must be a base character.  */
                 prev_ch = get_wchar(linebuf + curr);                  if (mbtowc(&prev_ch, linebuf + curr, MB_CUR_MAX) == -1) {
                           (void)mbtowc(NULL, NULL, MB_CUR_MAX);
                           prev_ch = L'\0';
                   }
                 a = attr[curr];                  a = attr[curr];
                 if (ch == prev_ch) {                  if (ch == prev_ch) {
                         /*                          /*
Line 835 
Line 839 
                         } else {                          } else {
                                 a |= AT_BOLD;                                  a |= AT_BOLD;
                         }                          }
                 } else if (ch == '_') {                  } else if (ch == '_' && prev_ch != L'\0') {
                         a |= AT_UNDERLINE;                          a |= AT_UNDERLINE;
                         ch = prev_ch;                          ch = prev_ch;
                         rep = linebuf + curr;                          rep = linebuf + curr;
Line 844 
Line 848 
                 }                  }
                 /* Else we replace prev_ch, but we keep its attributes.  */                  /* Else we replace prev_ch, but we keep its attributes.  */
         } else if (overstrike < 0) {          } else if (overstrike < 0) {
                 if (is_composing_char(ch) ||                  if (wcwidth(ch) == 0) {
                     is_combining_char(get_wchar(linebuf + curr), ch)) {  
                         /* Continuation of the same overstrike.  */                          /* Continuation of the same overstrike.  */
                         if (curr > 0)                          if (curr > 0)
                                 a = attr[curr - 1] & (AT_UNDERLINE | AT_BOLD);                                  a = attr[curr - 1] & (AT_UNDERLINE | AT_BOLD);
Line 868 
Line 871 
                                 return (1);                                  return (1);
                         break;                          break;
                 }                  }
         } else if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch)) {          } else if ((!utf_mode || is_ascii_char(ch)) &&
               !isprint((unsigned char)ch)) {
 do_control_char:  do_control_char:
                 if (ctldisp == OPT_ON ||                  if (ctldisp == OPT_ON ||
                     (ctldisp == OPT_ONPLUS && ch == ESC)) {                      (ctldisp == OPT_ONPLUS && ch == ESC)) {
Line 881 
Line 885 
                         if (store_prchar(ch, pos))                          if (store_prchar(ch, pos))
                                 return (1);                                  return (1);
                 }                  }
         } else if (utf_mode && ctldisp != OPT_ON && is_ubin_char(ch)) {          } else if (utf_mode && ctldisp != OPT_ON && !iswprint(ch)) {
                 char *s;                  char *s;
   
                 s = prutfchar(ch);                  s = prutfchar(ch);

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28