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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 29 12:50:22 CST 2007


Author: murf
Date: Thu Nov 29 12:50:22 2007
New Revision: 90159

URL: http://svn.digium.com/view/asterisk?view=rev&rev=90159
Log:
fixed various range notation bugs. A little cleanup. Looks pretty good.

Modified:
    team/murf/utf8-whatif/main/pbx.c
    team/murf/utf8-whatif/main/unicode.c

Modified: team/murf/utf8-whatif/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/main/pbx.c?view=diff&rev=90159&r1=90158&r2=90159
==============================================================================
--- team/murf/utf8-whatif/main/pbx.c (original)
+++ team/murf/utf8-whatif/main/pbx.c Thu Nov 29 12:50:22 2007
@@ -872,7 +872,7 @@
 	struct match_char_range *w;
 	ast_ucs4_to_utf8(node->x, buf, buflen, &z);
 	
-	if (*z) { 
+	if (*z) { /* we didn't fit the whole thing in the output buf... */ 
 		if (strlen(buf) +3 < buflen) {
 			strcat(buf,"...");
 			buflen -= 3;
@@ -885,24 +885,23 @@
 		char max_range_buffer[1024], *mcrp;
 		ucs4_t ucs4buf[2];
 		ucs4buf[1] = 0;
-		max_range_buffer[0] = '[';
+		max_range_buffer[0] = 0;
 		max_range_buffer[1] = 0;
-		mcrp = max_range_buffer+1;
+		mcrp = max_range_buffer;
 		
 		for(w=node->mcr;w;w=w->next)
 		{
 			ucs4buf[0] = w->start;
-			ast_ucs4_to_utf8(ucs4buf, mcrp, 1022-(mcrp-max_range_buffer), 0);
+			ast_ucs4_to_utf8(ucs4buf, mcrp, sizeof(max_range_buffer)-2-(mcrp-max_range_buffer), 0);
 			while (*mcrp)
 				mcrp++;
 			*mcrp++ = '-';
 			ucs4buf[0] = w->end;
-			ast_ucs4_to_utf8(ucs4buf, mcrp, 1022-(mcrp-max_range_buffer), 0);
+			ast_ucs4_to_utf8(ucs4buf, mcrp, sizeof(max_range_buffer)-2-(mcrp-max_range_buffer), 0);
 			while (*mcrp)
 				mcrp++;
 			*mcrp = 0;
 		}
-		strcat(max_range_buffer,"]");
 
 		if (strlen(max_range_buffer) < buflen)
 		{
@@ -1334,6 +1333,7 @@
 				}
 			}
 			*s2 = 0; /* null terminate the character class */
+			next_char = s1+1;
 			specif = ucs4_strlen(buf);
 		} else {
 			

Modified: team/murf/utf8-whatif/main/unicode.c
URL: http://svn.digium.com/view/asterisk/team/murf/utf8-whatif/main/unicode.c?view=diff&rev=90159&r1=90158&r2=90159
==============================================================================
--- team/murf/utf8-whatif/main/unicode.c (original)
+++ team/murf/utf8-whatif/main/unicode.c Thu Nov 29 12:50:22 2007
@@ -105,7 +105,8 @@
 char *ast_ucs4_to_utf8(ucs4_t *ucs, char *out, int outlen, ucs4_t **next)
 {
 	unsigned char *buf = (unsigned char *)out;
-	
+	if (!ucs)
+		return NULL;
 	while (*ucs && outlen > 0)
 	{
 		unsigned char t;
@@ -113,7 +114,8 @@
 		if (*ucs < 0x80) { /* one byte out */
 			if (outlen < 2) {
 				/* no room left */
-				*next = ucs;
+				if (next)
+					*next = ucs;
 				*buf = 0;
 				return out;
 			} else {
@@ -124,7 +126,8 @@
 		} else if (*ucs < 0x800) { /* two bytes out */
 			if (outlen < 3) {
 				/* no room left */
-				*next = ucs;
+				if (next)
+					*next = ucs;
 				*buf = 0;
 				return out;
 			} else {
@@ -138,7 +141,8 @@
 		} else if (*ucs < 0x10000) { /* three bytes out */
 			if (outlen < 4) {
 				/* no room left */
-				*next = ucs;
+				if (next)
+					*next = ucs;
 				*buf = 0;
 				return out;
 			} else {
@@ -154,7 +158,8 @@
 		} else { /* four bytes out */
 			if (outlen < 5) {
 				/* no room left */
-				*next = ucs;
+				if (next)
+					*next = ucs;
 				*buf = 0;
 				return out;
 			} else {
@@ -173,6 +178,8 @@
 		ucs++;
 	}
 	*buf = 0;
+	if (next)
+		*next = ucs;
 	return out;
 }
 
@@ -269,6 +276,7 @@
 		return 0;
 	for (i=0; i<size; i++)
 		p[i] = ustr[i];
+	p[i] = 0;
 	return p;
 }
 




More information about the asterisk-commits mailing list