comparison 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
comparison
equal deleted inserted replaced
420:99868cd95acb 421:35fa4733bc5d
73 Files::listLibraryFilesMatching(string libraryName) 73 Files::listLibraryFilesMatching(string libraryName)
74 { 74 {
75 vector<string> path = Vamp::PluginHostAdapter::getPluginPath(); 75 vector<string> path = Vamp::PluginHostAdapter::getPluginPath();
76 vector<string> libraryFiles; 76 vector<string> libraryFiles;
77 77
78 // we match case-insensitively 78 // we match case-insensitively, but only with ascii range
79 // characters (this string is expected to be utf-8)
79 for (size_t i = 0; i < libraryName.length(); ++i) { 80 for (size_t i = 0; i < libraryName.length(); ++i) {
80 libraryName[i] = tolower(libraryName[i]); 81 if (!(libraryName[i] & 0x80)) {
82 libraryName[i] = char(tolower(libraryName[i]));
83 }
81 } 84 }
82 85
83 for (size_t i = 0; i < path.size(); ++i) { 86 for (size_t i = 0; i < path.size(); ++i) {
84 87
85 vector<string> files = listFiles(path[i], PLUGIN_SUFFIX); 88 vector<string> files = listFiles(path[i], PLUGIN_SUFFIX);
86 89
87 for (vector<string>::iterator fi = files.begin(); 90 for (vector<string>::iterator fi = files.begin();
88 fi != files.end(); ++fi) { 91 fi != files.end(); ++fi) {
89 92
90 if (libraryName != "") { 93 if (libraryName != "") {
91 // we match case-insensitively 94 // we match case-insensitively, but only with ascii
95 // range characters (this string is expected to be
96 // utf-8)
92 string temp = *fi; 97 string temp = *fi;
93 for (size_t i = 0; i < temp.length(); ++i) { 98 for (size_t i = 0; i < temp.length(); ++i) {
94 temp[i] = tolower(temp[i]); 99 if (!(temp[i] & 0x80)) {
100 temp[i] = char(tolower(temp[i]));
101 }
95 } 102 }
96 // libraryName should be lacking an extension, as it 103 // libraryName should be lacking an extension, as it
97 // is supposed to have come from the plugin key 104 // is supposed to have come from the plugin key
98 string::size_type pi = temp.find('.'); 105 string::size_type pi = temp.find('.');
99 if (pi == string::npos) { 106 if (pi == string::npos) {
180 #endif 187 #endif
181 188
182 li = basename.find('.'); 189 li = basename.find('.');
183 if (li != string::npos) basename = basename.substr(0, li); 190 if (li != string::npos) basename = basename.substr(0, li);
184 191
192 // case-insensitive, but only with ascii range characters (this
193 // string is expected to be utf-8)
185 for (size_t i = 0; i < basename.length(); ++i) { 194 for (size_t i = 0; i < basename.length(); ++i) {
186 basename[i] = tolower(basename[i]); 195 if (!(basename[i] & 0x80)) {
196 basename[i] = char(tolower(basename[i]));
197 }
187 } 198 }
188 199
189 return basename; 200 return basename;
190 } 201 }
191 202