On Mon, 20 May 2002, Jungshik Shin wrote:
> On Mon, 20 May 2002, Zvi Har'El wrote:
> > I am using less on a UTF-8 Redhat Linux 7.3 machine. I am having troubles
> > with using man, because of the overstiking is not handled properly.
> > I read the
> Anyway, attached is a *simplistic*(not perfect) patch against
> less 374(the newest at less home page)
Attached is a newer patch. This one works better than the previous
one although it still has the problem mentioned in my previous
message(and quoted below). With this, two hyphens in a row(U+2010) overstruck
with themselves are rendered correctly. I don't have to be bothered
by hollow boxes(for U+2010) in man pages any more.
> 'pattern'). It's not perfect because it only checks the first
> octet of a two or three octet-long UTF-8 char to see if it's
> identical with the char. preceding backspace.
Jungshik Shin
--- line.c.orig Mon May 20 11:56:34 2002
+++ line.c Mon May 20 14:38:02 2002
@@ -555,6 +555,13 @@
return (r);
}
+#define IS_UTF8_4BYTE(c) ( ((c) & 0xf8) == 0xf0 )
+#define IS_UTF8_3BYTE(c) ( ((c) & 0xf0) == 0xe0 )
+#define IS_UTF8_2BYTE(c) ( ((c) & 0xe0) == 0xc0 )
+#define IS_UTF8_TRAIL(c) ( ((c) & 0xc0) == 0x80 )
+
+
+
static int
do_append(c, pos)
int c;
@@ -592,12 +599,20 @@
* or just deletion of the character in the buffer.
*/
overstrike--;
- if (utf_mode && curr > 1 && (char)c == linebuf[curr-2])
+ if (utf_mode && IS_UTF8_4BYTE(c) && curr > 2 && (char)c ==
+linebuf[curr-3])
+ {
+ backc();
+ backc();
+ backc();
+ STORE_CHAR(linebuf[curr], AT_BOLD, pos);
+ overstrike = 3;
+ } else if (utf_mode && (IS_UTF8_3BYTE(c) || overstrike==2 &&
+IS_UTF8_TRAIL(c)) && curr > 1 && (char)c == linebuf[curr-2])
{
backc();
backc();
+ STORE_CHAR(linebuf[curr], AT_BOLD, pos);
overstrike = 2;
- } else if (utf_mode && curr > 0 && (char)c == linebuf[curr-1])
+ } else if (utf_mode && curr > 0 && (IS_UTF8_2BYTE(c) || overstrike==1
+&& IS_UTF8_TRAIL(c)) && (char)c == linebuf[curr-1])
{
backc();
STORE_CHAR(linebuf[curr], AT_BOLD, pos);