[gthumb/gthumb-2-14] Fixed infinite reloading of some images when selected in the file list



commit 213d5a396f81f8fd9d3bf6e14a2d551510c44cd2
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Nov 6 10:33:26 2011 +0100

    Fixed infinite reloading of some images when selected in the file list
    
    Make \r\n equal to \n and 'end of line' equal to \n and to \r\n in
    dom_str_equal to overcome the GMarkupParser bad behaviuor of
    automatically convert \r into \n.
    
    [bug fixed]

 gthumb/dom.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gthumb/dom.c b/gthumb/dom.c
index e460715..5a95be2 100644
--- a/gthumb/dom.c
+++ b/gthumb/dom.c
@@ -813,15 +813,30 @@ dom_str_equal (const char *a,
 	bi = b;
 	while ((*ai != '\0') && (*bi != '\0')) {
 		if (*ai != *bi) {
+			/* \r equal to \n */
+
 			if (! (((*ai == '\r') && (*bi == '\n'))
 			       || ((*ai == '\n') && (*bi == '\r'))))
 			{
 				return FALSE;
 			}
+
+			/* \r\n equal to \n */
+
+			if ((*ai == '\r') && (*(ai + 1) == '\n') && (*bi == '\n') && (*(bi + 1) != '\n'))
+				ai++;
+			if ((*bi == '\r') && (*(bi + 1) == '\n') && (*ai == '\n') && (*(ai + 1) != '\n'))
+				ai++;
 		}
 		ai++;
 		bi++;
 	}
 
-	return *ai == *bi;
+	/* 'end of string' equal to \n and to \r\n */
+
+	return (((*ai == '\0') && (*bi == '\0'))
+		|| ((*ai == '\0') && (*bi == '\n') && (*(bi + 1) == '\0'))
+		|| ((*bi == '\0') && (*ai == '\n') && (*(ai + 1) == '\0'))
+		|| ((*ai == '\0') && (*bi == '\r') && (*(bi + 1) == '\n') && (*(bi + 2) == '\0'))
+		|| ((*bi == '\0') && (*ai == '\r') && (*(ai + 1) == '\n') && (*(ai + 2) == '\0')));
 }



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