[evolution-patches] Re: [Evolution-hackers] Logic flaw in header_decode_lwsp()



On Fri, 2005-12-02 at 15:19 +0100, Jules Colding wrote:
> Hi,
> 
> The following while statement does not make sense:
> 
> ############# snip ###########
> static void
> header_decode_lwsp(const char **in)
> {
> 	const char *inptr = *in;
> 	char c;
> 
> 	d2(printf("is ws: '%s'\n", *in));
> 
> 	while (camel_mime_is_lwsp(*inptr) || (*inptr =='(' && *inptr != '\0')) {
>         .
>         .
>         .
> 
> ############# snip ###########
> 
> If *inptr is equal to '(' then it is per definition not equal to '\0'. 
> 
> OK, "does not makes sense" might to harsh, but it definitely does not
> seem to done this way on purpose. 

indeed, and while I was fixing that logic problem I also removed the
'\0' check since it isn't needed in any way (if it is lwsp or '(' then
it can't be \0)



> 
> 
-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/ChangeLog,v
retrieving revision 1.2497
diff -u -r1.2497 ChangeLog
--- ChangeLog	2 Dec 2005 08:54:44 -0000	1.2497
+++ ChangeLog	2 Dec 2005 19:13:50 -0000
@@ -1,3 +1,11 @@
+2005-12-02  Jeffrey Stedfast  <fejj novell com>
+
+	* camel-mime-utils.c (header_decode_lwsp): fixed loop bounds
+	checking - we don't need to check for != '\0' if we are checking
+	that it is specifically lwsp || '('.
+	(camel_header_unfold): Fixed to only check the subset of LWSP that
+	is allowable to make the code more clear.
+
 2005-12-02  Shi Pu <shi pu sun com>
 
 	** See bug #321139
@@ -128,7 +136,7 @@
 
 	* camel-vtrash-folder.c: (vtrash_remove_folder):
 	check if mi->real exists, continue otherwise. 
-	
+
 2005-10-11 Vivek Jain <jvivek novell com>
 
 	** See bug #318508
Index: camel-mime-utils.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-mime-utils.c,v
retrieving revision 1.234
diff -u -r1.234 camel-mime-utils.c
--- camel-mime-utils.c	15 Sep 2005 17:35:45 -0000	1.234
+++ camel-mime-utils.c	2 Dec 2005 19:13:51 -0000
@@ -970,8 +970,8 @@
 
 	d2(printf("is ws: '%s'\n", *in));
 
-	while (camel_mime_is_lwsp(*inptr) || (*inptr =='(' && *inptr != '\0')) {
-		while (camel_mime_is_lwsp(*inptr) && inptr != '\0') {
+	while (camel_mime_is_lwsp(*inptr) || *inptr =='(') {
+		while (camel_mime_is_lwsp(*inptr)) {
 			d2(printf("(%c)", *inptr));
 			inptr++;
 		}
@@ -4479,10 +4479,10 @@
 	o = out;
 	while ((c = *inptr++)) {
 		if (c == '\n') {
-			if (camel_mime_is_lwsp(*inptr)) {
+			if (*inptr == ' ' || *inptr == '\t') {
 				do {
 					inptr++;
-				} while (camel_mime_is_lwsp(*inptr));
+				} while (*inptr == ' ' || *inptr == '\t');
 				*o++ = ' ';
 			} else {
 				*o++ = c;


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