PERFORCE change 154254 for review
Ed Schouten
ed at FreeBSD.org
Sun Dec 7 05:11:14 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=154254
Change 154254 by ed at ed_flippo on 2008/12/07 13:10:56
Add an implementation of wcwidth() to libteken.
I just took Markus Kuhn's implementation (see URL in
teken_wcwidth.h). Maybe we should add it to libkern. It's good
enough for now.
Affected files ...
.. //depot/projects/mpsafetty/sys/dev/syscons/teken/teken.c#4 edit
.. //depot/projects/mpsafetty/sys/dev/syscons/teken/teken_subr.h#6 edit
.. //depot/projects/mpsafetty/sys/dev/syscons/teken/teken_wcwidth.h#1 add
Differences ...
==== //depot/projects/mpsafetty/sys/dev/syscons/teken/teken.c#4 (text+ko) ====
@@ -46,6 +46,16 @@
#endif /* __FreeBSD__ && _KERNEL */
#include "teken.h"
+#ifdef TEKEN_UTF8
+#include "teken_wcwidth.h"
+#else /* !TEKEN_UTF8 */
+static inline int
+teken_wcwidth(teken_char_t c)
+{
+
+ return (c <= 0x1B) ? -1 : 1;
+}
+#endif /* TEKEN_UTF8 */
#define teken_clamp(x,low,high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
==== //depot/projects/mpsafetty/sys/dev/syscons/teken/teken_subr.h#6 (text+ko) ====
@@ -685,18 +685,11 @@
static void
teken_subr_regular_character(teken_t *t, teken_char_t c)
{
- unsigned int width;
+ int width;
- /* Unprintable characters. */
- if (c <= 0x1B)
+ width = teken_wcwidth(c);
+ if (width < 0)
return;
-
- /* XXX: calculate character width! */
-#ifdef TEKEN_UTF8
- width = 1;
-#else /* !TEKEN_UTF8 */
- width = 1;
-#endif /* TEKEN_UTF8 */
if (t->t_stateflags & TS_INSERT) {
/*
More information about the p4-projects
mailing list