[Bf-blender-cvs] [a934730] master: Cycles: Remove TM / R and whitespace from OpenCL device names.

Thomas Dinges noreply at git.blender.org
Thu May 21 23:45:05 CEST 2015


Commit: a9347303688336af5c320348a311c76049ba9ca4
Author: Thomas Dinges
Date:   Thu May 21 23:43:18 2015 +0200
Branches: master
https://developer.blender.org/rBa9347303688336af5c320348a311c76049ba9ca4

Cycles: Remove TM / R and whitespace from OpenCL device names.

Was already done for CPU devices, now we also do this for OpenCL.

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

M	intern/cycles/device/device_opencl.cpp
M	intern/cycles/util/util_string.cpp
M	intern/cycles/util/util_string.h
M	intern/cycles/util/util_system.cpp

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

diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp
index 67ed1c7..88c2a2f 100644
--- a/intern/cycles/device/device_opencl.cpp
+++ b/intern/cycles/device/device_opencl.cpp
@@ -3416,7 +3416,7 @@ void device_opencl_info(vector<DeviceInfo>& devices)
 			DeviceInfo info;
 
 			info.type = DEVICE_OPENCL;
-			info.description = string(name);
+			info.description = string_remove_trademark(string(name));
 			info.num = num_base + num;
 			info.id = string_printf("OPENCL_%d", info.num);
 			/* we don't know if it's used for display, but assume it is */
diff --git a/intern/cycles/util/util_string.cpp b/intern/cycles/util/util_string.cpp
index 8675ff3..66856dd 100644
--- a/intern/cycles/util/util_string.cpp
+++ b/intern/cycles/util/util_string.cpp
@@ -105,5 +105,22 @@ string string_strip(const string& s)
 
 }
 
+void string_replace(string& haystack, const string& needle, const string& other)
+{
+	size_t i;
+
+	while((i = haystack.find(needle)) != string::npos)
+		haystack.replace(i, needle.length(), other);
+}
+
+string string_remove_trademark(const string &s)
+{
+	string result = s;
+	string_replace(result, "(TM)", "");
+	string_replace(result, "(R)", "");
+
+	return string_strip(result);
+}
+
 CCL_NAMESPACE_END
 
diff --git a/intern/cycles/util/util_string.h b/intern/cycles/util/util_string.h
index fa1671f..6cb8d8d 100644
--- a/intern/cycles/util/util_string.h
+++ b/intern/cycles/util/util_string.h
@@ -40,8 +40,10 @@ string string_printf(const char *format, ...) PRINTF_ATTRIBUTE;
 
 bool string_iequals(const string& a, const string& b);
 void string_split(vector<string>& tokens, const string& str, const string& separators = "\t ");
+void string_replace(string& haystack, const string& needle, const string& other);
 bool string_endswith(const string& s, const char *end);
 string string_strip(const string& s);
+string string_remove_trademark(const string& s);
 
 CCL_NAMESPACE_END
 
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 4a88ef6..cc88320 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -16,6 +16,7 @@
 
 #include "util_system.h"
 #include "util_types.h"
+#include "util_string.h"
 
 #ifdef _WIN32
 #if(!defined(FREE_WINDOWS))
@@ -75,14 +76,6 @@ static void __cpuid(int data[4], int selector)
 }
 #endif
 
-static void replace_string(string& haystack, const string& needle, const string& other)
-{
-	size_t i;
-
-	while((i = haystack.find(needle)) != string::npos)
-		haystack.replace(i, needle.length(), other);
-}
-
 string system_cpu_brand_string()
 {
 	char buf[48];
@@ -98,10 +91,7 @@ string system_cpu_brand_string()
 		string brand = buf;
 
 		/* make it a bit more presentable */
-		replace_string(brand, "(TM)", "");
-		replace_string(brand, "(R)", "");
-
-		brand = string_strip(brand);
+		brand = string_remove_trademark(brand);
 
 		return brand;
 	}




More information about the Bf-blender-cvs mailing list