Clean-ups for #3616

This commit is contained in:
Flössie
2017-01-20 21:19:55 +01:00
parent 62451f471f
commit f25e161d16
4 changed files with 63 additions and 79 deletions

View File

@@ -2377,7 +2377,7 @@ bool Options::has_retained_extention (Glib::ustring fname)
bool Options::is_extention_enabled (Glib::ustring ext)
{
for (int j = 0; j < (int)parseExtensions.size(); j++)
if (parseExtensions[j].casefold() == ext.casefold()) { // issue 3598 REVIEW OK - no change required
if (parseExtensions[j].casefold() == ext.casefold()) {
return j >= (int)parseExtensionsEnabled.size() || parseExtensionsEnabled[j];
}

View File

@@ -269,7 +269,6 @@ int ProfileStore::findFolderId(const Glib::ustring &path)
*/
const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path)
{
if (path.empty()) {
return nullptr;
}
@@ -277,14 +276,19 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU(Glib::ustring path
if (path == DEFPROFILE_INTERNAL) {
return internalDefaultEntry;
}
// consistently apply casefold() to make sure dot position is correct
const Glib::ustring::size_type lastdot = path.casefold().find_last_of ('.');
if ((lastdot != Glib::ustring::npos) && (lastdot <= path.casefold().size() - 4) && (!path.casefold().compare (lastdot, 4, paramFileExtension)))
// removing the extension
// consistently apply casefold() to make sure dot position is correct
const Glib::ustring casefolded_path = path.casefold();
const Glib::ustring::size_type lastdot_pos = casefolded_path.find_last_of('.');
if (
lastdot_pos != Glib::ustring::npos
&& lastdot_pos <= casefolded_path.size() - 4
&& !casefolded_path.compare(lastdot_pos, 4, paramFileExtension))
{
// removing the extension
// now use dot position without casefold()
path = path.substr(0, path.find_last_of ('.'));
path = path.substr(0, path.find_last_of('.'));
}
// dir separator may come from options file and may be \ or /, we convert them to G_DIR_SEPARATOR_S