[907] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r893 - branches/barnowl_unicode/owl

daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:11:00 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Thu, 17 Jan 2008 02:03:11 -0500 (EST)

Author: asedeno
Date: 2008-01-17 02:03:11 -0500 (Thu, 17 Jan 2008)
New Revision: 893

Modified:
   branches/barnowl_unicode/owl/editwin.c
Log:
unicode/glib branch
editwin.c - fix a wrapping bug I introduced in the last revision.
It could leave us with a buffer that was not valid UTF-8

Modified: branches/barnowl_unicode/owl/editwin.c
===================================================================
--- branches/barnowl_unicode/owl/editwin.c	2008-01-17 06:23:53 UTC (rev 892)
+++ branches/barnowl_unicode/owl/editwin.c	2008-01-17 07:03:11 UTC (rev 893)
@@ -367,11 +367,10 @@
     c = g_utf8_get_char(ptr1);
     if (owl_util_can_break_after(c)) {
       if (c != ' ') {
-        _owl_editwin_set_xy_by_index(e, ptr1 - e->buff);
-        owl_editwin_key_right(e);
+        i = ptr1 - e->buff;
+        _owl_editwin_set_xy_by_index(e, i);
+        _owl_editwin_insert_bytes(e, 1);
         /* _owl_editwin_insert_bytes may move e->buff. */
-        i = ptr1 - e->buff;
-        _owl_editwin_insert_bytes(e,1);
         ptr1 = e->buff + i;
       }
       *ptr1 = '\n';
@@ -1044,7 +1043,10 @@
 
     /* if we've travelled too far, linewrap */
     if ((e->buffx) >= e->fillcol) {
+      int len = e->bufflen;
       _owl_editwin_linewrap_word(e);
+      /* we may have added a character. */
+      if (i < save) save += e->bufflen - len;
     }
 
     /* did we hit the end of a line too soon? */
@@ -1056,7 +1058,7 @@
       /* ********* we need to make sure we don't pull in a word that's too long ***********/
       e->buff[i]=' ';
     }
-    
+
     /* fix spacing */
     i = _owl_editwin_get_index_from_xy(e);
     if (e->buff[i] == ' ' && e->buff[i+1] == ' ') {
@@ -1072,7 +1074,6 @@
     } else {
       owl_editwin_key_right(e);
     }
-
   }
 
   /* put cursor back at starting point */


home help back first fref pref prev next nref lref last post