From c4c6efb140df3075a7b7ebac9870d00f5199fef0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 19 Sep 2015 19:51:02 -0700 Subject: [PATCH] Remove a crazy unused function from CPluginManager. --- core/logic/PluginSys.cpp | 209 --------------------------------------- core/logic/PluginSys.h | 11 --- 2 files changed, 220 deletions(-) diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index 5294183a..cb1daf32 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -1461,215 +1461,6 @@ IPluginIterator *CPluginManager::GetPluginIterator() return new CPluginIterator(m_plugins); } -bool CPluginManager::TestAliasMatch(const char *alias, const char *localpath) -{ - /* As an optimization, we do not call strlen, but compute the length in the first pass */ - size_t alias_len = 0; - size_t local_len = 0; - - const char *ptr = alias; - unsigned int alias_explicit_paths = 0; - unsigned int alias_path_end = 0; - while (*ptr != '\0') - { - if (*ptr == '\\' || *ptr == '/') - { - alias_explicit_paths++; - alias_path_end = alias_len; - } - alias_len++; - ptr++; - } - - if (alias_explicit_paths && alias_path_end == alias_len - 1) - { - /* Trailing slash is totally invalid here */ - return false; - } - - ptr = localpath; - unsigned int local_explicit_paths = 0; - unsigned int local_path_end = 0; - while (*ptr != '\0') - { - if (*ptr == '\\' || *ptr == '/') - { - local_explicit_paths++; - local_path_end = local_len; - } - local_len++; - ptr++; - } - - /* If the alias has more explicit paths than the real path, - * no match will be possible. - */ - if (alias_explicit_paths > local_explicit_paths) - { - return false; - } - - if (alias_explicit_paths) - { - /* We need to find if the paths match now. For example, these should all match: - * csdm csdm - * csdm optional/csdm - * csdm/ban optional/crab/csdm/ban - */ - const char *aliasptr = alias; - const char *localptr = localpath; - bool match = true; - do - { - if (*aliasptr != *localptr) - { - /* We have to knock one path off */ - local_explicit_paths--; - if (alias_explicit_paths > local_explicit_paths) - { - /* Skip out if we're gonna have an impossible match */ - return false; - } - /* Eat up localptr tokens until we get a result */ - while (((localptr - localpath) < (int)local_path_end) - && *localptr != '/' - && *localptr != '\\') - { - localptr++; - } - /* Check if we hit the end of our searchable area. - * This probably isn't possible because of the path - * count check, but it's a good idea anyway. - */ - if ((localptr - localpath) >= (int)local_path_end) - { - return false; - } else { - /* Consume the slash token */ - localptr++; - } - /* Reset the alias pointer so we can continue consuming */ - aliasptr = alias; - match = false; - continue; - } - /* Note: - * This is safe because if localptr terminates early, aliasptr will too - */ - do - { - /* We should never reach the end of the string because of this check. */ - bool aliasend = (aliasptr - alias) > (int)alias_path_end; - bool localend = (localptr - localpath) > (int)local_path_end; - if (aliasend || localend) - { - if (aliasend && localend) - { - /* we matched, and we can break out now */ - match = true; - break; - } - /* Otherwise, we've hit the end somehow and rest won't match up. Break out. */ - match = false; - break; - } - - /* If we got here, it's safe to compare the next two tokens */ - if (*localptr != *aliasptr) - { - match = false; - break; - } - localptr++; - aliasptr++; - } while (true); - } while (!match); - } - - /* If we got here, it's time to compare filenames */ - const char *aliasptr = alias; - const char *localptr = localpath; - - if (alias_explicit_paths) - { - aliasptr = &alias[alias_path_end + 1]; - } - - if (local_explicit_paths) - { - localptr = &localpath[local_path_end + 1]; - } - - while (true) - { - if (*aliasptr == '*') - { - /* First, see if this is the last character */ - if ((unsigned)(aliasptr - alias) == alias_len - 1) - { - /* If so, there's no need to match anything else */ - return true; - } - /* Otherwise, we need to search for an appropriate matching sequence in local. - * Note that we only need to search up to the next asterisk. - */ - aliasptr++; - bool match = true; - const char *local_orig = localptr; - do - { - match = true; - while (*aliasptr != '\0' && *aliasptr != '*') - { - /* Since aliasptr is never '\0', localptr hitting the end will fail */ - if (*aliasptr != *localptr) - { - match = false; - break; - } - aliasptr++; - localptr++; - } - if (!match) - { - /* If we didn't get a match, we need to advance the search stream. - * This will let us skip tokens while still searching for another match. - */ - localptr = ++local_orig; - /* Make sure we don't go out of bounds */ - if (*localptr == '\0') - { - break; - } - } - } while (!match); - - if (!match) - { - return false; - } else { - /* If we got a match, move on to the next token */ - continue; - } - } else if (*aliasptr == '\0') { - if (*localptr == '\0' - || - strcmp(localptr, ".smx") == 0) - { - return true; - } else { - return false; - } - } else if (*aliasptr != *localptr) { - return false; - } - aliasptr++; - localptr++; - } - - return true; -} - bool CPluginManager::IsLateLoadTime() const { return (m_AllPluginsLoaded || !bridge->IsMapLoading()); diff --git a/core/logic/PluginSys.h b/core/logic/PluginSys.h index aeb9aed2..1fb53af4 100644 --- a/core/logic/PluginSys.h +++ b/core/logic/PluginSys.h @@ -367,17 +367,6 @@ public: */ void LoadAll_SecondPass(); - /** - * Tests a plugin file mask against a local folder. - * The alias is searched backwards from localdir - i.e., given this input: - * csdm/ban csdm/ban - * ban csdm/ban - * csdm/ban optional/csdm/ban - * All of these will return true for an alias match. - * Wildcards are allowed in the filename. - */ - bool TestAliasMatch(const char *alias, const char *localdir); - /** * Returns whether anything loaded will be a late load. */