giftcurs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[giFTcurs-commits] giFTcurs/src ui_draw.c


From: Göran Weinholt
Subject: [giFTcurs-commits] giFTcurs/src ui_draw.c
Date: Mon, 13 Oct 2003 13:19:02 -0400

CVSROOT:        /cvsroot/giftcurs
Module name:    giFTcurs
Branch:         
Changes by:     Göran Weinholt <address@hidden> 03/10/13 13:19:02

Modified files:
        src            : ui_draw.c 

Log message:
        Don't verify the whole string at once, but do it later for each char.

Patches:
Index: giFTcurs/src/ui_draw.c
diff -u giFTcurs/src/ui_draw.c:1.108 giFTcurs/src/ui_draw.c:1.109
--- giFTcurs/src/ui_draw.c:1.108        Mon Oct 13 12:22:10 2003
+++ giFTcurs/src/ui_draw.c      Mon Oct 13 13:19:01 2003
@@ -18,7 +18,7 @@
  * along with giFTcurs; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,  USA.
  *
- * $Id: ui_draw.c,v 1.108 2003/10/13 16:22:10 weinholt Exp $
+ * $Id: ui_draw.c,v 1.109 2003/10/13 17:19:01 weinholt Exp $
  */
 #include "giftcurs.h"
 
@@ -130,13 +130,6 @@
        move(y, x);
        attrset(selection_color(selected, COLOR_STANDARD));
 
-       if (utf8) {
-               char *end;
-
-               if (!g_utf8_validate(str, -1, &end))
-                       *end = '\0';
-       }
-
        for (u = str; *u && printed < w; u++) {
                if (*u == '\v') {
                        u++;
@@ -158,13 +151,15 @@
                        addch(' ');
                else {
                        if (utf8) {
-                               /* We do that which must be done for utf8. The 
string must
-                                  be valid utf8. */
-                               gunichar c = g_utf8_get_char(u);
-                               gchar *nextc = g_utf8_next_char(u);
+                               /* Get a unicode character from the next few 
bytes. */
+                               gunichar c = g_utf8_get_char_validated(u, -1);
+                               gchar *nextc;
 
+                               if (c < 0)
+                                       break;          /* invalid utf-8 
sequence */
                                if (g_unichar_iswide(c))
                                        printed++;      /* two chars wide */
+                               nextc = g_utf8_next_char(u);
                                addnstr(u, nextc - u);
                                u = nextc - 1;
                        } else {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]