[Bf-blender-cvs] [dcba34b] master: Fix T38303: same names with different case sorted unpredictable in the file browser.

Brecht Van Lommel noreply at git.blender.org
Tue Jan 21 15:00:45 CET 2014


Commit: dcba34b4119619dccfa03fa8d99971724c87b358
Author: Brecht Van Lommel
Date:   Tue Jan 21 14:50:40 2014 +0100
https://developer.blender.org/rBdcba34b4119619dccfa03fa8d99971724c87b358

Fix T38303: same names with different case sorted unpredictable in the file browser.

The string comparison was in lower case, so the same strings with different case
were considered the same which can make qsort give different results on each
sort since it's not a stable sort. Now take case into account in comparison.

===================================================================

M	source/blender/blenlib/intern/string.c

===================================================================

diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 6b738fa..bbc1354 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -547,7 +547,13 @@ int BLI_natstrcmp(const char *s1, const char *s2)
 		d1++;
 		d2++;
 	}
-	return tiebreaker;
+
+	if (tiebreaker)
+		return tiebreaker;
+	
+	/* we might still have a different string because of lower/upper case, in
+	 * that case fall back to regular string comparison */
+	return strcmp(s1, s2);
 }
 
 void BLI_timestr(double _time, char *str, size_t maxlen)




More information about the Bf-blender-cvs mailing list