Mercurial > hg > vamp-plugin-sdk
diff src/vamp-hostsdk/Files.cpp @ 421:35fa4733bc5d
Fix compiler warnings, and fix potential mangling of utf8 when downcasing (this is still a nasty and incomplete way to do it though)
author | Chris Cannam |
---|---|
date | Thu, 14 Apr 2016 11:49:12 +0100 |
parents | b7268e8bd292 |
children | 79a219ba6178 |
line wrap: on
line diff
--- a/src/vamp-hostsdk/Files.cpp Thu Apr 14 09:19:28 2016 +0100 +++ b/src/vamp-hostsdk/Files.cpp Thu Apr 14 11:49:12 2016 +0100 @@ -75,9 +75,12 @@ vector<string> path = Vamp::PluginHostAdapter::getPluginPath(); vector<string> libraryFiles; - // we match case-insensitively + // we match case-insensitively, but only with ascii range + // characters (this string is expected to be utf-8) for (size_t i = 0; i < libraryName.length(); ++i) { - libraryName[i] = tolower(libraryName[i]); + if (!(libraryName[i] & 0x80)) { + libraryName[i] = char(tolower(libraryName[i])); + } } for (size_t i = 0; i < path.size(); ++i) { @@ -88,10 +91,14 @@ fi != files.end(); ++fi) { if (libraryName != "") { - // we match case-insensitively + // we match case-insensitively, but only with ascii + // range characters (this string is expected to be + // utf-8) string temp = *fi; for (size_t i = 0; i < temp.length(); ++i) { - temp[i] = tolower(temp[i]); + if (!(temp[i] & 0x80)) { + temp[i] = char(tolower(temp[i])); + } } // libraryName should be lacking an extension, as it // is supposed to have come from the plugin key @@ -182,8 +189,12 @@ li = basename.find('.'); if (li != string::npos) basename = basename.substr(0, li); + // case-insensitive, but only with ascii range characters (this + // string is expected to be utf-8) for (size_t i = 0; i < basename.length(); ++i) { - basename[i] = tolower(basename[i]); + if (!(basename[i] & 0x80)) { + basename[i] = char(tolower(basename[i])); + } } return basename;