[Bf-blender-cvs] [1572c1b] bake-cycles: changes to b2ffdf99 (BLI_path_suffix()) - to be squashed

Dalai Felinto noreply at git.blender.org
Sat Apr 26 18:22:06 CEST 2014


Commit: 1572c1b99020d37f1d38ba46084432adc714de20
Author: Dalai Felinto
Date:   Sat Apr 26 10:21:34 2014 -0300
https://developer.blender.org/rB1572c1b99020d37f1d38ba46084432adc714de20

changes to b2ffdf99 (BLI_path_suffix()) - to be squashed

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

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

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

diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 938b95b..b956ffb 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -720,21 +720,25 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char
 	const size_t sep_len = strlen(sep);
 	ssize_t a;
 	char extension[FILE_MAX];
+	bool has_extension = false;
 
 	if (string_len + sep_len + suffix_len >= maxlen)
 		return false;
 
 	for (a = string_len - 1; a >= 0; a--) {
-		if (ELEM3(string[a], '.', '/', '\\')) {
+		if (string[a] == '.') {
+			has_extension = true;
+			break;
+		}
+		else if (ELEM(string[a], '/', '\\')) {
 			break;
 		}
 	}
 
-	if ((a < 0) || (string[a] != '.')) {
+	if (!has_extension)
 		a = string_len;
-	}
 
-	strcpy(extension, string + a);
+	BLI_strncpy(extension, string + a, sizeof(extension));
 	sprintf(string + a, "%s%s%s", sep, suffix, extension);
 	return true;
 }




More information about the Bf-blender-cvs mailing list