Skip to content

Commit

Permalink
Treat Unicode formatting chars as control chars if -U is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Nov 13, 2017
1 parent 2170e92 commit 07c14bb
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Makefile.aut
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DISTFILES_W = \
defines.wn Makefile.wnm Makefile.wnb \
configure
UNICODE_FILES = \
compose.uni ubin.uni wide.uni
compose.uni fmt.uni ubin.uni wide.uni
DISTFILES = \
${SRC} regexp.c regexp.h \
COPYING INSTALL LICENSE Makefile.in Makefile.aut NEWS README \
Expand Down Expand Up @@ -104,7 +104,9 @@ ${srcdir}/lessecho.man: ${srcdir}/lessecho.nro
${NROFF} ${srcdir}/lessecho.nro >${srcdir}/lessecho.man

compose.uni: unicode/UnicodeData.txt
./mkutable -f2 Mn Me Cf -- unicode/UnicodeData.txt > $@
./mkutable -f2 Mn Me -- unicode/UnicodeData.txt > $@
fmt.uni: unicode/UnicodeData.txt
./mkutable -f2 Cf -- unicode/UnicodeData.txt > $@
ubin.uni: unicode/UnicodeData.txt
./mkutable -f2 Cc Cs Co Zl Zp -- unicode/UnicodeData.txt > $@
wide.uni: unicode/EastAsianWidth.txt
Expand Down
12 changes: 10 additions & 2 deletions charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <windows.h>
#endif

extern int bs_mode;

public int utf_mode = 0;

/*
Expand Down Expand Up @@ -739,6 +741,10 @@ DECLARE_RANGE_TABLE_START(wide)
#include "wide.uni"
DECLARE_RANGE_TABLE_END(wide)

DECLARE_RANGE_TABLE_START(fmt)
#include "fmt.uni"
DECLARE_RANGE_TABLE_END(fmt)

/* comb_table is special pairs, not ranges. */
static struct wchar_range comb_table[] = {
{0x0644,0x0622}, {0x0644,0x0623}, {0x0644,0x0625}, {0x0644,0x0627},
Expand Down Expand Up @@ -779,7 +785,8 @@ is_in_table(ch, table)
is_composing_char(ch)
LWCHAR ch;
{
return is_in_table(ch, &compose_table);
return is_in_table(ch, &compose_table) ||
(bs_mode != BS_CONTROL && is_in_table(ch, &fmt_table));
}

/*
Expand All @@ -789,7 +796,8 @@ is_composing_char(ch)
is_ubin_char(ch)
LWCHAR ch;
{
int ubin = is_in_table(ch, &ubin_table);
int ubin = is_in_table(ch, &ubin_table) ||
(bs_mode == BS_CONTROL && is_in_table(ch, &fmt_table));
#if MSDOS_COMPILER==WIN32C
if (!ubin && utf_mode == 2 && ch < 0x10000)
{
Expand Down
19 changes: 19 additions & 0 deletions fmt.uni
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* Generated by "./mkutable -f2 Cf -- unicode/UnicodeData.txt" on Sun Nov 12 16:13:49 PST 2017 */
{ 0x00ad, 0x00ad }, /* Cf */
{ 0x0600, 0x0605 }, /* Cf */
{ 0x061c, 0x061c }, /* Cf */
{ 0x06dd, 0x06dd }, /* Cf */
{ 0x070f, 0x070f }, /* Cf */
{ 0x08e2, 0x08e2 }, /* Cf */
{ 0x180e, 0x180e }, /* Cf */
{ 0x200b, 0x200f }, /* Cf */
{ 0x202a, 0x202e }, /* Cf */
{ 0x2060, 0x2064 }, /* Cf */
{ 0x2066, 0x206f }, /* Cf */
{ 0xfeff, 0xfeff }, /* Cf */
{ 0xfff9, 0xfffb }, /* Cf */
{ 0x110bd, 0x110bd }, /* Cf */
{ 0x1bca0, 0x1bca3 }, /* Cf */
{ 0x1d173, 0x1d17a }, /* Cf */
{ 0xe0001, 0xe0001 }, /* Cf */
{ 0xe0020, 0xe007f }, /* Cf */
4 changes: 2 additions & 2 deletions less.nro.VER
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@ Specifies a tags file to be used instead of "tags".
Causes backspaces and carriage returns to be treated as printable characters;
that is, they are sent to the terminal when they appear in the input.
.IP "\-U or \-\-UNDERLINE-SPECIAL"
Causes backspaces, tabs and carriage returns to be
treated as control characters;
Causes backspaces, tabs, carriage returns and "formatting characters"
(as defined by Unicode) to be treated as control characters;
that is, they are handled as specified by the \-r option.
.sp
By default, if neither \-u nor \-U is given,
Expand Down
4 changes: 3 additions & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,8 @@ v524 10/24/17 Fix getcc bug.
v525 10/24/17 Change M command to mark last displayed line.
v526 10/25/17 Fix search hilite bug introduced in v517.
v527 10/30/17 Fix search hilite bug on last page with -a.
v528 11/3/17 Make second ESC-u clear status column.
v529 11/12/17 Display Unicode formatting chars in hex if -U is set.
*/

char version[] = "527";
char version[] = "529";

0 comments on commit 07c14bb

Please sign in to comment.