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

Was already done for CPU devices, now we also do this for OpenCL.
This commit is contained in:
Thomas Dinges 2015-05-21 23:43:18 +02:00
parent 53eab562b4
commit a934730368
4 changed files with 22 additions and 13 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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

View File

@ -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;
}