>Number: 6612
>Category: user
>Synopsis: less(1) UTF-8 search is not displayed correctly
>Confidential: yes
>Severity: serious
>Priority: medium
>Responsible: bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: unknown
>Arrival-Date: Mon May 23 15:50:02 GMT 2011
>Closed-Date:
>Last-Modified:
>Originator:
>Release:
>Organization:
>Environment:
System : OpenBSD 4.9
Details : OpenBSD 4.9-current (kernel) #7: Mon May 23 01:13:34 MSD
2011
[email protected]:/usr/obj/kernel
Architecture: OpenBSD.amd64
Machine : amd64
>Description:
This is a known bug in less < 388 (See
http://www.greenwoodsoftware.com/less/bugs.html)
"Entering multibyte UTF-8 characters on the command line (for example,
in a search string)
may not work correctly"
>How-To-Repeat:
Open a file in less, type /QP5QQ.
It's displayed like this "/[Ko?=[Ko?=[Ko?=[Ko?="
% env|grep LC_
LC_CTYPE=en_US.UTF-8
>Fix:
I couldn't find less v.388 on the web, so here's a diff between v.394
and in-tree v.382
for cmdbuf.c and charset.{ch}, which makes the bug go away.
diff -urN /usr/src/usr.bin/less/Makefile.aut less/Makefile.aut
--- /usr/src/usr.bin/less/Makefile.aut Sun Jan 23 20:53:13 2011
+++ less/Makefile.aut Mon May 23 02:21:36 2011
@@ -24,7 +24,7 @@
${SRC} regexp.c regexp.h \
COPYING INSTALL LICENSE Makefile.in Makefile.aut NEWS README \
configure configure.ac lesskey.c lessecho.c scrsize.c \
- cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h position.h \
+ charset.h cmd.h funcs.h lglob.h less.h lesskey.h option.h pckeys.h
position.h \
install.sh defines.h.in mkinstalldirs \
less.nro lesskey.nro less.man lesskey.man less.hlp \
mkfuncs.awk mkhelp.c \
diff -urN /usr/src/usr.bin/less/charset.c less/charset.c
--- /usr/src/usr.bin/less/charset.c Sun Jan 23 20:53:13 2011
+++ less/charset.c Mon May 23 02:21:36 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2002 Mark Nudelman
+ * Copyright (C) 1984-2005 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -18,11 +18,13 @@
#if HAVE_LOCALE
#include <locale.h>
#include <ctype.h>
+#include <langinfo.h>
#endif
+#include "charset.h"
+
public int utf_mode = 0;
-#if !SMALL
/*
* Predefined character sets,
* selected by the LESSCHARSET environment variable.
@@ -32,23 +34,76 @@
int *p_flag;
char *desc;
} charsets[] = {
- { "ascii", NULL, "8bcccbcc18b95.b" },
- { "dos", NULL, "8bcccbcc12bc5b223.b" },
- { "ebcdic", NULL,
"5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
- { "IBM-1047", NULL,
"4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
- { "iso8859", NULL, "8bcccbcc18b95.33b." },
- { "koi8-r", NULL, "8bcccbcc18b95.b128." },
- { "next", NULL, "8bcccbcc18b95.bb125.bb" },
- { "utf-8", &utf_mode, "8bcccbcc18b." },
+ { "ascii", NULL, "8bcccbcc18b95.b" },
+ { "utf-8", &utf_mode, "8bcccbcc18b95.b126.bb" },
+ { "iso8859", NULL, "8bcccbcc18b95.33b." },
+ { "latin3", NULL,
"8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." },
+ { "arabic", NULL,
"8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" },
+ { "greek", NULL,
"8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" },
+ { "greek2005", NULL, "8bcccbcc18b95.33b14.b35.b44.b" },
+ { "hebrew", NULL, "8bcccbcc18b95.33b.b29.32b28.2b2.b"
},
+ { "koi8-r", NULL, "8bcccbcc18b95.b." },
+ { "KOI8-T", NULL,
"8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." },
+ { "georgianps", NULL, "8bcccbcc18b95.3b11.4b12.2b." },
+ { "tcvn", NULL, "b..b...bcccbccbbb7.8b95.b48.5b." },
+ { "TIS-620", NULL, "8bcccbcc18b95.b.4b.11b7.8b." },
+ { "next", NULL, "8bcccbcc18b95.bb125.bb" },
+ { "dos", NULL, "8bcccbcc12bc5b95.b." },
+ { "windows-1251", NULL, "8bcccbcc12bc5b95.b24.b." },
+ { "windows-1252", NULL, "8bcccbcc12bc5b95.b.b11.b.2b12.b."
},
+ { "windows-1255", NULL, "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b."
},
+ { "ebcdic", NULL,
"5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." },
+ { "IBM-1047", NULL,
"4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" },
{ NULL, NULL, NULL }
};
+/*
+ * Support "locale charmap"/nl_langinfo(CODESET) values, as well as others.
+ */
struct cs_alias {
char *name;
char *oname;
} cs_aliases[] = {
- { "latin1", "iso8859" },
- { "latin9", "iso8859" },
+ { "UTF-8", "utf-8" },
+ { "ANSI_X3.4-1968", "ascii" },
+ { "US-ASCII", "ascii" },
+ { "latin1", "iso8859" },
+ { "ISO-8859-1", "iso8859" },
+ { "latin9", "iso8859" },
+ { "ISO-8859-15", "iso8859" },
+ { "latin2", "iso8859" },
+ { "ISO-8859-2", "iso8859" },
+ { "ISO-8859-3", "latin3" },
+ { "latin4", "iso8859" },
+ { "ISO-8859-4", "iso8859" },
+ { "cyrillic", "iso8859" },
+ { "ISO-8859-5", "iso8859" },
+ { "ISO-8859-6", "arabic" },
+ { "ISO-8859-7", "greek" },
+ { "IBM9005", "greek2005" },
+ { "ISO-8859-8", "hebrew" },
+ { "latin5", "iso8859" },
+ { "ISO-8859-9", "iso8859" },
+ { "latin6", "iso8859" },
+ { "ISO-8859-10", "iso8859" },
+ { "latin7", "iso8859" },
+ { "ISO-8859-13", "iso8859" },
+ { "latin8", "iso8859" },
+ { "ISO-8859-14", "iso8859" },
+ { "latin10", "iso8859" },
+ { "ISO-8859-16", "iso8859" },
+ { "IBM437", "dos" },
+ { "EBCDIC-US", "ebcdic" },
+ { "IBM1047", "IBM-1047" },
+ { "KOI8-R", "koi8-r" },
+ { "KOI8-U", "koi8-r" },
+ { "GEORGIAN-PS", "georgianps" },
+ { "TCVN5712-1", "tcvn" },
+ { "NEXTSTEP", "next" },
+ { "windows", "windows-1252" }, /* backward compatibility */
+ { "CP1251", "windows-1251" },
+ { "CP1252", "windows-1252" },
+ { "CP1255", "windows-1255" },
{ NULL, NULL }
};
@@ -57,6 +112,7 @@
static char chardef[256];
static char *binfmt = NULL;
+static char *utfbinfmt = NULL;
public int binattr = AT_STANDOUT;
@@ -132,8 +188,9 @@
* The valid charset names are listed in the "charsets" array.
*/
static int
-icharset(name)
+icharset(name, no_error)
register char *name;
+ int no_error;
{
register struct charset *p;
register struct cs_alias *a;
@@ -162,9 +219,10 @@
}
}
- error("invalid charset name", NULL_PARG);
- quit(QUIT_ERROR);
- /*NOTREACHED*/
+ if (!no_error) {
+ error("invalid charset name", NULL_PARG);
+ quit(QUIT_ERROR);
+ }
return (0);
}
@@ -177,7 +235,6 @@
{
register int c;
- setlocale(LC_ALL, "");
for (c = 0; c < (int) sizeof(chardef); c++)
{
if (isprint(c))
@@ -191,17 +248,39 @@
#endif
/*
- * Define the printing format for control chars.
+ * Define the printing format for control (or binary utf) chars.
*/
- public void
-setbinfmt(s)
+ static void
+setbinfmt(s, fmtvarptr, default_fmt)
char *s;
+ char **fmtvarptr;
+ char *default_fmt;
{
- if (s == NULL || *s == '\0')
- s = "*s<%X>";
+ if (s && utf_mode)
+ {
+ /* It would be too hard to account for width otherwise. */
+ char *t = s;
+ while (*t)
+ {
+ if (*t < ' ' || *t > '~')
+ {
+ s = default_fmt;
+ goto attr;
+ }
+ t++;
+ }
+ }
+
+ /* %n is evil */
+ if (s == NULL || *s == '\0' ||
+ (*s == '*' && (s[1] == '\0' || s[2] == '\0' || strchr(s + 2, 'n')))
||
+ (*s != '*' && strchr(s, 'n')))
+ s = default_fmt;
+
/*
* Select the attributes if it starts with "*".
*/
+ attr:
if (*s == '*')
{
switch (s[1])
@@ -214,26 +293,24 @@
}
s += 2;
}
- binfmt = s;
+ *fmtvarptr = s;
}
/*
- * Initialize charset data structures.
+ *
*/
- public void
-init_charset()
+ static void
+set_charset()
{
- register char *s;
+ char *s;
- s = lgetenv("LESSBINFMT");
- setbinfmt(s);
-
/*
* See if environment variable LESSCHARSET is defined.
*/
s = lgetenv("LESSCHARSET");
- if (icharset(s))
+ if (icharset(s, 0))
return;
+
/*
* LESSCHARSET is not defined: try LESSCHARDEF.
*/
@@ -244,6 +321,15 @@
return;
}
+#if HAVE_LOCALE
+ /*
+ * Try using the codeset name as the charset name.
+ */
+ s = nl_langinfo(CODESET);
+ if (icharset(s, 1))
+ return;
+#endif
+
#if HAVE_STRSTR
/*
* Check whether LC_ALL, LC_CTYPE or LANG look like UTF-8 is used.
@@ -252,33 +338,55 @@
(s = lgetenv("LC_CTYPE")) != NULL ||
(s = lgetenv("LANG")) != NULL)
{
- if (strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL)
- if (icharset("utf-8"))
+ if ( strstr(s, "UTF-8") != NULL || strstr(s, "utf-8") != NULL
+ || strstr(s, "UTF8") != NULL || strstr(s, "utf8") != NULL)
+ if (icharset("utf-8", 1))
return;
}
#endif
#if HAVE_LOCALE
/*
- * Use setlocale.
+ * Get character definitions from locale functions,
+ * rather than from predefined charset entry.
*/
ilocale();
-#else
#if MSDOS_COMPILER
/*
* Default to "dos".
*/
- (void) icharset("dos");
+ (void) icharset("dos", 1);
#else
/*
* Default to "latin1".
*/
- (void) icharset("latin1");
+ (void) icharset("latin1", 1);
#endif
#endif
}
/*
+ * Initialize charset data structures.
+ */
+ public void
+init_charset()
+{
+ char *s;
+
+#if HAVE_LOCALE
+ setlocale(LC_ALL, "");
+#endif
+
+ set_charset();
+
+ s = lgetenv("LESSBINFMT");
+ setbinfmt(s, &binfmt, "*s<%02X>");
+
+ s = lgetenv("LESSUTFBINFMT");
+ setbinfmt(s, &utfbinfmt, "<U+%04lX>");
+}
+
+/*
* Is a given character a "binary" character?
*/
public int
@@ -308,13 +416,14 @@
prchar(c)
int c;
{
- static char buf[8];
+ /* {{ This buffer can be overrun if LESSBINFMT is a long string. }} */
+ static char buf[32];
c &= 0377;
- if (!control_char(c))
+ if ((c < 128 || !utf_mode) && !control_char(c))
snprintf(buf, sizeof(buf), "%c", c);
else if (c == ESC)
- snprintf(buf, sizeof(buf), "ESC");
+ strcpy(buf, "ESC");
#if IS_EBCDIC_HOST
else if (!binary_char(c) && c < 64)
snprintf(buf, sizeof(buf), "^%c",
@@ -336,55 +445,591 @@
return (buf);
}
-#else /* SMALL */
+/*
+ * Return the printable form of a UTF-8 character.
+ */
+ public char *
+prutfchar(ch)
+ LWCHAR ch;
+{
+ static char buf[32];
-public int binattr = AT_STANDOUT;
+ if (ch == ESC)
+ strcpy(buf, "ESC");
+ else if (ch < 128 && control_char(ch))
+ {
+ if (!control_char(ch ^ 0100))
+ snprintf(buf, sizeof(buf), "^%c", ((char) ch) ^ 0100);
+ else
+ snprintf(buf, sizeof(buf), binfmt, (char) ch);
+ } else if (is_ubin_char(ch))
+ snprintf(buf, sizeof(buf), utfbinfmt, ch);
+ else
+ {
+ int len;
+ if (ch >= 0x80000000)
+ {
+ len = 3;
+ ch = 0xFFFD;
+ } else
+ {
+ len = (ch < 0x80) ? 1
+ : (ch < 0x800) ? 2
+ : (ch < 0x10000) ? 3
+ : (ch < 0x200000) ? 4
+ : (ch < 0x4000000) ? 5
+ : 6;
+ }
+ buf[len] = '\0';
+ if (len == 1)
+ *buf = (char) ch;
+ else
+ {
+ *buf = ((1 << len) - 1) << (8 - len);
+ while (--len > 0)
+ {
+ buf[len] = (char) (0x80 | (ch & 0x3F));
+ ch >>= 6;
+ }
+ *buf |= ch;
+ }
+ }
+ return (buf);
+}
- public void
-init_charset()
+/*
+ * Get the length of a UTF-8 character in bytes.
+ */
+ public int
+utf_len(ch)
+ char ch;
{
- return;
+ if ((ch & 0x80) == 0)
+ return 1;
+ if ((ch & 0xE0) == 0xC0)
+ return 2;
+ if ((ch & 0xF0) == 0xE0)
+ return 3;
+ if ((ch & 0xF8) == 0xF0)
+ return 4;
+ if ((ch & 0xFC) == 0xF8)
+ return 5;
+ if ((ch & 0xFE) == 0xFC)
+ return 6;
+ /* Invalid UTF-8 encoding. */
+ return 1;
}
/*
- * Is a given character a "binary" character?
+ * Is a UTF-8 character well-formed?
*/
public int
-binary_char(c)
- unsigned char c;
+is_utf8_well_formed(s)
+ unsigned char *s;
{
- return (!isprint(c) && !isspace(c));
+ int i;
+ int len;
+
+ if (IS_UTF8_INVALID(s[0]))
+ return (0);
+
+ len = utf_len((char) s[0]);
+ if (len == 1)
+ return (1);
+ if (len == 2)
+ {
+ if (s[0] < 0xC2)
+ return (0);
+ } else
+ {
+ unsigned char mask;
+ mask = (~((1 << (8-len)) - 1)) & 0xFF;
+ if (s[0] == mask && (s[1] & mask) == 0x80)
+ return (0);
+ }
+
+ for (i = 1; i < len; i++)
+ if (!IS_UTF8_TRAIL(s[i]))
+ return (0);
+ return (1);
}
/*
- * Is a given character a "control" character?
+ * Get the value of a UTF-8 character.
*/
+ public LWCHAR
+get_wchar(p)
+ char *p;
+{
+ switch (utf_len(p[0]))
+ {
+ case 1:
+ default:
+ return (LWCHAR)
+ (p[0] & 0xFF);
+ case 2:
+ return (LWCHAR) (
+ ((p[0] & 0x1F) << 6) |
+ (p[1] & 0x3F));
+ case 3:
+ return (LWCHAR) (
+ ((p[0] & 0x0F) << 12) |
+ ((p[1] & 0x3F) << 6) |
+ (p[2] & 0x3F));
+ case 4:
+ return (LWCHAR) (
+ ((p[0] & 0x07) << 18) |
+ ((p[1] & 0x3F) << 12) |
+ ((p[2] & 0x3F) << 6) |
+ (p[3] & 0x3F));
+ case 5:
+ return (LWCHAR) (
+ ((p[0] & 0x03) << 24) |
+ ((p[1] & 0x3F) << 18) |
+ ((p[2] & 0x3F) << 12) |
+ ((p[3] & 0x3F) << 6) |
+ (p[4] & 0x3F));
+ case 6:
+ return (LWCHAR) (
+ ((p[0] & 0x01) << 30) |
+ ((p[1] & 0x3F) << 24) |
+ ((p[2] & 0x3F) << 18) |
+ ((p[3] & 0x3F) << 12) |
+ ((p[4] & 0x3F) << 6) |
+ (p[5] & 0x3F));
+ }
+}
+
+/*
+ * Step forward or backward one character in a string.
+ */
+ public LWCHAR
+step_char(pp, dir, limit)
+ char **pp;
+ signed int dir;
+ char *limit;
+{
+ LWCHAR ch;
+ char *p = *pp;
+
+ if (!utf_mode)
+ {
+ /* It's easy if chars are one byte. */
+ if (dir > 0)
+ ch = (LWCHAR) ((p < limit) ? *p++ : 0);
+ else
+ ch = (LWCHAR) ((p > limit) ? *--p : 0);
+ } else if (dir > 0)
+ {
+ if (p + utf_len(*p) > limit)
+ ch = 0;
+ else
+ {
+ ch = get_wchar(p);
+ p++;
+ while (IS_UTF8_TRAIL(*p))
+ p++;
+ }
+ } else
+ {
+ while (p > limit && IS_UTF8_TRAIL(p[-1]))
+ p--;
+ if (p > limit)
+ ch = get_wchar(--p);
+ else
+ ch = 0;
+ }
+ *pp = p;
+ return ch;
+}
+
+/*
+ * Unicode characters data
+ */
+struct wchar_range { LWCHAR first, last; };
+
+static struct wchar_range comp_table[] = {
+ {0x300,0x357}, {0x35d,0x36f}, {0x483,0x486}, {0x488,0x489},
+ {0x591,0x5a1}, {0x5a3,0x5b9}, {0x5bb,0x5bd}, {0x5bf,0x5bf},
+ {0x5c1,0x5c2}, {0x5c4,0x5c4}, {0x610,0x615}, {0x64b,0x658},
+ {0x670,0x670}, {0x6d6,0x6dc}, {0x6de,0x6e4}, {0x6e7,0x6e8},
+ {0x6ea,0x6ed}, {0x711,0x711}, {0x730,0x74a}, {0x7a6,0x7b0},
+ {0x901,0x902}, {0x93c,0x93c}, {0x941,0x948}, {0x94d,0x94d},
+ {0x951,0x954}, {0x962,0x963}, {0x981,0x981}, {0x9bc,0x9bc},
+ {0x9c1,0x9c4}, {0x9cd,0x9cd}, {0x9e2,0x9e3}, {0xa01,0xa02},
+ {0xa3c,0xa3c}, {0xa41,0xa42}, {0xa47,0xa48}, {0xa4b,0xa4d},
+ {0xa70,0xa71}, {0xa81,0xa82}, {0xabc,0xabc}, {0xac1,0xac5},
+ {0xac7,0xac8}, {0xacd,0xacd}, {0xae2,0xae3}, {0xb01,0xb01},
+ {0xb3c,0xb3c}, {0xb3f,0xb3f}, {0xb41,0xb43}, {0xb4d,0xb4d},
+ {0xb56,0xb56}, {0xb82,0xb82}, {0xbc0,0xbc0}, {0xbcd,0xbcd},
+ {0xc3e,0xc40}, {0xc46,0xc48}, {0xc4a,0xc4d}, {0xc55,0xc56},
+ {0xcbc,0xcbc}, {0xcbf,0xcbf}, {0xcc6,0xcc6}, {0xccc,0xccd},
+ {0xd41,0xd43}, {0xd4d,0xd4d}, {0xdca,0xdca}, {0xdd2,0xdd4},
+ {0xdd6,0xdd6}, {0xe31,0xe31}, {0xe34,0xe3a}, {0xe47,0xe4e},
+ {0xeb1,0xeb1}, {0xeb4,0xeb9}, {0xebb,0xebc}, {0xec8,0xecd},
+ {0xf18,0xf19}, {0xf35,0xf35}, {0xf37,0xf37}, {0xf39,0xf39},
+ {0xf71,0xf7e}, {0xf80,0xf84}, {0xf86,0xf87}, {0xf90,0xf97},
+ {0xf99,0xfbc}, {0xfc6,0xfc6}, {0x102d,0x1030}, {0x1032,0x1032},
+ {0x1036,0x1037}, {0x1039,0x1039}, {0x1058,0x1059},
+ {0x1712,0x1714}, {0x1732,0x1734}, {0x1752,0x1753},
+ {0x1772,0x1773}, {0x17b7,0x17bd}, {0x17c6,0x17c6},
+ {0x17c9,0x17d3}, {0x17dd,0x17dd}, {0x180b,0x180d},
+ {0x18a9,0x18a9}, {0x1920,0x1922}, {0x1927,0x1928},
+ {0x1932,0x1932}, {0x1939,0x193b}, {0x20d0,0x20ea},
+ {0x302a,0x302f}, {0x3099,0x309a}, {0xfb1e,0xfb1e},
+ {0xfe00,0xfe0f}, {0xfe20,0xfe23}, {0x1d167,0x1d169},
+ {0x1d17b,0x1d182}, {0x1d185,0x1d18b}, {0x1d1aa,0x1d1ad},
+ {0xe0100,0xe01ef},
+};
+
+static struct wchar_range comb_table[] = {
+ {0x0644,0x0622}, {0x0644,0x0623}, {0x0644,0x0625}, {0x0644,0x0627},
+};
+
+/*
+ * Characters with general category values
+ * Cc: Other, Control
+ * Cf: Other, Format
+ * Cs: Other, Surrogate
+ * Co: Other, Private Use
+ * Cn: Other, Not Assigned
+ * Zl: Separator, Line
+ * Zp: Separator, Paragraph
+ */
+static struct wchar_range ubin_table[] = {
+ { 0x0000, 0x001f} /* Cc */, { 0x007f, 0x009f} /* Cc */,
+#if 0
+ { 0x00ad, 0x00ad} /* Cf */,
+#endif
+ { 0x0237, 0x024f} /* Cn */, { 0x0358, 0x035c} /* Cn */,
+ { 0x0370, 0x0373} /* Cn */, { 0x0376, 0x0379} /* Cn */,
+ { 0x037b, 0x037d} /* Cn */, { 0x037f, 0x0383} /* Cn */,
+ { 0x038b, 0x038b} /* Cn */, { 0x038d, 0x038d} /* Cn */,
+ { 0x03a2, 0x03a2} /* Cn */, { 0x03cf, 0x03cf} /* Cn */,
+ { 0x03fc, 0x03ff} /* Cn */, { 0x0487, 0x0487} /* Cn */,
+ { 0x04cf, 0x04cf} /* Cn */, { 0x04f6, 0x04f7} /* Cn */,
+ { 0x04fa, 0x04ff} /* Cn */, { 0x0510, 0x0530} /* Cn */,
+ { 0x0557, 0x0558} /* Cn */, { 0x0560, 0x0560} /* Cn */,
+ { 0x0588, 0x0588} /* Cn */, { 0x058b, 0x0590} /* Cn */,
+ { 0x05a2, 0x05a2} /* Cn */, { 0x05ba, 0x05ba} /* Cn */,
+ { 0x05c5, 0x05cf} /* Cn */, { 0x05eb, 0x05ef} /* Cn */,
+ { 0x05f5, 0x05ff} /* Cn */,
+#if 0
+ { 0x0600, 0x0603} /* Cf */,
+#endif
+ { 0x0604, 0x060b} /* Cn */, { 0x0616, 0x061a} /* Cn */,
+ { 0x061c, 0x061e} /* Cn */, { 0x0620, 0x0620} /* Cn */,
+ { 0x063b, 0x063f} /* Cn */, { 0x0659, 0x065f} /* Cn */,
+#if 0
+ { 0x06dd, 0x06dd} /* Cf */,
+#endif
+ { 0x070e, 0x070e} /* Cn */,
+#if 0
+ { 0x070f, 0x070f} /* Cf */,
+#endif
+ { 0x074b, 0x074c} /* Cn */, { 0x0750, 0x077f} /* Cn */,
+ { 0x07b2, 0x0900} /* Cn */, { 0x093a, 0x093b} /* Cn */,
+ { 0x094e, 0x094f} /* Cn */, { 0x0955, 0x0957} /* Cn */,
+ { 0x0971, 0x0980} /* Cn */, { 0x0984, 0x0984} /* Cn */,
+ { 0x098d, 0x098e} /* Cn */, { 0x0991, 0x0992} /* Cn */,
+ { 0x09a9, 0x09a9} /* Cn */, { 0x09b1, 0x09b1} /* Cn */,
+ { 0x09b3, 0x09b5} /* Cn */, { 0x09ba, 0x09bb} /* Cn */,
+ { 0x09c5, 0x09c6} /* Cn */, { 0x09c9, 0x09ca} /* Cn */,
+ { 0x09ce, 0x09d6} /* Cn */, { 0x09d8, 0x09db} /* Cn */,
+ { 0x09de, 0x09de} /* Cn */, { 0x09e4, 0x09e5} /* Cn */,
+ { 0x09fb, 0x0a00} /* Cn */, { 0x0a04, 0x0a04} /* Cn */,
+ { 0x0a0b, 0x0a0e} /* Cn */, { 0x0a11, 0x0a12} /* Cn */,
+ { 0x0a29, 0x0a29} /* Cn */, { 0x0a31, 0x0a31} /* Cn */,
+ { 0x0a34, 0x0a34} /* Cn */, { 0x0a37, 0x0a37} /* Cn */,
+ { 0x0a3a, 0x0a3b} /* Cn */, { 0x0a3d, 0x0a3d} /* Cn */,
+ { 0x0a43, 0x0a46} /* Cn */, { 0x0a49, 0x0a4a} /* Cn */,
+ { 0x0a4e, 0x0a58} /* Cn */, { 0x0a5d, 0x0a5d} /* Cn */,
+ { 0x0a5f, 0x0a65} /* Cn */, { 0x0a75, 0x0a80} /* Cn */,
+ { 0x0a84, 0x0a84} /* Cn */, { 0x0a8e, 0x0a8e} /* Cn */,
+ { 0x0a92, 0x0a92} /* Cn */, { 0x0aa9, 0x0aa9} /* Cn */,
+ { 0x0ab1, 0x0ab1} /* Cn */, { 0x0ab4, 0x0ab4} /* Cn */,
+ { 0x0aba, 0x0abb} /* Cn */, { 0x0ac6, 0x0ac6} /* Cn */,
+ { 0x0aca, 0x0aca} /* Cn */, { 0x0ace, 0x0acf} /* Cn */,
+ { 0x0ad1, 0x0adf} /* Cn */, { 0x0ae4, 0x0ae5} /* Cn */,
+ { 0x0af0, 0x0af0} /* Cn */, { 0x0af2, 0x0b00} /* Cn */,
+ { 0x0b04, 0x0b04} /* Cn */, { 0x0b0d, 0x0b0e} /* Cn */,
+ { 0x0b11, 0x0b12} /* Cn */, { 0x0b29, 0x0b29} /* Cn */,
+ { 0x0b31, 0x0b31} /* Cn */, { 0x0b34, 0x0b34} /* Cn */,
+ { 0x0b3a, 0x0b3b} /* Cn */, { 0x0b44, 0x0b46} /* Cn */,
+ { 0x0b49, 0x0b4a} /* Cn */, { 0x0b4e, 0x0b55} /* Cn */,
+ { 0x0b58, 0x0b5b} /* Cn */, { 0x0b5e, 0x0b5e} /* Cn */,
+ { 0x0b62, 0x0b65} /* Cn */, { 0x0b72, 0x0b81} /* Cn */,
+ { 0x0b84, 0x0b84} /* Cn */, { 0x0b8b, 0x0b8d} /* Cn */,
+ { 0x0b91, 0x0b91} /* Cn */, { 0x0b96, 0x0b98} /* Cn */,
+ { 0x0b9b, 0x0b9b} /* Cn */, { 0x0b9d, 0x0b9d} /* Cn */,
+ { 0x0ba0, 0x0ba2} /* Cn */, { 0x0ba5, 0x0ba7} /* Cn */,
+ { 0x0bab, 0x0bad} /* Cn */, { 0x0bb6, 0x0bb6} /* Cn */,
+ { 0x0bba, 0x0bbd} /* Cn */, { 0x0bc3, 0x0bc5} /* Cn */,
+ { 0x0bc9, 0x0bc9} /* Cn */, { 0x0bce, 0x0bd6} /* Cn */,
+ { 0x0bd8, 0x0be6} /* Cn */, { 0x0bfb, 0x0c00} /* Cn */,
+ { 0x0c04, 0x0c04} /* Cn */, { 0x0c0d, 0x0c0d} /* Cn */,
+ { 0x0c11, 0x0c11} /* Cn */, { 0x0c29, 0x0c29} /* Cn */,
+ { 0x0c34, 0x0c34} /* Cn */, { 0x0c3a, 0x0c3d} /* Cn */,
+ { 0x0c45, 0x0c45} /* Cn */, { 0x0c49, 0x0c49} /* Cn */,
+ { 0x0c4e, 0x0c54} /* Cn */, { 0x0c57, 0x0c5f} /* Cn */,
+ { 0x0c62, 0x0c65} /* Cn */, { 0x0c70, 0x0c81} /* Cn */,
+ { 0x0c84, 0x0c84} /* Cn */, { 0x0c8d, 0x0c8d} /* Cn */,
+ { 0x0c91, 0x0c91} /* Cn */, { 0x0ca9, 0x0ca9} /* Cn */,
+ { 0x0cb4, 0x0cb4} /* Cn */, { 0x0cba, 0x0cbb} /* Cn */,
+ { 0x0cc5, 0x0cc5} /* Cn */, { 0x0cc9, 0x0cc9} /* Cn */,
+ { 0x0cce, 0x0cd4} /* Cn */, { 0x0cd7, 0x0cdd} /* Cn */,
+ { 0x0cdf, 0x0cdf} /* Cn */, { 0x0ce2, 0x0ce5} /* Cn */,
+ { 0x0cf0, 0x0d01} /* Cn */, { 0x0d04, 0x0d04} /* Cn */,
+ { 0x0d0d, 0x0d0d} /* Cn */, { 0x0d11, 0x0d11} /* Cn */,
+ { 0x0d29, 0x0d29} /* Cn */, { 0x0d3a, 0x0d3d} /* Cn */,
+ { 0x0d44, 0x0d45} /* Cn */, { 0x0d49, 0x0d49} /* Cn */,
+ { 0x0d4e, 0x0d56} /* Cn */, { 0x0d58, 0x0d5f} /* Cn */,
+ { 0x0d62, 0x0d65} /* Cn */, { 0x0d70, 0x0d81} /* Cn */,
+ { 0x0d84, 0x0d84} /* Cn */, { 0x0d97, 0x0d99} /* Cn */,
+ { 0x0db2, 0x0db2} /* Cn */, { 0x0dbc, 0x0dbc} /* Cn */,
+ { 0x0dbe, 0x0dbf} /* Cn */, { 0x0dc7, 0x0dc9} /* Cn */,
+ { 0x0dcb, 0x0dce} /* Cn */, { 0x0dd5, 0x0dd5} /* Cn */,
+ { 0x0dd7, 0x0dd7} /* Cn */, { 0x0de0, 0x0df1} /* Cn */,
+ { 0x0df5, 0x0e00} /* Cn */, { 0x0e3b, 0x0e3e} /* Cn */,
+ { 0x0e5c, 0x0e80} /* Cn */, { 0x0e83, 0x0e83} /* Cn */,
+ { 0x0e85, 0x0e86} /* Cn */, { 0x0e89, 0x0e89} /* Cn */,
+ { 0x0e8b, 0x0e8c} /* Cn */, { 0x0e8e, 0x0e93} /* Cn */,
+ { 0x0e98, 0x0e98} /* Cn */, { 0x0ea0, 0x0ea0} /* Cn */,
+ { 0x0ea4, 0x0ea4} /* Cn */, { 0x0ea6, 0x0ea6} /* Cn */,
+ { 0x0ea8, 0x0ea9} /* Cn */, { 0x0eac, 0x0eac} /* Cn */,
+ { 0x0eba, 0x0eba} /* Cn */, { 0x0ebe, 0x0ebf} /* Cn */,
+ { 0x0ec5, 0x0ec5} /* Cn */, { 0x0ec7, 0x0ec7} /* Cn */,
+ { 0x0ece, 0x0ecf} /* Cn */, { 0x0eda, 0x0edb} /* Cn */,
+ { 0x0ede, 0x0eff} /* Cn */, { 0x0f48, 0x0f48} /* Cn */,
+ { 0x0f6b, 0x0f70} /* Cn */, { 0x0f8c, 0x0f8f} /* Cn */,
+ { 0x0f98, 0x0f98} /* Cn */, { 0x0fbd, 0x0fbd} /* Cn */,
+ { 0x0fcd, 0x0fce} /* Cn */, { 0x0fd0, 0x0fff} /* Cn */,
+ { 0x1022, 0x1022} /* Cn */, { 0x1028, 0x1028} /* Cn */,
+ { 0x102b, 0x102b} /* Cn */, { 0x1033, 0x1035} /* Cn */,
+ { 0x103a, 0x103f} /* Cn */, { 0x105a, 0x109f} /* Cn */,
+ { 0x10c6, 0x10cf} /* Cn */, { 0x10f9, 0x10fa} /* Cn */,
+ { 0x10fc, 0x10ff} /* Cn */, { 0x115a, 0x115e} /* Cn */,
+ { 0x11a3, 0x11a7} /* Cn */, { 0x11fa, 0x11ff} /* Cn */,
+ { 0x1207, 0x1207} /* Cn */, { 0x1247, 0x1247} /* Cn */,
+ { 0x1249, 0x1249} /* Cn */, { 0x124e, 0x124f} /* Cn */,
+ { 0x1257, 0x1257} /* Cn */, { 0x1259, 0x1259} /* Cn */,
+ { 0x125e, 0x125f} /* Cn */, { 0x1287, 0x1287} /* Cn */,
+ { 0x1289, 0x1289} /* Cn */, { 0x128e, 0x128f} /* Cn */,
+ { 0x12af, 0x12af} /* Cn */, { 0x12b1, 0x12b1} /* Cn */,
+ { 0x12b6, 0x12b7} /* Cn */, { 0x12bf, 0x12bf} /* Cn */,
+ { 0x12c1, 0x12c1} /* Cn */, { 0x12c6, 0x12c7} /* Cn */,
+ { 0x12cf, 0x12cf} /* Cn */, { 0x12d7, 0x12d7} /* Cn */,
+ { 0x12ef, 0x12ef} /* Cn */, { 0x130f, 0x130f} /* Cn */,
+ { 0x1311, 0x1311} /* Cn */, { 0x1316, 0x1317} /* Cn */,
+ { 0x131f, 0x131f} /* Cn */, { 0x1347, 0x1347} /* Cn */,
+ { 0x135b, 0x1360} /* Cn */, { 0x137d, 0x139f} /* Cn */,
+ { 0x13f5, 0x1400} /* Cn */, { 0x1677, 0x167f} /* Cn */,
+ { 0x169d, 0x169f} /* Cn */, { 0x16f1, 0x16ff} /* Cn */,
+ { 0x170d, 0x170d} /* Cn */, { 0x1715, 0x171f} /* Cn */,
+ { 0x1737, 0x173f} /* Cn */, { 0x1754, 0x175f} /* Cn */,
+ { 0x176d, 0x176d} /* Cn */, { 0x1771, 0x1771} /* Cn */,
+ { 0x1774, 0x177f} /* Cn */,
+#if 0
+ { 0x17b4, 0x17b5} /* Cf */,
+#endif
+ { 0x17de, 0x17df} /* Cn */, { 0x17ea, 0x17ef} /* Cn */,
+ { 0x17fa, 0x17ff} /* Cn */, { 0x180f, 0x180f} /* Cn */,
+ { 0x181a, 0x181f} /* Cn */, { 0x1878, 0x187f} /* Cn */,
+ { 0x18aa, 0x18ff} /* Cn */, { 0x191d, 0x191f} /* Cn */,
+ { 0x192c, 0x192f} /* Cn */, { 0x193c, 0x193f} /* Cn */,
+ { 0x1941, 0x1943} /* Cn */, { 0x196e, 0x196f} /* Cn */,
+ { 0x1975, 0x19df} /* Cn */, { 0x1a00, 0x1cff} /* Cn */,
+ { 0x1d6c, 0x1dff} /* Cn */, { 0x1e9c, 0x1e9f} /* Cn */,
+ { 0x1efa, 0x1eff} /* Cn */, { 0x1f16, 0x1f17} /* Cn */,
+ { 0x1f1e, 0x1f1f} /* Cn */, { 0x1f46, 0x1f47} /* Cn */,
+ { 0x1f4e, 0x1f4f} /* Cn */, { 0x1f58, 0x1f58} /* Cn */,
+ { 0x1f5a, 0x1f5a} /* Cn */, { 0x1f5c, 0x1f5c} /* Cn */,
+ { 0x1f5e, 0x1f5e} /* Cn */, { 0x1f7e, 0x1f7f} /* Cn */,
+ { 0x1fb5, 0x1fb5} /* Cn */, { 0x1fc5, 0x1fc5} /* Cn */,
+ { 0x1fd4, 0x1fd5} /* Cn */, { 0x1fdc, 0x1fdc} /* Cn */,
+ { 0x1ff0, 0x1ff1} /* Cn */, { 0x1ff5, 0x1ff5} /* Cn */,
+ { 0x1fff, 0x1fff} /* Cn */, { 0x200b, 0x200f} /* Cf */,
+ { 0x2028, 0x2028} /* Zl */,
+ { 0x2029, 0x2029} /* Zp */,
+ { 0x202a, 0x202e} /* Cf */,
+ { 0x2055, 0x2056} /* Cn */, { 0x2058, 0x205e} /* Cn */,
+ { 0x2060, 0x2063} /* Cf */,
+ { 0x2064, 0x2069} /* Cn */,
+ { 0x206a, 0x206f} /* Cf */,
+ { 0x2072, 0x2073} /* Cn */, { 0x208f, 0x209f} /* Cn */,
+ { 0x20b2, 0x20cf} /* Cn */, { 0x20eb, 0x20ff} /* Cn */,
+ { 0x213c, 0x213c} /* Cn */, { 0x214c, 0x2152} /* Cn */,
+ { 0x2184, 0x218f} /* Cn */, { 0x23d1, 0x23ff} /* Cn */,
+ { 0x2427, 0x243f} /* Cn */, { 0x244b, 0x245f} /* Cn */,
+ { 0x2618, 0x2618} /* Cn */, { 0x267e, 0x267f} /* Cn */,
+ { 0x2692, 0x269f} /* Cn */, { 0x26a2, 0x2700} /* Cn */,
+ { 0x2705, 0x2705} /* Cn */, { 0x270a, 0x270b} /* Cn */,
+ { 0x2728, 0x2728} /* Cn */, { 0x274c, 0x274c} /* Cn */,
+ { 0x274e, 0x274e} /* Cn */, { 0x2753, 0x2755} /* Cn */,
+ { 0x2757, 0x2757} /* Cn */, { 0x275f, 0x2760} /* Cn */,
+ { 0x2795, 0x2797} /* Cn */, { 0x27b0, 0x27b0} /* Cn */,
+ { 0x27bf, 0x27cf} /* Cn */, { 0x27ec, 0x27ef} /* Cn */,
+ { 0x2b0e, 0x2e7f} /* Cn */, { 0x2e9a, 0x2e9a} /* Cn */,
+ { 0x2ef4, 0x2eff} /* Cn */, { 0x2fd6, 0x2fef} /* Cn */,
+ { 0x2ffc, 0x2fff} /* Cn */, { 0x3040, 0x3040} /* Cn */,
+ { 0x3097, 0x3098} /* Cn */, { 0x3100, 0x3104} /* Cn */,
+ { 0x312d, 0x3130} /* Cn */, { 0x318f, 0x318f} /* Cn */,
+ { 0x31b8, 0x31ef} /* Cn */, { 0x321f, 0x321f} /* Cn */,
+ { 0x3244, 0x324f} /* Cn */, { 0x327e, 0x327e} /* Cn */,
+ { 0x32ff, 0x32ff} /* Cn */, { 0x4db6, 0x4dbf} /* Cn */,
+ { 0x9fa6, 0x9fff} /* Cn */, { 0xa48d, 0xa48f} /* Cn */,
+ { 0xa4c7, 0xabff} /* Cn */, { 0xd7a4, 0xd7ff} /* Cn */,
+ { 0xd800, 0xdfff} /* Cs */,
+ { 0xe000, 0xf8ff} /* Co */,
+ { 0xfa2e, 0xfa2f} /* Cn */, { 0xfa6b, 0xfaff} /* Cn */,
+ { 0xfb07, 0xfb12} /* Cn */, { 0xfb18, 0xfb1c} /* Cn */,
+ { 0xfb37, 0xfb37} /* Cn */, { 0xfb3d, 0xfb3d} /* Cn */,
+ { 0xfb3f, 0xfb3f} /* Cn */, { 0xfb42, 0xfb42} /* Cn */,
+ { 0xfb45, 0xfb45} /* Cn */, { 0xfbb2, 0xfbd2} /* Cn */,
+ { 0xfd40, 0xfd4f} /* Cn */, { 0xfd90, 0xfd91} /* Cn */,
+ { 0xfdc8, 0xfdef} /* Cn */, { 0xfdfe, 0xfdff} /* Cn */,
+ { 0xfe10, 0xfe1f} /* Cn */, { 0xfe24, 0xfe2f} /* Cn */,
+ { 0xfe53, 0xfe53} /* Cn */, { 0xfe67, 0xfe67} /* Cn */,
+ { 0xfe6c, 0xfe6f} /* Cn */, { 0xfe75, 0xfe75} /* Cn */,
+ { 0xfefd, 0xfefe} /* Cn */,
+ { 0xfeff, 0xfeff} /* Cf */,
+ { 0xff00, 0xff00} /* Cn */, { 0xffbf, 0xffc1} /* Cn */,
+ { 0xffc8, 0xffc9} /* Cn */, { 0xffd0, 0xffd1} /* Cn */,
+ { 0xffd8, 0xffd9} /* Cn */, { 0xffdd, 0xffdf} /* Cn */,
+ { 0xffe7, 0xffe7} /* Cn */, { 0xffef, 0xfff8} /* Cn */,
+ { 0xfff9, 0xfffb} /* Cf */,
+ { 0xfffe, 0xffff} /* Cn */, { 0x1000c, 0x1000c} /* Cn */,
+ { 0x10027, 0x10027} /* Cn */, { 0x1003b, 0x1003b} /* Cn */,
+ { 0x1003e, 0x1003e} /* Cn */, { 0x1004e, 0x1004f} /* Cn */,
+ { 0x1005e, 0x1007f} /* Cn */, { 0x100fb, 0x100ff} /* Cn */,
+ { 0x10103, 0x10106} /* Cn */, { 0x10134, 0x10136} /* Cn */,
+ { 0x10140, 0x102ff} /* Cn */, { 0x1031f, 0x1031f} /* Cn */,
+ { 0x10324, 0x1032f} /* Cn */, { 0x1034b, 0x1037f} /* Cn */,
+ { 0x1039e, 0x1039e} /* Cn */, { 0x103a0, 0x103ff} /* Cn */,
+ { 0x1049e, 0x1049f} /* Cn */, { 0x104aa, 0x107ff} /* Cn */,
+ { 0x10806, 0x10807} /* Cn */, { 0x10809, 0x10809} /* Cn */,
+ { 0x10836, 0x10836} /* Cn */, { 0x10839, 0x1083b} /* Cn */,
+ { 0x1083d, 0x1083e} /* Cn */, { 0x10840, 0x1cfff} /* Cn */,
+ { 0x1d0f6, 0x1d0ff} /* Cn */, { 0x1d127, 0x1d129} /* Cn */,
+ { 0x1d173, 0x1d17a} /* Cf */,
+ { 0x1d1de, 0x1d2ff} /* Cn */, { 0x1d357, 0x1d3ff} /* Cn */,
+ { 0x1d455, 0x1d455} /* Cn */, { 0x1d49d, 0x1d49d} /* Cn */,
+ { 0x1d4a0, 0x1d4a1} /* Cn */, { 0x1d4a3, 0x1d4a4} /* Cn */,
+ { 0x1d4a7, 0x1d4a8} /* Cn */, { 0x1d4ad, 0x1d4ad} /* Cn */,
+ { 0x1d4ba, 0x1d4ba} /* Cn */, { 0x1d4bc, 0x1d4bc} /* Cn */,
+ { 0x1d4c4, 0x1d4c4} /* Cn */, { 0x1d506, 0x1d506} /* Cn */,
+ { 0x1d50b, 0x1d50c} /* Cn */, { 0x1d515, 0x1d515} /* Cn */,
+ { 0x1d51d, 0x1d51d} /* Cn */, { 0x1d53a, 0x1d53a} /* Cn */,
+ { 0x1d53f, 0x1d53f} /* Cn */, { 0x1d545, 0x1d545} /* Cn */,
+ { 0x1d547, 0x1d549} /* Cn */, { 0x1d551, 0x1d551} /* Cn */,
+ { 0x1d6a4, 0x1d6a7} /* Cn */, { 0x1d7ca, 0x1d7cd} /* Cn */,
+ { 0x1d800, 0x1ffff} /* Cn */, { 0x2a6d7, 0x2f7ff} /* Cn */,
+ { 0x2fa1e, 0xe0000} /* Cn */,
+ { 0xe0001, 0xe0001} /* Cf */,
+ { 0xe0002, 0xe001f} /* Cn */,
+ { 0xe0020, 0xe007f} /* Cf */,
+ { 0xe0080, 0xe00ff} /* Cn */, { 0xe01f0, 0xeffff} /* Cn */,
+ { 0xf0000, 0xffffd} /* Co */,
+ { 0xffffe, 0xfffff} /* Cn */,
+ {0x100000,0x10fffd} /* Co */,
+ {0x10fffe,0x10ffff} /* Cn */,
+ {0x110000,0x7fffffff} /* ISO 10646?? */
+};
+
+/*
+ * Double width characters
+ * W: East Asian Wide
+ * F: East Asian Full-width
+ */
+static struct wchar_range wide_table[] = {
+ { 0x1100, 0x115f} /* W */, { 0x2329, 0x232a} /* W */,
+ { 0x2E80, 0x2FFB} /* W */,
+ { 0x3000, 0x3000} /* F */,
+ { 0x3001, 0x303E} /* W */, { 0x3041, 0x4DB5} /* W */,
+ { 0x4E00, 0x9FA5} /* W */, { 0xA000, 0xA4C6} /* W */,
+ { 0xAC00, 0xD7A3} /* W */, { 0xF900, 0xFA6A} /* W */,
+ { 0xFE30, 0xFE6B} /* W */,
+ { 0xFF01, 0xFF60} /* F */, { 0xFFE0, 0xFFE6} /* F */,
+ { 0x20000, 0x2FFFD} /* W */, { 0x30000, 0x3FFFD} /* W */,
+
+};
+
+ static int
+is_in_table(ch, table, tsize)
+ LWCHAR ch;
+ struct wchar_range table[];
+ int tsize;
+{
+ int hi;
+ int lo;
+
+ /* Binary search in the table. */
+ if (ch < table[0].first)
+ return 0;
+ lo = 0;
+ hi = tsize - 1;
+ while (lo <= hi)
+ {
+ int mid = (lo + hi) / 2;
+ if (ch > table[mid].last)
+ lo = mid + 1;
+ else if (ch < table[mid].first)
+ hi = mid - 1;
+ else
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * Is a character a UTF-8 composing character?
+ * If a composing character follows any char, the two combine into one glyph.
+ */
public int
-control_char(c)
- int c;
+is_composing_char(ch)
+ LWCHAR ch;
{
- return (iscntrl(c));
+ return is_in_table(ch, comp_table, (sizeof(comp_table) /
sizeof(*comp_table)));
}
/*
- * Return the printable form of a character.
- * For example, in the "ascii" charset '\3' is printed as "^C".
+ * Should this UTF-8 character be treated as binary?
*/
- public char *
-prchar(c)
- int c;
+ public int
+is_ubin_char(ch)
+ LWCHAR ch;
{
- static char buf[8];
+ return is_in_table(ch, ubin_table, (sizeof(ubin_table) /
sizeof(*ubin_table)));
+}
- c &= 0377;
- if (!iscntrl(c))
- snprintf(buf, sizeof(buf), "%c", c);
- else if (c == ESC)
- snprintf(buf, sizeof(buf), "ESC");
- else if (c < 128 && !iscntrl(c ^ 0100))
- snprintf(buf, sizeof(buf), "^%c", c ^ 0100);
- else
- snprintf(buf, sizeof(buf), "*s<%X>", c);
- return (buf);
+/*
+ * Is this a double width UTF-8 character?
+ */
+ public int
+is_wide_char(ch)
+ LWCHAR ch;
+{
+ return is_in_table(ch, wide_table, (sizeof(wide_table) /
sizeof(*wide_table)));
}
-#endif /* SMALL */
+
+/*
+ * Is a character a UTF-8 combining character?
+ * A combining char acts like an ordinary char, but if it follows
+ * a specific char (not any char), the two combine into one glyph.
+ */
+ public int
+is_combining_char(ch1, ch2)
+ LWCHAR ch1;
+ LWCHAR ch2;
+{
+ /* The table is small; use linear search. */
+ int i;
+ for (i = 0; i < sizeof(comb_table)/sizeof(*comb_table); i++)
+ {
+ if (ch1 == comb_table[i].first &&
+ ch2 == comb_table[i].last)
+ return 1;
+ }
+ return 0;
+}
+
diff -urN /usr/src/usr.bin/less/charset.h less/charset.h
--- /usr/src/usr.bin/less/charset.h Thu Jan 1 03:00:00 1970
+++ less/charset.h Mon May 23 02:22:08 2011
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2005 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+#define IS_ASCII_OCTET(c) (((c) & 0x80) == 0)
+#define IS_UTF8_TRAIL(c) (((c) & 0xC0) == 0x80)
+#define IS_UTF8_LEAD2(c) (((c) & 0xE0) == 0xC0)
+#define IS_UTF8_LEAD3(c) (((c) & 0xF0) == 0xE0)
+#define IS_UTF8_LEAD4(c) (((c) & 0xF8) == 0xF0)
+#define IS_UTF8_LEAD5(c) (((c) & 0xFC) == 0xF8)
+#define IS_UTF8_LEAD6(c) (((c) & 0xFE) == 0xFC)
+#define IS_UTF8_INVALID(c) (((c) & 0xFE) == 0xFE)
+#define IS_UTF8_LEAD(c) (((c) & 0xC0) == 0xC0 && !IS_UTF8_INVALID(c))
diff -urN /usr/src/usr.bin/less/cmdbuf.c less/cmdbuf.c
--- /usr/src/usr.bin/less/cmdbuf.c Sun Jan 23 20:53:13 2011
+++ less/cmdbuf.c Mon May 23 02:21:36 2011
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2002 Mark Nudelman
+ * Copyright (C) 1984-2005 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -16,8 +16,13 @@
#include "less.h"
#include "cmd.h"
+#include "charset.h"
+#if HAVE_STAT
+#include <sys/stat.h>
+#endif
extern int sc_width;
+extern int utf_mode;
static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */
static int cmd_col; /* Current column of the cursor */
@@ -93,7 +98,11 @@
static struct mlist *curr_mlist = NULL;
static int curr_cmdflags;
+static char cmd_mbc_buf[MAX_UTF_CHAR_LEN];
+static int cmd_mbc_buf_len;
+static int cmd_mbc_buf_index;
+
/*
* Reset command buffer (to empty).
*/
@@ -105,6 +114,7 @@
cmd_col = 0;
cmd_offset = 0;
literal = 0;
+ cmd_mbc_buf_len = 0;
}
/*
@@ -115,6 +125,7 @@
{
clear_bot();
cmd_col = prompt_col = 0;
+ cmd_mbc_buf_len = 0;
}
/*
@@ -124,9 +135,28 @@
cmd_putstr(s)
char *s;
{
- putstr(s);
- cmd_col += strlen(s);
- prompt_col += strlen(s);
+ LWCHAR prev_ch = 0;
+ LWCHAR ch;
+ char *endline = s + strlen(s);
+ while (*s != '\0')
+ {
+ char *ns = s;
+ ch = step_char(&ns, +1, endline);
+ while (s < ns)
+ putchr(*s++);
+ if (!utf_mode)
+ {
+ cmd_col++;
+ prompt_col++;
+ } else if (!is_composing_char(ch) &&
+ !is_combining_char(prev_ch, ch))
+ {
+ int width = is_wide_char(ch) ? 2 : 1;
+ cmd_col += width;
+ prompt_col += width;
+ }
+ prev_ch = ch;
+ }
}
/*
@@ -135,10 +165,116 @@
public int
len_cmdbuf()
{
- return (strlen(cmdbuf));
+ char *s = cmdbuf;
+ char *endline = s + strlen(s);
+ int len = 0;
+
+ while (*s != '\0')
+ {
+ step_char(&s, +1, endline);
+ len++;
+ }
+ return (len);
}
/*
+ * Common part of cmd_step_right() and cmd_step_left().
+ */
+ static char *
+cmd_step_common(p, ch, len, pwidth, bswidth)
+ char *p;
+ LWCHAR ch;
+ int len;
+ int *pwidth;
+ int *bswidth;
+{
+ char *pr;
+
+ if (len == 1)
+ {
+ pr = prchar((int) ch);
+ if (pwidth != NULL || bswidth != NULL)
+ {
+ int len = strlen(pr);
+ if (pwidth != NULL)
+ *pwidth = len;
+ if (bswidth != NULL)
+ *bswidth = len;
+ }
+ } else
+ {
+ pr = prutfchar(ch);
+ if (pwidth != NULL || bswidth != NULL)
+ {
+ if (is_composing_char(ch))
+ {
+ if (pwidth != NULL)
+ *pwidth = 0;
+ if (bswidth != NULL)
+ *bswidth = 0;
+ } else if (is_ubin_char(ch))
+ {
+ int len = strlen(pr);
+ if (pwidth != NULL)
+ *pwidth = len;
+ if (bswidth != NULL)
+ *bswidth = len;
+ } else
+ {
+ LWCHAR prev_ch = step_char(&p, -1, cmdbuf);
+ if (is_combining_char(prev_ch, ch))
+ {
+ if (pwidth != NULL)
+ *pwidth = 0;
+ if (bswidth != NULL)
+ *bswidth = 0;
+ } else
+ {
+ if (pwidth != NULL)
+ *pwidth = is_wide_char(ch)
+ ? 2
+ : 1;
+ if (bswidth != NULL)
+ *bswidth = 1;
+ }
+ }
+ }
+ }
+
+ return (pr);
+}
+
+/*
+ * Step a pointer one character right in the command buffer.
+ */
+ static char *
+cmd_step_right(pp, pwidth, bswidth)
+ char **pp;
+ int *pwidth;
+ int *bswidth;
+{
+ char *p = *pp;
+ LWCHAR ch = step_char(pp, +1, p + strlen(p));
+
+ return cmd_step_common(p, ch, *pp - p, pwidth, bswidth);
+}
+
+/*
+ * Step a pointer one character left in the command buffer.
+ */
+ static char *
+cmd_step_left(pp, pwidth, bswidth)
+ char **pp;
+ int *pwidth;
+ int *bswidth;
+{
+ char *p = *pp;
+ LWCHAR ch = step_char(pp, -1, cmdbuf);
+
+ return cmd_step_common(*pp, ch, p - *pp, pwidth, bswidth);
+}
+
+/*
* Repaint the line from cp onwards.
* Then position the cursor just after the char old_cp (a pointer into cmdbuf).
*/
@@ -146,20 +282,31 @@
cmd_repaint(old_cp)
char *old_cp;
{
- char *p;
-
/*
* Repaint the line from the current position.
*/
clear_eol();
- for ( ; *cp != '\0'; cp++)
+ while (*cp != '\0')
{
- p = prchar(*cp);
- if (cmd_col + (int)strlen(p) >= sc_width)
+ char *np = cp;
+ int width;
+ char *pr = cmd_step_right(&np, &width, NULL);
+ if (cmd_col + width >= sc_width)
break;
- putstr(p);
- cmd_col += strlen(p);
+ cp = np;
+ putstr(pr);
+ cmd_col += width;
}
+ while (*cp != '\0')
+ {
+ char *np = cp;
+ int width;
+ char *pr = cmd_step_right(&np, &width, NULL);
+ if (width > 0)
+ break;
+ cp = np;
+ putstr(pr);
+ }
/*
* Back up the cursor to the correct position.
@@ -177,8 +324,12 @@
{
while (cmd_col > prompt_col)
{
- putbs();
- cmd_col--;
+ int width, bswidth;
+
+ cmd_step_left(&cp, &width, &bswidth);
+ while (bswidth-- > 0)
+ putbs();
+ cmd_col -= width;
}
cp = &cmdbuf[cmd_offset];
@@ -201,7 +352,20 @@
s = cmdbuf + cmd_offset;
cols = 0;
while (cols < (sc_width - prompt_col) / 2 && *s != '\0')
- cols += strlen(prchar(*s++));
+ {
+ int width;
+ cmd_step_right(&s, &width, NULL);
+ cols += width;
+ }
+ while (*s != '\0')
+ {
+ int width;
+ char *ns = s;
+ cmd_step_right(&ns, &width, NULL);
+ if (width > 0)
+ break;
+ s = ns;
+ }
cmd_offset = s - cmdbuf;
save_cp = cp;
@@ -216,7 +380,6 @@
cmd_rshift()
{
char *s;
- char *p;
char *save_cp;
int cols;
@@ -229,8 +392,9 @@
cols = 0;
while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf)
{
- p = prchar(*--s);
- cols += strlen(p);
+ int width;
+ cmd_step_left(&s, &width, NULL);
+ cols += width;
}
cmd_offset = s - cmdbuf;
@@ -245,23 +409,32 @@
static int
cmd_right()
{
- char *p;
+ char *pr;
+ char *ncp;
+ int width;
if (*cp == '\0')
{
- /*
- * Already at the end of the line.
- */
+ /* Already at the end of the line. */
return (CC_OK);
}
- p = prchar(*cp);
- if (cmd_col + (int)strlen(p) >= sc_width)
+ ncp = cp;
+ pr = cmd_step_right(&ncp, &width, NULL);
+ if (cmd_col + width >= sc_width)
cmd_lshift();
- else if (cmd_col + (int)strlen(p) == sc_width - 1 && cp[1] != '\0')
+ else if (cmd_col + width == sc_width - 1 && cp[1] != '\0')
cmd_lshift();
- cp++;
- putstr(p);
- cmd_col += strlen(p);
+ cp = ncp;
+ cmd_col += width;
+ putstr(pr);
+ while (*cp != '\0')
+ {
+ pr = cmd_step_right(&ncp, &width, NULL);
+ if (width > 0)
+ break;
+ putstr(pr);
+ cp = ncp;
+ }
return (CC_OK);
}
@@ -271,19 +444,26 @@
static int
cmd_left()
{
- char *p;
+ char *ncp;
+ int width, bswidth;
if (cp <= cmdbuf)
{
/* Already at the beginning of the line */
return (CC_OK);
}
- p = prchar(cp[-1]);
- if (cmd_col < prompt_col + (int)strlen(p))
+ ncp = cp;
+ while (ncp > cmdbuf)
+ {
+ cmd_step_left(&ncp, &width, &bswidth);
+ if (width > 0)
+ break;
+ }
+ if (cmd_col < prompt_col + width)
cmd_rshift();
- cp--;
- cmd_col -= strlen(p);
- while (*p++ != '\0')
+ cp = ncp;
+ cmd_col -= width;
+ while (bswidth-- > 0)
putbs();
return (CC_OK);
}
@@ -292,27 +472,30 @@
* Insert a char into the command buffer, at the current position.
*/
static int
-cmd_ichar(c)
- int c;
+cmd_ichar(cs, clen)
+ char *cs;
+ int clen;
{
char *s;
- if (strlen(cmdbuf) >= sizeof(cmdbuf)-2)
+ if (strlen(cmdbuf) + clen >= sizeof(cmdbuf)-1)
{
- /*
- * No room in the command buffer for another char.
- */
+ /* No room in the command buffer for another char. */
bell();
return (CC_ERROR);
}
/*
- * Insert the character into the buffer.
+ * Make room for the new character (shift the tail of the buffer right).
*/
for (s = &cmdbuf[strlen(cmdbuf)]; s >= cp; s--)
- s[1] = s[0];
- *cp = c;
+ s[clen] = s[0];
/*
+ * Insert the character into the buffer.
+ */
+ for (s = cp; s < cp + clen; s++)
+ *s = *cs++;
+ /*
* Reprint the tail of the line from the inserted char.
*/
cmd_repaint(cp);
@@ -328,6 +511,7 @@
cmd_erase()
{
register char *s;
+ int clen;
if (cp == cmdbuf)
{
@@ -340,12 +524,20 @@
/*
* Move cursor left (to the char being erased).
*/
+ s = cp;
cmd_left();
+ clen = s - cp;
+
/*
* Remove the char from the buffer (shift the buffer left).
*/
- for (s = cp; *s != '\0'; s++)
- s[0] = s[1];
+ for (s = cp; ; s++)
+ {
+ s[0] = s[clen];
+ if (s[0] == '\0')
+ break;
+ }
+
/*
* Repaint the buffer after the erased char.
*/
@@ -368,9 +560,7 @@
{
if (*cp == '\0')
{
- /*
- * At end of string; there is no char under the cursor.
- */
+ /* At end of string; there is no char under the cursor. */
return (CC_OK);
}
/*
@@ -441,9 +631,7 @@
{
if (cmdbuf[0] == '\0')
{
- /*
- * Buffer is already empty; abort the current command.
- */
+ /* Buffer is already empty; abort the current command. */
return (CC_QUIT);
}
cmd_offset = 0;
@@ -470,6 +658,10 @@
{
curr_mlist = (struct mlist *) mlist;
curr_cmdflags = cmdflags;
+
+ /* Make sure the next up-arrow moves to the last string in the mlist. */
+ if (curr_mlist != NULL)
+ curr_mlist->curr_mp = curr_mlist;
}
#if CMD_HISTORY
@@ -505,12 +697,9 @@
s = curr_mlist->curr_mp->string;
if (s == NULL)
s = "";
- for (cp = cmdbuf; *s != '\0'; s++)
- {
- *cp = *s;
+ strcpy(cmdbuf, s);
+ for (cp = cmdbuf; *cp != '\0'; )
cmd_right();
- }
- *cp = '\0';
return (CC_OK);
}
#endif
@@ -531,18 +720,14 @@
*/
if (strlen(cmd) == 0)
return;
+
/*
- * Don't save if a duplicate of a command which is already
- * in the history.
- * But select the one already in the history to be current.
+ * Save the command unless it's a duplicate of the
+ * last command in the history.
*/
- for (ml = mlist->next; ml != mlist; ml = ml->next)
+ ml = mlist->prev;
+ if (ml == mlist || strcmp(ml->string, cmd) != 0)
{
- if (strcmp(ml->string, cmd) == 0)
- break;
- }
- if (ml == mlist)
- {
/*
* Did not find command in history.
* Save the command and put it at the end of the history list.
@@ -705,10 +890,13 @@
{
char *s;
int action;
+ char *endline = str + strlen(str);
- for (s = str; *s != '\0'; s++)
+ for (s = str; *s != '\0'; )
{
- action = cmd_ichar(*s);
+ char *os = s;
+ step_char(&s, +1, endline);
+ action = cmd_ichar(os, s - os);
if (action != CC_OK)
{
bell();
@@ -995,20 +1183,70 @@
int c;
{
int action;
+ int len;
+ if (!utf_mode)
+ {
+ cmd_mbc_buf[0] = c;
+ len = 1;
+ } else
+ {
+ /* Perform strict validation in all possible cases. */
+ if (cmd_mbc_buf_len == 0)
+ {
+ retry:
+ cmd_mbc_buf_index = 1;
+ *cmd_mbc_buf = c;
+ if (IS_ASCII_OCTET(c))
+ cmd_mbc_buf_len = 1;
+ else if (IS_UTF8_LEAD(c))
+ {
+ cmd_mbc_buf_len = utf_len(c);
+ return (CC_OK);
+ } else
+ {
+ /* UTF8_INVALID or stray UTF8_TRAIL */
+ bell();
+ return (CC_ERROR);
+ }
+ } else if (IS_UTF8_TRAIL(c))
+ {
+ cmd_mbc_buf[cmd_mbc_buf_index++] = c;
+ if (cmd_mbc_buf_index < cmd_mbc_buf_len)
+ return (CC_OK);
+ if (!is_utf8_well_formed(cmd_mbc_buf))
+ {
+ /* complete, but not well formed (non-shortest
form), sequence */
+ cmd_mbc_buf_len = 0;
+ bell();
+ return (CC_ERROR);
+ }
+ } else
+ {
+ /* Flush incomplete (truncated) sequence. */
+ cmd_mbc_buf_len = 0;
+ bell();
+ /* Handle new char. */
+ goto retry;
+ }
+
+ len = cmd_mbc_buf_len;
+ cmd_mbc_buf_len = 0;
+ }
+
if (literal)
{
/*
* Insert the char, even if it is a line-editing char.
*/
literal = 0;
- return (cmd_ichar(c));
+ return (cmd_ichar(cmd_mbc_buf, len));
}
/*
- * See if it is a special line-editing character.
+ * See if it is a line-editing character.
*/
- if (in_mca())
+ if (in_mca() && len == 1)
{
action = cmd_edit(c);
switch (action)
@@ -1024,7 +1262,7 @@
/*
* Insert the char into the command buffer.
*/
- return (cmd_ichar(c));
+ return (cmd_ichar(cmd_mbc_buf, len));
}
/*
diff -urN /usr/src/usr.bin/less/less.h less/less.h
--- /usr/src/usr.bin/less/less.h Sun Jan 23 20:53:13 2011
+++ less/less.h Mon May 23 02:21:36 2011
@@ -153,9 +153,11 @@
/*
* Special types and constants.
*/
+typedef unsigned long LWCHAR;
typedef off_t POSITION;
typedef off_t LINENUM;
#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */
+#define MAX_UTF_CHAR_LEN 6 /* Max bytes in one UTF-8 char */
#define NULL_POSITION ((POSITION)(-1))
dmesg:
OpenBSD 4.9-current (kernel) #7: Mon May 23 01:13:34 MSD 2011
[email protected]:/usr/obj/kernel
real mem = 1876754432 (1789MB)
avail mem = 1812729856 (1728MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xf0920 (43 entries)
bios0: vendor LENOVO version "6XET47WW (1.30 )" date 12/30/2010
bios0: LENOVO 3508RL6
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP TCPA SSDT APIC MCFG HPET SLIC
acpi0: wakeup devices PB5_(S5) OHC0(S3) OHC1(S3) OHC2(S3) OHC3(S3) OHC4(S3)
P2P_(S5) LID_(S3)
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Athlon(tm) Neo X2 Dual Core Processor L335, 1597.26 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,CX16,NXE,MMXX,FFXSR,LONG,3DNOW2,3DNOW
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 256KB 64b/line
16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: DTLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: apic clock running at 199MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD Athlon(tm) Neo X2 Dual Core Processor L335, 1596.00 MHz
cpu1:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,CX16,NXE,MMXX,FFXSR,LONG,3DNOW2,3DNOW
cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 256KB 64b/line
16-way L2 cache
cpu1: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu1: DTLB 32 4KB entries fully associative, 8 4MB entries fully associative
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 21, 24 pins
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-3
acpihpet0 at acpi0: 14318180 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (PB5_)
acpiprt2 at acpi0: bus 4 (P2P_)
acpiprt3 at acpi0: bus 1 (AGP_)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2, PSS
acpicpu1 at acpi0: PSS
acpitz0 at acpi0: critical temperature 92 degC
acpibtn0 at acpi0: PWRB
acpibtn1 at acpi0: SLPB
acpithinkpad0 at acpi0
acpiac0 at acpi0: AC unit online
acpibat0 at acpi0: BAT1 model "42T4785" serial 958 type LION oem "SANYO"
acpibtn2 at acpi0: LID_
cpu0: PowerNow! K8 1596 MHz: speeds: 1600 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "AMD RS780 Host" rev 0x00
ppb0 at pci0 dev 1 function 0 "AMD RS780 PCIE" rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 5 function 0 "ATI Radeon HD 3200" rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
radeondrm0 at vga1: apic 2 int 18
drm0 at radeondrm0
ppb1 at pci0 dev 5 function 0 "AMD RS780 PCIE" rev 0x00: apic 2 int 17
pci2 at ppb1 bus 2
re0 at pci2 dev 0 function 0 "Realtek 8168" rev 0x03: RTL8168D/8111D (0x2800),
apic 2 int 17, address c8:0a:a9:cc:b0:01
rgephy0 at re0 phy 7: RTL8169S/8110S PHY, rev. 2
ahci0 at pci0 dev 17 function 0 "ATI SBx00 SATA" rev 0x00: apic 2 int 22, AHCI
1.1
scsibus0 at ahci0: 32 targets
sd0 at scsibus0 targ 0 lun 0: <ATA, WDC WD2500BEVT-0, 02.0> SCSI3 0/direct
fixed naa.50014ee204a69fb1
sd0: 238475MB, 512 bytes/sec, 488397168 sec total
ohci0 at pci0 dev 18 function 0 "ATI SB700 USB" rev 0x00: apic 2 int 16,
version 1.0, legacy support
ohci1 at pci0 dev 18 function 1 "ATI SB700 USB" rev 0x00: apic 2 int 16,
version 1.0, legacy support
ehci0 at pci0 dev 18 function 2 "ATI SB700 USB2" rev 0x00: apic 2 int 17
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "ATI EHCI root hub" rev 2.00/1.00 addr 1
ohci2 at pci0 dev 19 function 0 "ATI SB700 USB" rev 0x00: apic 2 int 18,
version 1.0, legacy support
ehci1 at pci0 dev 19 function 2 "ATI SB700 USB2" rev 0x00: apic 2 int 19
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "ATI EHCI root hub" rev 2.00/1.00 addr 1
piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x3c: SMI
iic0 at piixpm0
spdmem0 at iic0 addr 0x51: 2GB DDR2 SDRAM non-parity PC2-5300CL5 SO-DIMM
azalia0 at pci0 dev 20 function 2 "ATI SBx00 HD Audio" rev 0x00: apic 2 int 16
azalia0: codecs: Conexant/0x5066
audio0 at azalia0
pcib0 at pci0 dev 20 function 3 "ATI SB700 ISA" rev 0x00
ppb2 at pci0 dev 20 function 4 "ATI SB600 PCI" rev 0x00
pci3 at ppb2 bus 4
pchb1 at pci0 dev 24 function 0 "AMD AMD64 0Fh HyperTransport" rev 0x00
pchb2 at pci0 dev 24 function 1 "AMD AMD64 0Fh Address Map" rev 0x00
pchb3 at pci0 dev 24 function 2 "AMD AMD64 0Fh DRAM Cfg" rev 0x00
kate0 at pci0 dev 24 function 3 "AMD AMD64 0Fh Misc Cfg" rev 0x00: core rev
BH-G2
usb2 at ohci0: USB revision 1.0
uhub2 at usb2 "ATI OHCI root hub" rev 1.00/1.00 addr 1
usb3 at ohci1: USB revision 1.0
uhub3 at usb3 "ATI OHCI root hub" rev 1.00/1.00 addr 1
usb4 at ohci2: USB revision 1.0
uhub4 at usb4 "ATI OHCI root hub" rev 1.00/1.00 addr 1
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
mtrr: Pentium Pro MTRR support
run0 at uhub0 port 1 "Ralink 802.11 n WLAN" rev 2.00/1.01 addr 2
run0: MAC/BBP RT3071 (rev 0x0213), RF RT3022 (MIMO 2T2R), address
e0:cb:4e:bd:7d:73
umass0 at uhub1 port 1 configuration 1 interface 0 "Generic USB2.0-CRW" rev
2.00/58.88 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd1 at scsibus1 targ 1 lun 0: <Generic-, Multi-Card, 1.00> SCSI0 0/direct
removable serial.0bda0158114173400000
uvideo0 at uhub1 port 2 configuration 1 interface 0 "Image Processor Integrated
Camera" rev 2.00/30.08 addr 3
video0 at uvideo0
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
root on sd0a swap on sd0b dump on sd0b
usbdevs:
Controller /dev/usb0:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), ATI(0x1002),
rev 1.00
port 1 addr 2: high speed, power 450 mA, config 1, 802.11 n WLAN(0x1784),
Ralink(0x0b05), rev 1.01, iSerialNumber 1.0
port 2 powered
port 3 powered
port 4 powered
port 5 powered
port 6 powered
Controller /dev/usb1:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), ATI(0x1002),
rev 1.00
port 1 addr 2: high speed, power 500 mA, config 1, USB2.0-CRW(0x0158),
Generic(0x0bda), rev 58.88, iSerialNumber 20071114173400000
port 2 addr 3: high speed, power 500 mA, config 1, Integrated Camera(0xb1b4),
Image Processor(0x04f2), rev 30.08, iSerialNumber Integrated Camera
port 3 powered
port 4 powered
port 5 powered
port 6 powered
Controller /dev/usb2:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), ATI(0x1002),
rev 1.00
port 1 powered
port 2 powered
port 3 powered
Controller /dev/usb3:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), ATI(0x1002),
rev 1.00
port 1 powered
port 2 powered
port 3 powered
Controller /dev/usb4:
addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), ATI(0x1002),
rev 1.00
port 1 powered
port 2 powered
port 3 powered
--
Alexander Polakov | plhk.ru
>Release-Note:
>Audit-Trail:
>Unformatted: