Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Dec 2008 13:11:13 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 154254 for review
Message-ID:  <200812071311.mB7DBDLS083272@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=154254

Change 154254 by ed@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) {
 		/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812071311.mB7DBDLS083272>