version 1.27, 2019/03/12 11:59:24 |
version 1.28, 2019/03/13 11:22:56 |
|
|
*/ |
*/ |
|
|
#include <wchar.h> |
#include <wchar.h> |
|
#include <wctype.h> |
|
|
#include "charset.h" |
#include "charset.h" |
#include "less.h" |
#include "less.h" |
|
|
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; |
|
|
|
|
*/ |
*/ |
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) { |
/* |
/* |
|
|
} 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; |
|
|
} |
} |
/* 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); |
|
|
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)) { |
|
|
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); |