mirror of
https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git
synced 2025-05-15 01:08:39 +00:00
layer: fix env var delimiters
This commit is contained in:
parent
335e80ff1c
commit
faa46b0633
3 changed files with 16 additions and 5 deletions
|
@ -112,13 +112,19 @@ std::string GetEnvSettingName(const char *layer_key, const char *setting_key, Tr
|
|||
return result.str();
|
||||
}
|
||||
|
||||
char GetEnvDelimiter() {
|
||||
#ifdef WIN32 // a define is necessary because ':' is used for disk drives on Windows path
|
||||
return ';';
|
||||
#else
|
||||
return ':';
|
||||
#endif
|
||||
}
|
||||
|
||||
char FindDelimiter(const std::string& s) {
|
||||
if (s.find(',') != std::string::npos) {
|
||||
return ',';
|
||||
} else if (s.find(':') != std::string::npos) { // Typically Unix env variables
|
||||
return ':';
|
||||
} else if (s.find(';') != std::string::npos) { // Typically Win32 env variables
|
||||
return ';';
|
||||
} else if (s.find(GetEnvDelimiter()) != std::string::npos) {
|
||||
return GetEnvDelimiter();
|
||||
} else {
|
||||
return ',';
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace vl {
|
|||
// Find the delimiter (, ; :) in a string made of tokens. Return ',' by default
|
||||
char FindDelimiter(const std::string &s);
|
||||
|
||||
// ';' on WIN32 and ':' on Unix
|
||||
char GetEnvDelimiter();
|
||||
|
||||
// Remove whitespaces at the beginning of the end
|
||||
std::string TrimWhitespace(const std::string &s);
|
||||
|
||||
|
|
|
@ -68,11 +68,13 @@ TEST(test_layer_settings_util, FindDelimiter) {
|
|||
char A = vl::FindDelimiter("VALUE_A,VALUE_B");
|
||||
EXPECT_EQ(',', A);
|
||||
|
||||
#ifdef WIN32
|
||||
char B = vl::FindDelimiter("VALUE_A;VALUE_B");
|
||||
EXPECT_EQ(';', B);
|
||||
|
||||
#else
|
||||
char C = vl::FindDelimiter("VALUE_A:VALUE_B");
|
||||
EXPECT_EQ(':', C);
|
||||
#endif
|
||||
|
||||
EXPECT_EQ(',', vl::FindDelimiter("VALUE_A"));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue