[asterisk-commits] murf: branch murf/utf8-whatif r93189 - /team/murf/utf8-whatif/main/editline/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 17 08:17:39 CST 2007


Author: murf
Date: Mon Dec 17 08:17:38 2007
New Revision: 93189

URL: http://svn.digium.com/view/asterisk?view=rev&rev=93189
Log:
add a few comments about c_utf8_seq.

Modified:
    team/murf/utf8-whatif/main/editline/common.c
    team/murf/utf8-whatif/main/editline/refresh.c

Modified: team/murf/utf8-whatif/main/editline/common.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/main/editline/common.c?view=diff&rev=93189&r1=93188&r2=93189
==============================================================================
--- team/murf/utf8-whatif/main/editline/common.c (original)
+++ team/murf/utf8-whatif/main/editline/common.c Mon Dec 17 08:17:38 2007
@@ -50,6 +50,26 @@
  */
 #include "el.h"
 
+/* c_utf8_seq
+   Input: ptrs to string ptrs begin and end.
+          'begin' should be pointing to a char
+          possibly part of a utf8 sequence.
+          upon return, begin and end will be
+          set to point to the beginning and end
+          of the utf8 sequence for a single char.
+          if ANY problem is found, begin and end
+          will both point to the input char.
+          If the char is not involved in a
+          UTF-8 sequence, then begin and end
+          point to the same char. If the sequence
+          is not complete, then begin and end
+          will point to the input char.
+          The input char pointed to by begin,
+          can be the first char of the utf8 
+          sequence, the last char, or any in
+          between, it doesn't matter.
+*/
+
 static void 
 c_utf8_seq(EditLine *el, char **begin, char **end)
 {
@@ -60,6 +80,8 @@
 	b = cp;
 	e = cp;
 
+	/* go backwards thru the input sequence, skipping bytes that start
+       with binary 10...  (continuation bytes) */
 	while (count > 0 && (((unsigned int)*b) & 0xc0) == 0x80 && b > el->el_line.buffer) {
 		count--;
 		b--;

Modified: team/murf/utf8-whatif/main/editline/refresh.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/main/editline/refresh.c?view=diff&rev=93189&r1=93188&r2=93189
==============================================================================
--- team/murf/utf8-whatif/main/editline/refresh.c (original)
+++ team/murf/utf8-whatif/main/editline/refresh.c Mon Dec 17 08:17:38 2007
@@ -952,7 +952,7 @@
 		b = cp;
 		c_utf8_seq(el, &b, &e);
 		
-		h += e-b+1;		/* all chars at least this long */
+		h++;		/* all chars at least this long */
 
 		if (c == '\n') {/* handle newline in data part too */
 			h = 0;
@@ -969,7 +969,7 @@
 					h = 1;
 					v++;
 				}
-			} else if (!isprint((unsigned char) c)) {
+			} else if (!isprint((unsigned char) c) && b == e) {
 				h += 3;
 				if (h > th) {	/* if overflow, compensate */
 					h = h - th;
@@ -982,6 +982,7 @@
 			h = 0;
 			v++;
 		}
+		cp += e-b; /* the for loop incr will give you another +1 to this */
 	}
 
 	/* now go there */




More information about the asterisk-commits mailing list